UilSemVal.c 124 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these librararies and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*
  24. * @OSF_COPYRIGHT@
  25. * COPYRIGHT NOTICE
  26. * Copyright (c) 1990, 1991, 1992, 1993 Open Software Foundation, Inc.
  27. * ALL RIGHTS RESERVED (MOTIF). See the file named COPYRIGHT.MOTIF for
  28. * the full copyright text.
  29. */
  30. /*
  31. * HISTORY
  32. */
  33. #ifdef REV_INFO
  34. #ifndef lint
  35. static char rcsid[] = "$TOG: UilSemVal.c /main/18 1997/09/15 14:15:21 cshi $"
  36. #endif
  37. #endif
  38. /*
  39. * (c) Copyright 1989, 1990, DIGITAL EQUIPMENT CORPORATION, MAYNARD, MASS. */
  40. /*
  41. **++
  42. ** FACILITY:
  43. **
  44. ** User Interface Language Compiler (UIL)
  45. **
  46. ** ABSTRACT:
  47. **
  48. ** This module contains the second pass routines for performing
  49. ** semantic validation.
  50. **
  51. **--
  52. **/
  53. /*
  54. **
  55. ** INCLUDE FILES
  56. **
  57. **/
  58. #include <stdlib.h>
  59. #include <setjmp.h>
  60. #include <Mrm/MrmAppl.h>
  61. #include <Xm/XmStrDefs.h>
  62. #include "UilDefI.h"
  63. /*
  64. **
  65. ** DEFINE and MACRO DEFINITIONS
  66. **
  67. ** The order of these constants is significant. The constants lower in
  68. ** value than error_arg_type are basically numeric types and various
  69. ** conversions may be done on those types. Those constants are compared
  70. ** numerically with error_arg_type to determine whether they may be
  71. ** converted. Furthermore, the numeric_convert_table is indexed by
  72. ** those constants. If you are adding new arg types, add before error_arg_type
  73. ** if it is a numeric type, but also remember to update the numeric_
  74. ** convert_table below to have an entry for that type. Add the new type
  75. ** after error_arg_type if it is not numeric. lstr_arg_type must be after
  76. ** char_arg_type and before cstr_arg_type. When done, update all the constants
  77. ** to be sequential.
  78. **
  79. **/
  80. #define boolean_arg_type 0
  81. #define integer_arg_type 1
  82. #define single_float_arg_type 2
  83. #define float_arg_type 3
  84. #define horizontal_integer_arg_type 4
  85. #define vertical_integer_arg_type 5
  86. #define horizontal_float_arg_type 6
  87. #define vertical_float_arg_type 7
  88. #define error_arg_type 8
  89. #define char_arg_type 9
  90. #define lstr_arg_type 10
  91. #define cstr_arg_type 11
  92. #define keysym_arg_type 12
  93. #define font_arg_type 13
  94. #define color_arg_type 14
  95. #define xbitmap_arg_type 15
  96. #define reason_arg_type 16
  97. #define argument_arg_type 17
  98. #define font_table_arg_type 18
  99. #define wcstr_arg_type 19
  100. #define fontset_arg_type 20
  101. /* BEGIN HaL fix CR 5429 */
  102. #define classrec_arg_type 21
  103. /* END HaL Fix CR 5429 */
  104. /*
  105. **
  106. ** EXTERNAL VARIABLE DECLARATIONS
  107. **
  108. **/
  109. /*
  110. **
  111. ** GLOBAL VARIABLE DECLARATIONS
  112. **
  113. **/
  114. /*
  115. **
  116. ** OWN VARIABLE DECLARATIONS
  117. **
  118. **/
  119. static unsigned int ref_chk_value = 0;
  120. static short in_expr = 0;
  121. static int cycle_id = 1;
  122. /*
  123. ** This table is indexed by arg_types defined above that are less than
  124. ** error_arg_type.
  125. **/
  126. static int ( * numeric_convert_table[])() = {
  127. 0,
  128. sem_convert_to_integer,
  129. sem_convert_to_single_float,
  130. sem_convert_to_float,
  131. sem_convert_to_integer,
  132. sem_convert_to_integer,
  133. sem_convert_to_float,
  134. sem_convert_to_float,
  135. sem_convert_to_error };
  136. /*
  137. * The next two definitions must match value sets defining
  138. * expression operators in UilSymDef.h
  139. */
  140. static unsigned int legal_operand_type[ ] = {
  141. /* unused */ 0,
  142. /* not */ 1 << sym_k_bool_value | 1 << sym_k_integer_value,
  143. /* unary plus */ 1 << sym_k_integer_value |
  144. 1 << sym_k_horizontal_integer_value |
  145. 1 << sym_k_vertical_integer_value |
  146. 1 << sym_k_float_value |
  147. 1 << sym_k_horizontal_float_value |
  148. 1 << sym_k_vertical_float_value |
  149. 1 << sym_k_single_float_value,
  150. /* unary minus */ 1 << sym_k_integer_value |
  151. 1 << sym_k_horizontal_integer_value |
  152. 1 << sym_k_vertical_integer_value |
  153. 1 << sym_k_float_value |
  154. 1 << sym_k_horizontal_float_value |
  155. 1 << sym_k_vertical_float_value |
  156. 1 << sym_k_single_float_value,
  157. /* comp_str */ 1 << sym_k_char_8_value |
  158. 1 << sym_k_localized_string_value |
  159. 1 << sym_k_compound_string_value,
  160. /* wchar_str */ 1 << sym_k_localized_string_value,
  161. /* multiply */ 1 << sym_k_integer_value |
  162. 1 << sym_k_horizontal_integer_value |
  163. 1 << sym_k_vertical_integer_value |
  164. 1 << sym_k_float_value |
  165. 1 << sym_k_horizontal_float_value |
  166. 1 << sym_k_vertical_float_value |
  167. 1 << sym_k_single_float_value,
  168. /* divide */ 1 << sym_k_integer_value |
  169. 1 << sym_k_horizontal_integer_value |
  170. 1 << sym_k_vertical_integer_value |
  171. 1 << sym_k_float_value |
  172. 1 << sym_k_horizontal_float_value |
  173. 1 << sym_k_vertical_float_value |
  174. 1 << sym_k_single_float_value,
  175. /* add */ 1 << sym_k_integer_value |
  176. 1 << sym_k_horizontal_integer_value |
  177. 1 << sym_k_vertical_integer_value |
  178. 1 << sym_k_float_value |
  179. 1 << sym_k_horizontal_float_value |
  180. 1 << sym_k_vertical_float_value |
  181. 1 << sym_k_single_float_value,
  182. /* subtract */ 1 << sym_k_integer_value |
  183. 1 << sym_k_horizontal_integer_value |
  184. 1 << sym_k_vertical_integer_value |
  185. 1 << sym_k_float_value |
  186. 1 << sym_k_horizontal_float_value |
  187. 1 << sym_k_vertical_float_value |
  188. 1 << sym_k_single_float_value,
  189. /* left shift */ 1 << sym_k_integer_value,
  190. /* right shift */ 1 << sym_k_integer_value,
  191. /* and */ 1 << sym_k_bool_value |
  192. 1 << sym_k_integer_value |
  193. 1 << sym_k_char_8_value |
  194. 1 << sym_k_localized_string_value |
  195. 1 << sym_k_compound_string_value |
  196. 1 << sym_k_localized_string_value,
  197. /* xor */ 1 << sym_k_bool_value | 1 << sym_k_integer_value,
  198. /* or */ 1 << sym_k_bool_value | 1 << sym_k_integer_value,
  199. /* cat */ 1 << sym_k_char_8_value |
  200. 1 << sym_k_compound_string_value |
  201. 1 << sym_k_localized_string_value,
  202. /* valref */ 0xFFFFFFFF,
  203. /* coerce */ 0xFFFFFFFF
  204. };
  205. static char *operator_symbol[ ] = {
  206. /* unused */ "** OPERATOR ERROR**",
  207. /* not */ "not operator",
  208. /* unary plus */ "unary plus operator",
  209. /* unary minus */ "unary minus operator",
  210. /* comp str */ "compound string function",
  211. /* wchar str */ "wide_character string function",
  212. /* multiply */ "multiply operator",
  213. /* divide */ "divide operator",
  214. /* add */ "add operator",
  215. /* subtract */ "subtract operator",
  216. /* left shift */ "left shift operator",
  217. /* right shift */ "right shift operator",
  218. /* and */ "and operator",
  219. /* xor */ "exclusive or operator",
  220. /* or */ "or operator",
  221. /* cat */ "concatenate operator",
  222. /* coerce */ "coerce operator",
  223. };
  224. static char *value_text[ ] = {
  225. /* boolean */ "boolean expression",
  226. /* integer */ "integer expression",
  227. /* float */ "floating point expression",
  228. };
  229. static sym_argument_entry_type **arg_seen;
  230. static sym_callback_entry_type **reason_seen;
  231. /*
  232. **++
  233. ** FUNCTIONAL DESCRIPTION:
  234. **
  235. ** This function walks the entire parse tree for the input, and
  236. ** performs semantic validation. It guarantees type matching,
  237. ** that arguments and controls and legal, etc.
  238. **
  239. ** FORMAL PARAMETERS:
  240. **
  241. ** none
  242. **
  243. ** IMPLICIT INPUTS:
  244. **
  245. ** sym_az_root_entry
  246. **
  247. ** IMPLICIT OUTPUTS:
  248. **
  249. ** none
  250. **
  251. ** FUNCTION VALUE:
  252. **
  253. ** void
  254. **
  255. ** SIDE EFFECTS:
  256. **
  257. ** error messages may be issued for objects that are still undefined
  258. ** or of the wrong type
  259. **
  260. **--
  261. **/
  262. void sem_validation ()
  263. {
  264. /*
  265. * Allocate storage if required
  266. */
  267. if ( arg_seen == NULL )
  268. arg_seen = (sym_argument_entry_type **)
  269. XtMalloc (sizeof(sym_argument_entry_type *)*(uil_max_arg+1));
  270. if ( reason_seen == NULL )
  271. reason_seen = (sym_callback_entry_type **)
  272. XtMalloc (sizeof(sym_argument_entry_type *)*(uil_max_reason+1));
  273. /*
  274. * Walk the parse tree, performing validation on each node which
  275. * requires it.
  276. */
  277. sem_validate_node (( sym_entry_type *)sym_az_root_entry->sections);
  278. }
  279. /*
  280. **++
  281. ** FUNCTIONAL DESCRIPTION:
  282. **
  283. ** This routine recursively walks through the parse tree. It
  284. ** ignores any nodes which require no pass 2 validation, and
  285. ** calls a specialized routine for any others. It checks for
  286. ** any requests to terminate.
  287. **
  288. ** FORMAL PARAMETERS:
  289. **
  290. ** node current parse tree node
  291. **
  292. ** IMPLICIT INPUTS:
  293. **
  294. ** >
  295. **
  296. ** IMPLICIT OUTPUTS:
  297. **
  298. ** >
  299. **
  300. ** FUNCTION VALUE:
  301. **
  302. ** void
  303. **
  304. ** SIDE EFFECTS:
  305. **
  306. ** may terminate processing
  307. **
  308. **--
  309. **/
  310. void sem_validate_node (node)
  311. sym_entry_type *node;
  312. {
  313. /*
  314. * Local variables
  315. */
  316. sym_value_entry_type *value_node;
  317. sym_widget_entry_type *widget_node;
  318. sym_widget_entry_type *child_node;
  319. sym_list_entry_type *list_node;
  320. sym_include_file_entry_type *ifile_node;
  321. sym_section_entry_type *section_node;
  322. sym_obj_entry_type *entry_node;
  323. sym_obj_entry_type *list_member;
  324. sym_nested_list_entry_type *nested_list_entry;
  325. sym_control_entry_type *control_entry;
  326. /*
  327. * Call the status callback routine to report progress and check status
  328. */
  329. /* %COMPLETE */
  330. Uil_percent_complete = 80;
  331. if ( Uil_cmd_z_command.status_cb != (Uil_continue_type(*)())NULL )
  332. diag_report_status ();
  333. /*
  334. * Switch on the node type for validation and recursion.
  335. */
  336. if ( node == NULL ) return;
  337. switch ( node->header.b_tag )
  338. {
  339. case sym_k_value_entry:
  340. value_node = (sym_value_entry_type *) node;
  341. sem_validate_value_node (value_node);
  342. break;
  343. case sym_k_widget_entry:
  344. case sym_k_gadget_entry:
  345. case sym_k_child_entry:
  346. widget_node = (sym_widget_entry_type *) node;
  347. sem_validate_widget_node (widget_node);
  348. /*
  349. * Recurse for children and validate all children. Duplicate
  350. * validation will not occur since sem_validate_widget_node checks
  351. * bflags for validated flag.
  352. */
  353. sem_validate_node (( sym_entry_type *)widget_node->az_controls);
  354. break;
  355. case sym_k_list_entry:
  356. /*
  357. * recursive entry point for processing controls lists.
  358. */
  359. list_node = (sym_list_entry_type *) node;
  360. if ( list_node->header.b_type != sym_k_control_list )
  361. break;
  362. for (list_member=(sym_obj_entry_type *)list_node->obj_header.az_next;
  363. list_member!=NULL;
  364. list_member=(sym_obj_entry_type *)list_member->obj_header.az_next)
  365. switch ( list_member->header.b_tag )
  366. {
  367. case sym_k_nested_list_entry:
  368. nested_list_entry =
  369. (sym_nested_list_entry_type *) list_member;
  370. sem_validate_node (( sym_entry_type *)nested_list_entry->az_list);
  371. break;
  372. case sym_k_control_entry:
  373. control_entry = (sym_control_entry_type *) list_member;
  374. child_node = (sym_widget_entry_type *)
  375. control_entry->az_con_obj;
  376. sem_validate_node (( sym_entry_type *)child_node);
  377. break;
  378. }
  379. break;
  380. case sym_k_include_file_entry:
  381. ifile_node = (sym_include_file_entry_type *) node;
  382. sem_validate_node (( sym_entry_type *)ifile_node->sections);
  383. break;
  384. case sym_k_section_entry:
  385. section_node = (sym_section_entry_type *) node;
  386. sem_validate_node (( sym_entry_type *)section_node->next);
  387. switch ( section_node->header.b_type )
  388. {
  389. case sym_k_section_tail:
  390. break;
  391. default:
  392. entry_node = (sym_obj_entry_type *) section_node->entries;
  393. sem_validate_node (( sym_entry_type *)entry_node);
  394. break;
  395. }
  396. break;
  397. }
  398. }
  399. /*
  400. **++
  401. ** FUNCTIONAL DESCRIPTION:
  402. **
  403. ** This routine validates a value node
  404. **
  405. ** FORMAL PARAMETERS:
  406. **
  407. ** value_node the symbol table node to be validated.
  408. **
  409. ** IMPLICIT INPUTS:
  410. **
  411. ** IMPLICIT OUTPUTS:
  412. **
  413. ** FUNCTION VALUE:
  414. **
  415. ** pointer to the value node resulting from the operation (may be
  416. ** different from input)
  417. **
  418. ** SIDE EFFECTS:
  419. **
  420. ** error reporting
  421. **
  422. **--
  423. **/
  424. sym_value_entry_type *sem_validate_value_node (value_node)
  425. sym_value_entry_type *value_node;
  426. {
  427. /*
  428. * Local variables
  429. */
  430. /*
  431. * Both evaluation and validation are done by the value evaluation routine
  432. */
  433. if ( value_node == NULL )
  434. return NULL;
  435. if ( value_node->obj_header.b_flags & sym_m_validated )
  436. return value_node;
  437. sem_evaluate_value (value_node);
  438. value_node->obj_header.b_flags |= sym_m_validated;
  439. return value_node;
  440. }
  441. /*
  442. **++
  443. ** FUNCTIONAL DESCRIPTION:
  444. **
  445. ** This routine validates a widget node
  446. **
  447. ** FORMAL PARAMETERS:
  448. **
  449. ** widget_node the symbol table node to be validated.
  450. **
  451. ** IMPLICIT INPUTS:
  452. **
  453. ** IMPLICIT OUTPUTS:
  454. **
  455. ** FUNCTION VALUE:
  456. **
  457. ** SIDE EFFECTS:
  458. **
  459. ** error reporting
  460. **
  461. **--
  462. **/
  463. void sem_validate_widget_node (widget_node)
  464. sym_widget_entry_type *widget_node;
  465. {
  466. /*
  467. * Local variables
  468. */
  469. unsigned int widget_type;
  470. sym_list_entry_type *list_entry; /* for various lists */
  471. /*
  472. * if this widget has already been validated just return
  473. */
  474. if (widget_node->obj_header.b_flags & sym_m_validated)
  475. return;
  476. /*
  477. * Pick up widget parameters
  478. */
  479. if (widget_node->header.b_tag == sym_k_child_entry)
  480. widget_type = child_class_table[widget_node->header.b_type];
  481. else widget_type = widget_node->header.b_type;
  482. /*
  483. * Validate the arguments. Each argument in the list is validated
  484. * by an argument validation routine.
  485. */
  486. if ( widget_node->az_arguments != NULL )
  487. {
  488. int ndx;
  489. for ( ndx=0 ; ndx<uil_max_arg+1 ; ndx++ )
  490. arg_seen[ndx] = 0;
  491. sem_validate_argument_list (widget_node, widget_type,
  492. widget_node->az_arguments, arg_seen);
  493. }
  494. /*
  495. * Validate the callbacks. Each callback is validated by a validation
  496. * routine
  497. */
  498. if ( widget_node->az_callbacks != NULL )
  499. {
  500. int ndx;
  501. for ( ndx=0 ; ndx<uil_max_reason+1 ; ndx++ )
  502. reason_seen[ndx] = 0;
  503. sem_validate_callback_list (widget_node, widget_type,
  504. widget_node->az_callbacks, reason_seen);
  505. }
  506. /*
  507. * Validate the controls. Each is validated by a validation routine.
  508. * Also check the node for cycles.
  509. */
  510. if ( widget_node->az_controls != NULL )
  511. {
  512. int gadget_count = 0;
  513. list_entry = (sym_list_entry_type *) widget_node->az_controls;
  514. sem_validate_control_list (widget_node, widget_type,
  515. list_entry, &gadget_count);
  516. list_entry->w_gadget_count = gadget_count;
  517. sem_validate_widget_cycle (list_entry, widget_node->obj_header.az_name);
  518. }
  519. /*
  520. * Mark the widget as validated
  521. */
  522. widget_node->obj_header.b_flags |= sym_m_validated;
  523. }
  524. /*
  525. **++
  526. ** FUNCTIONAL DESCRIPTION:
  527. **
  528. ** This routine validates all the arguments in an argument list.
  529. ** It recurse down nested lists.
  530. **
  531. ** FORMAL PARAMETERS:
  532. **
  533. ** widget_node the current widget
  534. ** widget_type the current widget's type
  535. ** list_entry list to be validated
  536. ** seen flag table to detect duplicate arguments
  537. **
  538. ** IMPLICIT INPUTS:
  539. **
  540. ** IMPLICIT OUTPUTS:
  541. **
  542. ** FUNCTION VALUE:
  543. **
  544. ** SIDE EFFECTS:
  545. **
  546. **--
  547. **/
  548. void sem_validate_argument_list (widget_node, widget_type, list_entry, seen)
  549. sym_widget_entry_type *widget_node;
  550. unsigned int widget_type;
  551. sym_list_entry_type *list_entry;
  552. sym_argument_entry_type **seen;
  553. {
  554. /*
  555. * Local variables
  556. */
  557. sym_obj_entry_type *list_member;
  558. sym_nested_list_entry_type *nested_list_entry;
  559. sym_argument_entry_type *argument_entry;
  560. /* For fixing DTS 9540 */
  561. static int nest_count=0;
  562. static sym_list_entry_type *nest_head = NULL;
  563. /*
  564. * loop down the list
  565. */
  566. if ( list_entry == NULL ) return;
  567. for (list_member=(sym_obj_entry_type *)list_entry->obj_header.az_next;
  568. list_member!=NULL;
  569. list_member=(sym_obj_entry_type *)list_member->obj_header.az_next)
  570. switch ( list_member->header.b_tag )
  571. {
  572. case sym_k_nested_list_entry:
  573. nested_list_entry = (sym_nested_list_entry_type *) list_member;
  574. /* Begin fixing DTS 9540 */
  575. if(!nest_count)
  576. nest_head = nested_list_entry->az_list;
  577. nest_count++;
  578. if(nest_count == 1 || nest_head != nested_list_entry->az_list){
  579. sem_validate_argument_list (widget_node, widget_type,
  580. nested_list_entry->az_list, seen);
  581. nest_count--;
  582. }else
  583. diag_issue_diagnostic
  584. (d_circular_ref,
  585. _sar_source_pos2(list_entry),
  586. "argument name");
  587. /* End fixing DTS 9540 */
  588. break;
  589. case sym_k_argument_entry:
  590. argument_entry = (sym_argument_entry_type *) list_member;
  591. sem_validate_argument_entry (widget_node, widget_type,
  592. list_entry, argument_entry, seen);
  593. break;
  594. default:
  595. diag_issue_diagnostic
  596. ( d_list_item,
  597. _sar_source_pos2 ( list_entry ),
  598. diag_tag_text (sym_k_argument_entry),
  599. diag_tag_text (list_entry->header.b_type),
  600. diag_tag_text (list_entry->header.b_tag) );
  601. }
  602. }
  603. /*
  604. **++
  605. ** FUNCTIONAL DESCRIPTION:
  606. **
  607. ** This routine performs validation for a single argument entry
  608. ** for the current widget node.
  609. **
  610. ** FORMAL PARAMETERS:
  611. **
  612. ** widget_node the current widget
  613. ** widget_type the current widget's type
  614. ** list_entry list entry for current argument entry
  615. ** argument_entry the current argument entry
  616. ** seen flag table to detect duplicate arguments
  617. **
  618. ** IMPLICIT INPUTS:
  619. **
  620. **
  621. ** IMPLICIT OUTPUTS:
  622. **
  623. ** FUNCTION VALUE:
  624. **
  625. ** void
  626. **
  627. ** SIDE EFFECTS:
  628. **
  629. ** error reporting
  630. **
  631. **--
  632. **/
  633. void sem_validate_argument_entry
  634. (widget_node, widget_type, list_entry, argument_entry, seen)
  635. sym_widget_entry_type *widget_node;
  636. unsigned int widget_type;
  637. sym_list_entry_type *list_entry;
  638. sym_argument_entry_type *argument_entry;
  639. sym_argument_entry_type **seen;
  640. {
  641. /*
  642. * Local variables
  643. */
  644. sym_value_entry_type *argname_value_entry;
  645. sym_value_entry_type *argvalue_value_entry;
  646. key_keytable_entry_type *keytable_entry;
  647. sym_argument_entry_type **seen_entry;
  648. boolean supported_flag;
  649. unsigned char expected_type, actual_type, actual_tag;
  650. boolean valid_value;
  651. /*
  652. * ignore error entries, consistency check
  653. */
  654. if ( argument_entry->header.b_tag == sym_k_error_entry ) return;
  655. _assert (argument_entry->header.b_tag==sym_k_argument_entry,
  656. "unexpected non argument entry");
  657. /*
  658. * Validate and evaluate the argument name and argument value entries.
  659. */
  660. sem_validate_node (( sym_entry_type *)argument_entry->az_arg_name);
  661. /*
  662. * There is no need to validate the value if it is a widget since widgets are
  663. * validated elsewhere and you can't define widgets in an argument list anyway.
  664. */
  665. if ( argument_entry->az_arg_value == NULL )
  666. return;
  667. if ((argument_entry->az_arg_value->header.b_tag != sym_k_widget_entry) &&
  668. (argument_entry->az_arg_value->header.b_tag != sym_k_gadget_entry))
  669. sem_validate_node (( sym_entry_type *)argument_entry->az_arg_value);
  670. argname_value_entry = (sym_value_entry_type *) argument_entry->az_arg_name;
  671. if ( argname_value_entry == NULL )
  672. {
  673. diag_issue_diagnostic
  674. (d_bad_argument,
  675. _sar_source_pos2(argument_entry),
  676. "argument name");
  677. return;
  678. }
  679. sem_evaluate_value_expr(argname_value_entry);
  680. _assert (argname_value_entry->header.b_tag==sym_k_value_entry,
  681. "invalid argument name value_entry");
  682. if (argname_value_entry->b_type != sym_k_argument_value)
  683. {
  684. diag_issue_diagnostic
  685. (d_list_item,
  686. _sar_source_pos2(argname_value_entry),
  687. diag_value_text(argname_value_entry->b_type),
  688. diag_tag_text(list_entry->header.b_type),
  689. diag_tag_text(list_entry->header.b_tag));
  690. return;
  691. }
  692. argvalue_value_entry = (sym_value_entry_type *) argument_entry->az_arg_value;
  693. /* BEGIN HAL Fix CR 3857 */
  694. if ((argument_entry->az_arg_value->header.b_tag != sym_k_widget_entry) &&
  695. (argument_entry->az_arg_value->header.b_tag != sym_k_gadget_entry))
  696. /* END HAL Fix CR 3857 */
  697. sem_evaluate_value_expr(argvalue_value_entry);
  698. /*
  699. * Check for unsupported arguments. Validate constraints.
  700. * This check is required for known toolkit arguments in
  701. * toolkit widgets.
  702. */
  703. if ( (argname_value_entry->obj_header.b_flags&sym_m_builtin) &&
  704. (widget_type!=uil_sym_user_defined_object) &&
  705. (argname_value_entry->obj_header.az_name == NULL) )
  706. {
  707. /*
  708. * Pick up the token keytable entry for the argument.
  709. * Fork on whether it is a constraint argument
  710. */
  711. keytable_entry = (key_keytable_entry_type *)
  712. argname_value_entry->value.az_data;
  713. _assert (keytable_entry->b_class==tkn_k_class_argument,
  714. "unexpected non-argument keytable entry");
  715. if ( _constraint_check(keytable_entry->b_subclass) )
  716. sem_validate_constraint_entry (widget_node, argument_entry, widget_type);
  717. else
  718. {
  719. supported_flag = sem_argument_allowed
  720. (keytable_entry->b_subclass, widget_type);
  721. if ( ! supported_flag )
  722. diag_issue_diagnostic
  723. (d_unsupported,
  724. _sar_source_pos2(argument_entry),
  725. keytable_entry->at_name,
  726. diag_tag_text(argument_entry->header.b_tag),
  727. diag_object_text(widget_type));
  728. }
  729. /*
  730. * Check for duplicate arguments. A warning is issued, but the
  731. * argument is not removed from the list, since it may occur in
  732. * an argument list - and the argument list may be referenced in
  733. * another context where this argument is not duplicated.
  734. */
  735. seen_entry = (sym_argument_entry_type **)
  736. &seen[keytable_entry->b_subclass];
  737. if ( *seen_entry != NULL )
  738. {
  739. diag_issue_diagnostic
  740. (d_supersede,
  741. _sar_source_pos2(argument_entry),
  742. keytable_entry->at_name,
  743. diag_tag_text(argument_entry->header.b_tag),
  744. diag_tag_text(list_entry->header.b_type),
  745. diag_tag_text(list_entry->header.b_tag));
  746. }
  747. else
  748. {
  749. *seen_entry = argument_entry;
  750. }
  751. /*
  752. * Make sure that any enumeration value reference is valid.
  753. */
  754. sem_validate_argument_enumset (argument_entry,
  755. keytable_entry->b_subclass,
  756. argvalue_value_entry);
  757. }
  758. /*
  759. ** Verify the value type for this argument, if it is a
  760. ** built-in argument or a user_defined argument. Check for
  761. ** proper enumeration set match
  762. */
  763. if ( (argname_value_entry->obj_header.b_flags & sym_m_builtin) &&
  764. (argname_value_entry->obj_header.az_name == NULL) )
  765. {
  766. key_keytable_entry_type * keytable_entry;
  767. keytable_entry =
  768. (key_keytable_entry_type *) argname_value_entry->value.az_data;
  769. _assert (keytable_entry->b_class==tkn_k_class_argument,
  770. "name is not an argument");
  771. expected_type = argument_type_table[keytable_entry->b_subclass];
  772. }
  773. else
  774. expected_type = argname_value_entry->b_arg_type;
  775. /*
  776. ** Argument value validation
  777. **
  778. ** Acquire and evaluate argument value.
  779. ** Allow a widget reference as the value of an argument. NOTE: gadgets
  780. ** are not allowed as argument values, only controls.
  781. **
  782. ** This entry may be absent due to extensive compilation errors.
  783. */
  784. if ( argvalue_value_entry == NULL ) return;
  785. actual_tag = argvalue_value_entry->header.b_tag;
  786. switch ( actual_tag )
  787. {
  788. case sym_k_value_entry:
  789. actual_type = argvalue_value_entry->b_type;
  790. break;
  791. case sym_k_widget_entry:
  792. actual_type = sym_k_widget_ref_value;
  793. break;
  794. default:
  795. _assert (FALSE, "value entry missing");
  796. break;
  797. }
  798. valid_value = (actual_type == expected_type);
  799. /*
  800. ** Coerce actual_type to expected_type for certain special cases.
  801. ** We'll do this by creating a new value node for the coerced value with
  802. ** the coerce unary operator set. We'll actually perform the coersion
  803. ** operation here and set the flag indicating that expression evaluation
  804. ** has already taken place.
  805. */
  806. if ( expected_type == sym_k_any_value )
  807. valid_value = TRUE;
  808. if ( actual_type == sym_k_any_value )
  809. valid_value = TRUE;
  810. if ( actual_type == sym_k_identifier_value )
  811. valid_value = TRUE;
  812. if (( expected_type == sym_k_pixmap_value ) &&
  813. ( actual_type == sym_k_icon_value ))
  814. valid_value = TRUE;
  815. if (( expected_type == sym_k_pixmap_value ) &&
  816. ( actual_type == sym_k_xbitmapfile_value ))
  817. valid_value = TRUE;
  818. if (( expected_type == sym_k_color_value) && /* RAP rgb data type */
  819. ( actual_type == sym_k_rgb_value))
  820. valid_value = TRUE;
  821. /* BEGIN HaL fix CR 5429 */
  822. if (( expected_type == sym_k_class_rec_name_value) &&
  823. ( actual_type == sym_k_class_rec_name_value))
  824. valid_value = TRUE;
  825. /* END HaL fix CR 5429 */
  826. /* For boolean values converted to enums */
  827. if ((expected_type == sym_k_integer_value) &&
  828. (actual_type == sym_k_bool_value))
  829. valid_value = TRUE;
  830. if (( expected_type == sym_k_char_8_value ) &&
  831. ( actual_type == sym_k_localized_string_value ))
  832. valid_value = TRUE;
  833. if (( expected_type == sym_k_compound_string_value ) &&
  834. ( actual_type == sym_k_char_8_value ))
  835. {
  836. valid_value = TRUE;
  837. if ( (argvalue_value_entry->obj_header.b_flags & sym_m_private) != 0)
  838. {
  839. sym_value_entry_type *cstr_value;
  840. cstr_value = (sym_value_entry_type *) sem_create_cstr();
  841. cstr_value->b_expr_opr = sym_k_coerce_op;
  842. cstr_value->az_exp_op1 = argvalue_value_entry;
  843. sem_evaluate_value_expr (cstr_value);
  844. argument_entry->az_arg_value = cstr_value;
  845. }
  846. }
  847. if (( expected_type == sym_k_compound_string_value ) &&
  848. ( actual_type == sym_k_localized_string_value ))
  849. {
  850. valid_value = TRUE;
  851. if ( (argvalue_value_entry->obj_header.b_flags & sym_m_private) != 0)
  852. {
  853. sym_value_entry_type *cstr_value;
  854. cstr_value = (sym_value_entry_type *) sem_create_cstr();
  855. cstr_value->b_expr_opr = sym_k_coerce_op;
  856. cstr_value->az_exp_op1 = argvalue_value_entry;
  857. sem_evaluate_value_expr (cstr_value);
  858. argument_entry->az_arg_value = cstr_value;
  859. }
  860. }
  861. if (( expected_type == sym_k_wchar_string_value ) &&
  862. ( actual_type == sym_k_localized_string_value ))
  863. {
  864. valid_value = TRUE;
  865. if ( (argvalue_value_entry->obj_header.b_flags & sym_m_private) != 0)
  866. {
  867. sym_value_entry_type *wcstr_value;
  868. wcstr_value = (sym_value_entry_type *) sem_create_wchar_str();
  869. wcstr_value->b_expr_opr = sym_k_coerce_op;
  870. wcstr_value->az_exp_op1 = argvalue_value_entry;
  871. sem_evaluate_value_expr (wcstr_value);
  872. argument_entry->az_arg_value = wcstr_value;
  873. }
  874. }
  875. if (( expected_type == sym_k_font_table_value ) &&
  876. (( actual_type == sym_k_font_value ) ||
  877. ( actual_type == sym_k_fontset_value )))
  878. {
  879. valid_value = TRUE;
  880. if ( (argvalue_value_entry->obj_header.b_flags & sym_m_private) != 0)
  881. {
  882. sym_value_entry_type *font_table;
  883. font_table =
  884. sem_create_value_entry
  885. ((char*)&argvalue_value_entry, sizeof(long),
  886. sym_k_font_table_value);
  887. font_table->b_table_count = 1;
  888. font_table->az_first_table_value = argvalue_value_entry;
  889. font_table->b_expr_opr = sym_k_coerce_op;
  890. font_table->az_exp_op1 = argvalue_value_entry;
  891. font_table->b_aux_flags |= sym_m_exp_eval;
  892. argument_entry->az_arg_value = sem_evaluate_value (font_table);
  893. }
  894. }
  895. if (( expected_type == sym_k_keysym_value ) &&
  896. ( actual_type == sym_k_integer_value ))
  897. {
  898. /*
  899. * If an integer is incountered when expecting a keysym then just make the
  900. * integer into a keysym if the integer is private. If it isn't give an error
  901. * message because Mrm won't be able to handle that problem.
  902. * When allocating the space for c_value the size of the string is one since an
  903. * integer can only be one character.
  904. */
  905. if ( (argvalue_value_entry->obj_header.b_flags & sym_m_private) != 0)
  906. {
  907. char tmp;
  908. valid_value = TRUE;
  909. tmp = argument_entry->az_arg_value->value.l_integer;
  910. argument_entry->az_arg_value->value.c_value = (char *) XtCalloc(1,2);
  911. /*
  912. * This is a very strange move. While we Calloc 2 bytes we only need to move
  913. * one of those bytes. We calloc 2 bytes for a null termination so HP type
  914. * machines will work. It looks wierd but it works.
  915. */
  916. _move (argument_entry->az_arg_value->value.c_value, &tmp, 1);
  917. argument_entry->az_arg_value->b_type = sym_k_keysym_value;
  918. argument_entry->az_arg_value->w_length = 1;
  919. }
  920. }
  921. if ((( expected_type == sym_k_horizontal_integer_value ) ||
  922. ( expected_type == sym_k_vertical_integer_value ))
  923. &&
  924. (( actual_type == sym_k_integer_value) ||
  925. ( actual_type == sym_k_float_value)))
  926. {
  927. /* If the expected type was either a horizontal or
  928. vertical integer and we got an integer, then simply make
  929. the actual type become the expected type. */
  930. valid_value = TRUE;
  931. argument_entry->az_arg_value->b_type = expected_type;
  932. /* If the actual_type is a float then coerce it into
  933. being an integer */
  934. if (actual_type == sym_k_float_value)
  935. argument_entry->az_arg_value->value.l_integer =
  936. (long) argument_entry->az_arg_value->value.d_real;
  937. /* XmPIXELS currently has a value of 0 so the following
  938. isn't really necessary but I suppose it is more robust. */
  939. if (argument_entry->az_arg_value->b_arg_type == 0)
  940. argument_entry->az_arg_value->b_arg_type = XmPIXELS;
  941. }
  942. if ((( expected_type == sym_k_horizontal_float_value ) ||
  943. ( expected_type == sym_k_vertical_float_value ))
  944. &&
  945. (( actual_type == sym_k_horizontal_integer_value ) ||
  946. ( actual_type == sym_k_vertical_integer_value )))
  947. {
  948. /* If the expected type was either a horizontal or
  949. vertical float and we got a horizontal or
  950. vertical integer, then make the actual type become
  951. a horizontal or vertical integer, respectively. */
  952. valid_value = TRUE;
  953. if (expected_type == sym_k_horizontal_float_value)
  954. argument_entry->az_arg_value->b_type =
  955. sym_k_horizontal_integer_value;
  956. else if (expected_type == sym_k_vertical_float_value)
  957. argument_entry->az_arg_value->b_type = sym_k_vertical_integer_value;
  958. /* Coerce the value into being a float */
  959. argument_entry->az_arg_value->value.d_real =
  960. (double) argument_entry->az_arg_value->value.l_integer;
  961. /* XmPIXELS currently has a value of 0 so the following
  962. isn't really necessary but I suppose it is more robust. */
  963. if (argument_entry->az_arg_value->b_arg_type == 0)
  964. argument_entry->az_arg_value->b_arg_type = XmPIXELS;
  965. }
  966. if ((( expected_type == sym_k_horizontal_integer_value ) ||
  967. ( expected_type == sym_k_vertical_integer_value ))
  968. &&
  969. (( actual_type == sym_k_horizontal_float_value ) ||
  970. ( actual_type == sym_k_vertical_float_value )))
  971. {
  972. /* If the expected type was either a horizontal or
  973. vertical integer and we got a horizontal or vertical
  974. float, then make the actual type become a horizontal
  975. or vertical float, respectively. */
  976. valid_value = TRUE;
  977. if (expected_type == sym_k_horizontal_integer_value)
  978. argument_entry->az_arg_value->b_type = sym_k_horizontal_float_value;
  979. else if (expected_type == sym_k_vertical_integer_value)
  980. argument_entry->az_arg_value->b_type = sym_k_vertical_float_value;
  981. /* Coerce the value into being an integer */
  982. argument_entry->az_arg_value->value.l_integer =
  983. (long) argument_entry->az_arg_value->value.d_real;
  984. /* XmPIXELS currently has a value of 0 so the following
  985. isn't really necessary but I suppose it is more robust. */
  986. if (argument_entry->az_arg_value->b_arg_type == 0)
  987. argument_entry->az_arg_value->b_arg_type = XmPIXELS;
  988. }
  989. if ((( expected_type == sym_k_horizontal_float_value ) ||
  990. ( expected_type == sym_k_vertical_float_value ))
  991. &&
  992. (( actual_type == sym_k_integer_value) ||
  993. ( actual_type == sym_k_float_value)))
  994. {
  995. /* If the expected type was either a horizontal or
  996. vertical float and we got a float, then simply make
  997. the actual type become the expected type. */
  998. valid_value = TRUE;
  999. argument_entry->az_arg_value->b_type = expected_type;
  1000. /* If actual_type is an integer, then coerce into being
  1001. a float */
  1002. if (actual_type == sym_k_integer_value)
  1003. argument_entry->az_arg_value->value.d_real =
  1004. (double) argument_entry->az_arg_value->value.l_integer;
  1005. /* XmPIXELS currently has a value of 0 so the following
  1006. isn't really necessary but I suppose it is more robust. */
  1007. if (argument_entry->az_arg_value->b_arg_type == 0)
  1008. argument_entry->az_arg_value->b_arg_type = XmPIXELS;
  1009. }
  1010. /* It is also possible for us to encounter a horizontal float or
  1011. int when we are expecting a vertical float or int. When using
  1012. 'value' defined constants, we coerce the type of the constant
  1013. the first time it is used. We have to be able to accept the
  1014. coerced value in a different context later. */
  1015. if ((( expected_type == sym_k_horizontal_float_value ) &&
  1016. ( actual_type == sym_k_vertical_float_value ))
  1017. ||
  1018. (( expected_type == sym_k_horizontal_integer_value ) &&
  1019. ( actual_type == sym_k_vertical_integer_value )))
  1020. {
  1021. /* Leave the actual type and value alone, but flag it as
  1022. an acceptable value. This will mean that the first orientation
  1023. the value is coerced to will be the orientation for all
  1024. occurences of the value. */
  1025. valid_value = TRUE;
  1026. }
  1027. if (!valid_value)
  1028. diag_issue_diagnostic
  1029. (d_obj_type,
  1030. _sar_source_pos2(argname_value_entry),
  1031. diag_value_text(actual_type),
  1032. diag_tag_text(actual_tag),
  1033. diag_value_text(expected_type),
  1034. diag_tag_text(sym_k_value_entry) );
  1035. }
  1036. /*
  1037. **++
  1038. ** FUNCTIONAL DESCRIPTION:
  1039. **
  1040. ** This routine performs enumeration set validation for a single
  1041. ** argument entry. If it's value is an enumeration set reference,
  1042. ** then we verify that the value comes from the argument's supported
  1043. ** enumeration set.
  1044. **
  1045. ** FORMAL PARAMETERS:
  1046. **
  1047. ** argument_entry the current argument entry
  1048. ** arg_code the sym_k_..._arg code for the argument
  1049. ** arg_value_entry the value node for the argument value
  1050. **
  1051. ** IMPLICIT INPUTS:
  1052. **
  1053. ** IMPLICIT OUTPUTS:
  1054. **
  1055. ** FUNCTION VALUE:
  1056. **
  1057. ** void
  1058. **
  1059. ** SIDE EFFECTS:
  1060. **
  1061. ** error reporting
  1062. **
  1063. **--
  1064. **/
  1065. void sem_validate_argument_enumset
  1066. (argument_entry, arg_code, arg_value_entry)
  1067. sym_argument_entry_type *argument_entry;
  1068. int arg_code;
  1069. sym_value_entry_type *arg_value_entry;
  1070. {
  1071. /*
  1072. * Local variables
  1073. */
  1074. unsigned short int enumval_code;
  1075. unsigned short int enumset_code;
  1076. int ndx;
  1077. /*
  1078. * No action if value is not an integer enumeration value. Else:
  1079. * - argument must support enumeration set
  1080. * - value must be from set
  1081. */
  1082. if ( arg_value_entry == NULL ) return;
  1083. if ((arg_value_entry->b_type != sym_k_integer_value) &&
  1084. (arg_value_entry->b_type != sym_k_bool_value)) return;
  1085. enumval_code = arg_value_entry->b_enumeration_value_code;
  1086. if ( enumval_code == 0 ) return;
  1087. enumset_code = argument_enumset_table[arg_code];
  1088. if ( enumset_code == 0 )
  1089. {
  1090. if (arg_value_entry->b_type != sym_k_bool_value)
  1091. diag_issue_diagnostic(d_no_enumset,
  1092. _sar_source_pos2(argument_entry),
  1093. uil_argument_names[arg_code]);
  1094. return;
  1095. }
  1096. for ( ndx=0 ; ndx<enum_set_table[enumset_code].values_cnt ; ndx++ )
  1097. if ( enum_set_table[enumset_code].values[ndx] == enumval_code ) return;
  1098. diag_issue_diagnostic (d_invalid_enumval,
  1099. _sar_source_pos2(argument_entry),
  1100. uil_argument_names[arg_code],
  1101. uil_enumval_names[enumval_code]);
  1102. return;
  1103. }
  1104. /*
  1105. **++
  1106. ** FUNCTIONAL DESCRIPTION:
  1107. **
  1108. ** This routine validates a constraint entry. It checks to make
  1109. ** sure that the constraint reference is valid in each of the
  1110. ** parents of the widget using the constraint
  1111. **
  1112. ** FORMAL PARAMETERS:
  1113. **
  1114. ** widget_node the widget using the constraint
  1115. ** argument_entry the constraint argument
  1116. **
  1117. ** IMPLICIT INPUTS:
  1118. **
  1119. ** >
  1120. **
  1121. ** IMPLICIT OUTPUTS:
  1122. **
  1123. ** FUNCTION VALUE:
  1124. **
  1125. ** void
  1126. **
  1127. ** SIDE EFFECTS:
  1128. **
  1129. ** error reporting
  1130. **
  1131. **--
  1132. **/
  1133. void sem_validate_constraint_entry (widget_node, argument_entry, widget_type)
  1134. sym_widget_entry_type *widget_node;
  1135. sym_argument_entry_type *argument_entry;
  1136. unsigned int widget_type;
  1137. {
  1138. /*
  1139. * Local variables
  1140. */
  1141. sym_parent_list_type *parent_entry;
  1142. sym_widget_entry_type *parent_object;
  1143. unsigned int parent_type;
  1144. unsigned int parent_tag;
  1145. key_keytable_entry_type *keytable_entry;
  1146. sym_value_entry_type *arg_name_entry;
  1147. boolean supported_flag;
  1148. /*
  1149. * Validate the constraint with each of the referencing widget's parents
  1150. */
  1151. for (parent_entry=widget_node->parent_list;
  1152. parent_entry!=NULL;
  1153. parent_entry=parent_entry->next)
  1154. {
  1155. /*
  1156. * Acquire the parent object and its type
  1157. */
  1158. parent_object = parent_entry->parent;
  1159. parent_type = parent_object->header.b_type;
  1160. if ( parent_object->obj_header.b_flags & sym_m_obj_is_gadget )
  1161. {
  1162. parent_tag = sym_k_gadget_entry;
  1163. }
  1164. else
  1165. {
  1166. parent_tag = sym_k_widget_entry;
  1167. }
  1168. /*
  1169. * Acquire the appropriate pointers, and validate the reference
  1170. */
  1171. arg_name_entry = (sym_value_entry_type *)argument_entry->az_arg_name;
  1172. keytable_entry = (key_keytable_entry_type *)arg_name_entry->value.az_data;
  1173. supported_flag = sem_argument_allowed(keytable_entry->b_subclass,
  1174. parent_type);
  1175. if (!supported_flag)
  1176. {
  1177. /* Check for both argument and constraint, e.g. decimalPoints. */
  1178. supported_flag = sem_argument_allowed(keytable_entry->b_subclass,
  1179. widget_type);
  1180. if (!supported_flag)
  1181. diag_issue_diagnostic(d_unsupp_const,
  1182. _sar_source_pos2(argument_entry),
  1183. keytable_entry->at_name,
  1184. diag_object_text(parent_type),
  1185. diag_tag_text(parent_tag));
  1186. }
  1187. }
  1188. /*
  1189. * Checks on nodes pointed to by this node
  1190. *
  1191. * There is no need to validate the value if it is a widget since widgets are
  1192. * validated elsewhere and you can't define widgets in an argument list anyway.
  1193. */
  1194. if ((argument_entry->az_arg_value->header.b_tag != sym_k_widget_entry) &&
  1195. (argument_entry->az_arg_value->header.b_tag != sym_k_gadget_entry))
  1196. sem_validate_node (( sym_entry_type *)argument_entry->az_arg_value);
  1197. }
  1198. /*
  1199. **++
  1200. ** FUNCTIONAL DESCRIPTION:
  1201. **
  1202. ** This routine validates all the callbacks in an callback list.
  1203. ** It recurse down nested lists.
  1204. **
  1205. ** FORMAL PARAMETERS:
  1206. **
  1207. ** widget_node the current widget
  1208. ** widget_type the current widget's type
  1209. ** list_entry list to be validated
  1210. ** seen flag table to detect duplicate callbacks
  1211. **
  1212. ** IMPLICIT INPUTS:
  1213. **
  1214. ** IMPLICIT OUTPUTS:
  1215. **
  1216. ** FUNCTION VALUE:
  1217. **
  1218. ** SIDE EFFECTS:
  1219. **
  1220. **--
  1221. **/
  1222. void sem_validate_callback_list (widget_node, widget_type, list_entry, seen)
  1223. sym_widget_entry_type *widget_node;
  1224. unsigned int widget_type;
  1225. sym_list_entry_type *list_entry;
  1226. sym_callback_entry_type **seen;
  1227. {
  1228. /*
  1229. * Local variables
  1230. */
  1231. sym_obj_entry_type *list_member;
  1232. sym_nested_list_entry_type *nested_list_entry;
  1233. sym_callback_entry_type *callback_entry;
  1234. /*
  1235. * loop down the list
  1236. */
  1237. if ( list_entry == NULL ) return;
  1238. for (list_member=(sym_obj_entry_type *)list_entry->obj_header.az_next;
  1239. list_member!=NULL;
  1240. list_member=(sym_obj_entry_type *)list_member->obj_header.az_next)
  1241. switch ( list_member->header.b_tag )
  1242. {
  1243. case sym_k_nested_list_entry:
  1244. nested_list_entry = (sym_nested_list_entry_type *) list_member;
  1245. sem_validate_callback_list (widget_node, widget_type,
  1246. nested_list_entry->az_list, seen);
  1247. break;
  1248. case sym_k_callback_entry:
  1249. callback_entry = (sym_callback_entry_type *) list_member;
  1250. sem_validate_callback_entry (widget_node, widget_type,
  1251. list_entry, callback_entry, seen);
  1252. break;
  1253. default:
  1254. diag_issue_diagnostic
  1255. ( d_list_item,
  1256. _sar_source_pos2 ( list_entry ),
  1257. diag_tag_text (sym_k_callback_entry),
  1258. diag_tag_text (list_entry->header.b_type),
  1259. diag_tag_text (list_entry->header.b_tag) );
  1260. }
  1261. }
  1262. /*
  1263. **++
  1264. ** FUNCTIONAL DESCRIPTION:
  1265. **
  1266. ** This routine performs validation for a single callback entry
  1267. ** for the current widget node.
  1268. **
  1269. ** FORMAL PARAMETERS:
  1270. **
  1271. ** widget_node the current widget
  1272. ** widget_type the current widget's type
  1273. ** list_entry list entry for current callback entry
  1274. ** callback_entry the current callback entry
  1275. ** seen flag table to detect duplicate callbacks
  1276. **
  1277. ** IMPLICIT INPUTS:
  1278. **
  1279. ** IMPLICIT OUTPUTS:
  1280. **
  1281. ** FUNCTION VALUE:
  1282. **
  1283. ** void
  1284. **
  1285. ** SIDE EFFECTS:
  1286. **
  1287. ** error reporting
  1288. **
  1289. **--
  1290. **/
  1291. void sem_validate_callback_entry
  1292. (widget_node, widget_type, list_entry, callback_entry, seen)
  1293. sym_widget_entry_type *widget_node;
  1294. unsigned int widget_type;
  1295. sym_list_entry_type *list_entry;
  1296. sym_callback_entry_type *callback_entry;
  1297. sym_callback_entry_type **seen;
  1298. {
  1299. /*
  1300. * Local variables
  1301. */
  1302. sym_value_entry_type *reason_value_entry;
  1303. key_keytable_entry_type *keytable_entry;
  1304. sym_callback_entry_type **seen_entry;
  1305. boolean supported_flag;
  1306. static sym_value_entry_type *widget_az_arg_value = NULL;
  1307. /*
  1308. * ignore error entries, consistency check
  1309. */
  1310. if ( callback_entry->header.b_tag == sym_k_error_entry ) return;
  1311. _assert (callback_entry->header.b_tag==sym_k_callback_entry,
  1312. "unexpected non callback entry");
  1313. reason_value_entry = (sym_value_entry_type *)
  1314. callback_entry->az_call_reason_name;
  1315. /*
  1316. * Force expression evaluation
  1317. */
  1318. sem_evaluate_value_expr (reason_value_entry);
  1319. if (reason_value_entry == NULL)
  1320. return;
  1321. _assert (reason_value_entry->header.b_tag == sym_k_value_entry,
  1322. "reason value entry missing");
  1323. if (reason_value_entry->b_type != sym_k_reason_value) {
  1324. diag_issue_diagnostic
  1325. ( d_list_item,
  1326. _sar_source_pos2 ( reason_value_entry ),
  1327. diag_value_text (reason_value_entry->b_type),
  1328. diag_tag_text (list_entry->header.b_type),
  1329. diag_tag_text (list_entry->header.b_tag) );
  1330. return;
  1331. }
  1332. /*
  1333. * Check for unsupported callbacks.
  1334. * This check is required for known toolkit callbacks in
  1335. * toolkit widgets.
  1336. */
  1337. if ( (reason_value_entry->obj_header.b_flags&sym_m_builtin) &&
  1338. (widget_type!=uil_sym_user_defined_object) )
  1339. {
  1340. /*
  1341. * Pick up the token keytable entry for the callback.
  1342. * Validate that the reason is supported
  1343. */
  1344. keytable_entry = (key_keytable_entry_type *)
  1345. reason_value_entry->value.az_data;
  1346. _assert (keytable_entry->b_class==tkn_k_class_reason,
  1347. "unexpected non-reason keytable entry");
  1348. supported_flag = sem_reason_allowed
  1349. (keytable_entry->b_subclass, widget_type);
  1350. if ( ! supported_flag )
  1351. diag_issue_diagnostic
  1352. (d_unsupported,
  1353. _sar_source_pos2(callback_entry),
  1354. keytable_entry->at_name,
  1355. diag_tag_text(callback_entry->header.b_tag),
  1356. diag_object_text(widget_type));
  1357. /*
  1358. * Check for duplicate callbacks. A warning is issued, but the
  1359. * callback is not removed from the list, since it may occur in
  1360. * an callback list - and the callback list may be referenced in
  1361. * another context where this callback is not duplicated.
  1362. */
  1363. seen_entry = (sym_callback_entry_type **)
  1364. &seen[keytable_entry->b_subclass];
  1365. if ( *seen_entry != NULL )
  1366. {
  1367. diag_issue_diagnostic
  1368. (d_supersede,
  1369. _sar_source_pos2(callback_entry),
  1370. keytable_entry->at_name,
  1371. diag_tag_text(callback_entry->header.b_tag),
  1372. diag_tag_text(list_entry->header.b_type),
  1373. diag_tag_text(list_entry->header.b_tag));
  1374. }
  1375. else
  1376. {
  1377. *seen_entry = callback_entry;
  1378. }
  1379. }
  1380. /*
  1381. * Checks on nodes pointed to by this node
  1382. */
  1383. /* Begin fixing DTS 10391 and OSF CR 8715*/
  1384. if(callback_entry->az_call_proc_ref &&
  1385. callback_entry->az_call_proc_ref->az_arg_value &&
  1386. (callback_entry->az_call_proc_ref->az_arg_value->header.b_tag
  1387. == sym_k_widget_entry ||
  1388. callback_entry->az_call_proc_ref->az_arg_value->header.b_tag
  1389. == sym_k_gadget_entry) &&
  1390. widget_az_arg_value == callback_entry->az_call_proc_ref->az_arg_value){
  1391. diag_issue_diagnostic
  1392. (d_circular_def,
  1393. _sar_source_pos2(callback_entry),
  1394. "callback client_data");
  1395. }else{
  1396. if(callback_entry->az_call_proc_ref &&
  1397. callback_entry->az_call_proc_ref->az_arg_value &&
  1398. (callback_entry->az_call_proc_ref->az_arg_value->header.b_tag
  1399. == sym_k_widget_entry ||
  1400. callback_entry->az_call_proc_ref->az_arg_value->header.b_tag
  1401. == sym_k_gadget_entry) && !widget_az_arg_value)
  1402. widget_az_arg_value = callback_entry->az_call_proc_ref->az_arg_value;
  1403. sem_validate_procref_entry (callback_entry->az_call_proc_ref);
  1404. sem_validate_procref_list (callback_entry->az_call_proc_ref_list);
  1405. }
  1406. widget_az_arg_value = NULL;
  1407. /* End fixing DTS 10391 and OSF CR 8715*/
  1408. }
  1409. /*
  1410. **++
  1411. ** FUNCTIONAL DESCRIPTION:
  1412. **
  1413. ** This routine validates all the controls in an control list.
  1414. ** It recurse down nested lists.
  1415. **
  1416. ** FORMAL PARAMETERS:
  1417. **
  1418. ** widget_node the current widget
  1419. ** widget_type the current widget's type
  1420. ** list_entry list to be validated
  1421. ** count to return gadget count
  1422. **
  1423. ** IMPLICIT INPUTS:
  1424. **
  1425. ** IMPLICIT OUTPUTS:
  1426. **
  1427. ** FUNCTION VALUE:
  1428. **
  1429. ** SIDE EFFECTS:
  1430. **
  1431. **--
  1432. **/
  1433. void sem_validate_control_list (widget_node, widget_type, list_entry, count)
  1434. sym_widget_entry_type *widget_node;
  1435. unsigned int widget_type;
  1436. sym_list_entry_type *list_entry;
  1437. int *count;
  1438. {
  1439. /*
  1440. * Local variables
  1441. */
  1442. sym_obj_entry_type *list_member;
  1443. sym_nested_list_entry_type *nested_list_entry;
  1444. sym_control_entry_type *control_entry;
  1445. /*
  1446. * loop down the list
  1447. */
  1448. if ( list_entry == NULL ) return;
  1449. for (list_member=(sym_obj_entry_type *)list_entry->obj_header.az_next;
  1450. list_member!=NULL;
  1451. list_member=(sym_obj_entry_type *)list_member->obj_header.az_next)
  1452. switch ( list_member->header.b_tag )
  1453. {
  1454. case sym_k_nested_list_entry:
  1455. nested_list_entry = (sym_nested_list_entry_type *) list_member;
  1456. sem_validate_control_list
  1457. (widget_node, widget_type, nested_list_entry->az_list, count);
  1458. break;
  1459. case sym_k_control_entry:
  1460. control_entry = (sym_control_entry_type *) list_member;
  1461. sem_validate_control_entry
  1462. (widget_node, widget_type, list_entry, control_entry, count);
  1463. break;
  1464. }
  1465. }
  1466. /*
  1467. **++
  1468. ** FUNCTIONAL DESCRIPTION:
  1469. **
  1470. ** This routine performs validation for a single control entry
  1471. ** for the current widget node.
  1472. **
  1473. ** FORMAL PARAMETERS:
  1474. **
  1475. ** widget_node the current widget
  1476. ** widget_type the current widget's type
  1477. ** list_entry list entry for current control entry
  1478. ** control_entry the current control entry
  1479. ** gadget_count to accumulate count of controlled gadgets
  1480. **
  1481. ** IMPLICIT INPUTS:
  1482. **
  1483. ** IMPLICIT OUTPUTS:
  1484. **
  1485. ** FUNCTION VALUE:
  1486. **
  1487. ** void
  1488. **
  1489. ** SIDE EFFECTS:
  1490. **
  1491. ** error reporting
  1492. **
  1493. **--
  1494. **/
  1495. void sem_validate_control_entry
  1496. (widget_node, widget_type, list_entry, control_entry, gadget_count)
  1497. sym_widget_entry_type *widget_node;
  1498. unsigned int widget_type;
  1499. sym_list_entry_type *list_entry;
  1500. sym_control_entry_type *control_entry;
  1501. int *gadget_count;
  1502. {
  1503. /*
  1504. * Local variables
  1505. */
  1506. sym_widget_entry_type *control_obj_entry;
  1507. boolean supported_flag;
  1508. /*
  1509. * ignore error entries, consistency check
  1510. */
  1511. if ( control_entry->header.b_tag == sym_k_error_entry ) return;
  1512. _assert (control_entry->header.b_tag==sym_k_control_entry,
  1513. "unexpected non control entry");
  1514. /*
  1515. * Similar checks for the object being controlled
  1516. */
  1517. control_obj_entry = (sym_widget_entry_type *) control_entry->az_con_obj;
  1518. if ( control_obj_entry->header.b_tag == sym_k_error_entry )
  1519. {
  1520. control_entry->header.b_tag = sym_k_error_entry;
  1521. return;
  1522. }
  1523. _assert (control_obj_entry->header.b_tag==sym_k_widget_entry ||
  1524. control_obj_entry->header.b_tag==sym_k_gadget_entry ||
  1525. control_obj_entry->header.b_tag==sym_k_child_entry,
  1526. "unexpected non-control object entry");
  1527. if ( control_obj_entry->header.b_tag == sym_k_gadget_entry )
  1528. *gadget_count += 1;
  1529. /*
  1530. * Check for unsupported controls or automatic children.
  1531. */
  1532. if (control_obj_entry->header.b_tag == sym_k_child_entry)
  1533. {
  1534. supported_flag =
  1535. sem_child_allowed(control_obj_entry->header.b_type, widget_type);
  1536. if ( ! supported_flag )
  1537. diag_issue_diagnostic
  1538. (d_unsupported,
  1539. _sar_source_pos2(control_entry),
  1540. uil_child_names[control_obj_entry->header.b_type],
  1541. "automatic child",
  1542. diag_object_text(widget_type));
  1543. }
  1544. else
  1545. {
  1546. supported_flag =
  1547. sem_control_allowed(control_obj_entry->header.b_type, widget_type);
  1548. if ( ! supported_flag )
  1549. diag_issue_diagnostic
  1550. (d_unsupported,
  1551. _sar_source_pos2(control_entry),
  1552. diag_object_text(control_obj_entry->header.b_type),
  1553. diag_tag_text(control_entry->header.b_tag),
  1554. diag_object_text(widget_type));
  1555. }
  1556. }
  1557. /*
  1558. **++
  1559. ** FUNCTIONAL DESCRIPTION:
  1560. **
  1561. ** This routine recursively checks for cycles in a widget hierarchy.
  1562. ** A cycle is defined as the appearance of a widget's name in its
  1563. ** subtree hierarchy. A cycle is detected by setting a unique id
  1564. ** for this cycle check in each name entry encountered. If this id
  1565. ** is ever encountered again, there is a cycle.
  1566. **
  1567. ** This is the root routine of the recursion, which is responsible
  1568. ** for setting flags in the name entry.
  1569. **
  1570. ** FORMAL PARAMETERS:
  1571. **
  1572. ** list_entry list to be validated
  1573. ** cycle_name if non-NULL, a widget name for cycle check
  1574. **
  1575. ** IMPLICIT INPUTS:
  1576. **
  1577. ** IMPLICIT OUTPUTS:
  1578. **
  1579. ** FUNCTION VALUE:
  1580. **
  1581. ** SIDE EFFECTS:
  1582. **
  1583. **--
  1584. **/
  1585. void sem_validate_widget_cycle (list_entry, cycle_name)
  1586. sym_list_entry_type *list_entry;
  1587. sym_name_entry_type *cycle_name;
  1588. {
  1589. /*
  1590. * Local variables
  1591. */
  1592. boolean cycle_res;
  1593. /*
  1594. * Acquire a new cycle id value.Call the auxiliary recursion routine,
  1595. * and set results in the name entry.
  1596. */
  1597. if ( cycle_name == NULL ) return;
  1598. cycle_id += 1;
  1599. cycle_name->az_cycle_id = cycle_id;
  1600. cycle_res = sem_validate_widget_cycle_aux (list_entry, cycle_name);
  1601. cycle_name->b_flags |= sym_m_cycle_checked;
  1602. if ( cycle_res )
  1603. cycle_name->b_flags |= sym_m_has_cycle;
  1604. }
  1605. /*
  1606. **++
  1607. ** FUNCTIONAL DESCRIPTION:
  1608. **
  1609. ** This routine recursively checks for cycles in a widget hierarchy.
  1610. ** A cycle is defined as the appearance of a widget's name in its
  1611. ** subtree hierarchy. This is the fully recursive auxiliary for
  1612. ** sem_validate_widget_cycle
  1613. **
  1614. ** Checking is based on the fact that for any named widget, its
  1615. ** subtree definition is fixed and can be checked exactly once. Once
  1616. ** checked, it is marked as checked, and also flagged if it contains
  1617. ** a cycle. Since any tree containing a subtree which has a cycle also
  1618. ** has a cycle, checking stops immediately if such a subtree is detected,
  1619. ** and subtrees must always be (recursively) checked in advance of
  1620. ** the current check.
  1621. **
  1622. ** FORMAL PARAMETERS:
  1623. **
  1624. ** list_entry list to be validated
  1625. ** cycle_name if non-NULL, a widget name for cycle check
  1626. **
  1627. ** IMPLICIT INPUTS:
  1628. **
  1629. ** IMPLICIT OUTPUTS:
  1630. **
  1631. ** FUNCTION VALUE:
  1632. ** TRUE cycle detected
  1633. ** FALSE no cycle detected
  1634. **
  1635. ** SIDE EFFECTS:
  1636. **
  1637. **--
  1638. **/
  1639. boolean sem_validate_widget_cycle_aux (list_entry, cycle_name)
  1640. sym_list_entry_type *list_entry;
  1641. sym_name_entry_type *cycle_name;
  1642. {
  1643. /*
  1644. * Local variables
  1645. */
  1646. sym_obj_entry_type *list_member;
  1647. sym_nested_list_entry_type *nested_list_entry;
  1648. sym_control_entry_type *control_entry;
  1649. sym_widget_entry_type *control_obj_entry;
  1650. sym_name_entry_type *control_obj_name;
  1651. /*
  1652. * loop down the list. Check for cycles in each leaf (widget) node. Note
  1653. * we must step through the az_reference for named widgets. If a cycle is
  1654. * ever detected, we exit (or we'll recurse forever). Note that an error
  1655. * node returns TRUE, as if it had a cycle (which inhibits further checking).
  1656. *
  1657. * If we encounter a previously visited node, we may have either a cycle
  1658. * or a legitimate multiple reference. Verify that it is a cycle, and
  1659. * issue an error message if so. If it is not verified, it need not be
  1660. * checked again.
  1661. */
  1662. if ( list_entry == NULL ) return FALSE;
  1663. if ( cycle_name == NULL ) return FALSE;
  1664. if ( cycle_name->b_flags & sym_m_cycle_checked )
  1665. return (cycle_name->b_flags&sym_m_has_cycle) == 1;
  1666. for (list_member=(sym_obj_entry_type *)list_entry->obj_header.az_next;
  1667. list_member!=NULL;
  1668. list_member=(sym_obj_entry_type *)list_member->obj_header.az_next)
  1669. switch ( list_member->header.b_tag )
  1670. {
  1671. case sym_k_nested_list_entry:
  1672. nested_list_entry = (sym_nested_list_entry_type *) list_member;
  1673. if ( sem_validate_widget_cycle_aux
  1674. (nested_list_entry->az_list, cycle_name) )
  1675. return TRUE;
  1676. break;
  1677. case sym_k_control_entry:
  1678. control_entry = (sym_control_entry_type *) list_member;
  1679. control_obj_entry =
  1680. (sym_widget_entry_type *) control_entry->az_con_obj;
  1681. if ( control_obj_entry->header.b_tag == sym_k_error_entry )
  1682. return TRUE;
  1683. _assert (control_obj_entry->header.b_tag==sym_k_widget_entry ||
  1684. control_obj_entry->header.b_tag==sym_k_gadget_entry ||
  1685. control_obj_entry->header.b_tag==sym_k_child_entry,
  1686. "unexpected non-control object entry");
  1687. if ( control_obj_entry->obj_header.az_reference != NULL )
  1688. control_obj_entry = (sym_widget_entry_type *)
  1689. control_obj_entry->obj_header.az_reference;
  1690. if ( control_obj_entry->az_controls == NULL )
  1691. break;
  1692. control_obj_name = control_obj_entry->obj_header.az_name;
  1693. if ( control_obj_name != NULL )
  1694. {
  1695. if ( control_obj_name->az_cycle_id == cycle_id )
  1696. {
  1697. if ( sem_validate_verify_cycle
  1698. (control_obj_entry,
  1699. control_obj_entry->az_controls) )
  1700. {
  1701. diag_issue_diagnostic
  1702. (d_widget_cycle,
  1703. _sar_source_pos2(control_entry),
  1704. control_obj_name->c_text);
  1705. control_obj_name->b_flags |= sym_m_cycle_checked;
  1706. control_obj_name->b_flags |= sym_m_has_cycle;
  1707. return TRUE;
  1708. }
  1709. else
  1710. {
  1711. control_obj_name->b_flags |= sym_m_cycle_checked;
  1712. break;
  1713. }
  1714. }
  1715. control_obj_name->az_cycle_id = cycle_id;
  1716. }
  1717. if ( sem_validate_widget_cycle_aux
  1718. (control_obj_entry->az_controls, cycle_name) )
  1719. return TRUE;
  1720. break;
  1721. }
  1722. return FALSE;
  1723. }
  1724. /*
  1725. **++
  1726. ** FUNCTIONAL DESCRIPTION:
  1727. **
  1728. ** This routine verifies that a cycle found by widget_cycle_aux is
  1729. ** really a cycle. widget_cycle_aux may have detected a legitimate
  1730. ** multiple appearance of a widget in a hierarchy which is not a cycle.
  1731. ** This routine uses a pointer-marching technique to see if the given
  1732. ** node is in a real cycle. If the cycle_obj is ever encountered in
  1733. ** the pointer march, then there is a cycle. Otherwise, the march
  1734. ** terminates.
  1735. **
  1736. **
  1737. ** FORMAL PARAMETERS:
  1738. **
  1739. ** cycle_obj object to be found in cycle
  1740. ** list_entry current controls list
  1741. **
  1742. ** IMPLICIT INPUTS:
  1743. **
  1744. ** IMPLICIT OUTPUTS:
  1745. **
  1746. ** FUNCTION VALUE:
  1747. ** TRUE cycle detected
  1748. ** FALSE no cycle detected
  1749. **
  1750. ** SIDE EFFECTS:
  1751. **
  1752. **--
  1753. **/
  1754. boolean sem_validate_verify_cycle (cycle_obj, list_entry)
  1755. sym_widget_entry_type *cycle_obj;
  1756. sym_list_entry_type *list_entry;
  1757. {
  1758. /*
  1759. * Local variables
  1760. */
  1761. sym_obj_entry_type *list_member;
  1762. sym_nested_list_entry_type *nested_list_entry;
  1763. sym_control_entry_type *control_entry;
  1764. sym_widget_entry_type *control_obj_entry;
  1765. /*
  1766. * Search all objects in the controls list, and recurse.
  1767. * objects controlled by the current object.
  1768. */
  1769. if ( list_entry == NULL )
  1770. return FALSE;
  1771. for (list_member=(sym_obj_entry_type *)list_entry->obj_header.az_next;
  1772. list_member!=NULL;
  1773. list_member=(sym_obj_entry_type *)list_member->obj_header.az_next)
  1774. switch ( list_member->header.b_tag )
  1775. {
  1776. case sym_k_nested_list_entry:
  1777. nested_list_entry = (sym_nested_list_entry_type *) list_member;
  1778. if ( sem_validate_verify_cycle
  1779. (cycle_obj, nested_list_entry->az_list) )
  1780. return TRUE;
  1781. break;
  1782. case sym_k_control_entry:
  1783. control_entry = (sym_control_entry_type *) list_member;
  1784. control_obj_entry =
  1785. (sym_widget_entry_type *) control_entry->az_con_obj;
  1786. if ( control_obj_entry->obj_header.az_reference != NULL )
  1787. control_obj_entry = (sym_widget_entry_type *)
  1788. control_obj_entry->obj_header.az_reference;
  1789. if ( control_obj_entry == cycle_obj )
  1790. return TRUE;
  1791. if ( control_obj_entry->az_controls == NULL )
  1792. break;
  1793. if ( sem_validate_verify_cycle
  1794. (cycle_obj, control_obj_entry->az_controls) )
  1795. return TRUE;
  1796. break;
  1797. }
  1798. return FALSE;
  1799. }
  1800. /*
  1801. **++
  1802. ** FUNCTIONAL DESCRIPTION:
  1803. **
  1804. ** This routine validates all the procrefs in an procref list.
  1805. ** It recurses down nested lists.
  1806. **
  1807. ** FORMAL PARAMETERS:
  1808. **
  1809. ** list_entry list to be validated
  1810. **
  1811. ** IMPLICIT INPUTS:
  1812. **
  1813. ** IMPLICIT OUTPUTS:
  1814. **
  1815. ** FUNCTION VALUE:
  1816. **
  1817. ** SIDE EFFECTS:
  1818. **
  1819. **--
  1820. **/
  1821. void sem_validate_procref_list (list_entry)
  1822. sym_list_entry_type *list_entry;
  1823. {
  1824. /*
  1825. * Local variables
  1826. */
  1827. sym_obj_entry_type *list_member;
  1828. sym_nested_list_entry_type *nested_list_entry;
  1829. sym_proc_ref_entry_type *procref_entry;
  1830. /*
  1831. * loop down the list
  1832. */
  1833. if ( list_entry == NULL ) return;
  1834. for (list_member=(sym_obj_entry_type *)list_entry->obj_header.az_next;
  1835. list_member!=NULL;
  1836. list_member=(sym_obj_entry_type *)list_member->obj_header.az_next)
  1837. switch ( list_member->header.b_tag )
  1838. {
  1839. case sym_k_nested_list_entry:
  1840. nested_list_entry = (sym_nested_list_entry_type *) list_member;
  1841. sem_validate_procref_list (nested_list_entry->az_list);
  1842. break;
  1843. case sym_k_proc_ref_entry:
  1844. procref_entry = (sym_proc_ref_entry_type *) list_member;
  1845. sem_validate_procref_entry (procref_entry);
  1846. break;
  1847. }
  1848. }
  1849. /*
  1850. **++
  1851. ** FUNCTIONAL DESCRIPTION:
  1852. **
  1853. ** This routine performs validation for a single procref entry.
  1854. **
  1855. ** FORMAL PARAMETERS:
  1856. **
  1857. ** procref_entry the current procref entry
  1858. **
  1859. ** IMPLICIT INPUTS:
  1860. **
  1861. ** IMPLICIT OUTPUTS:
  1862. **
  1863. ** FUNCTION VALUE:
  1864. **
  1865. ** void
  1866. **
  1867. ** SIDE EFFECTS:
  1868. **
  1869. ** error reporting
  1870. **
  1871. **--
  1872. **/
  1873. void sem_validate_procref_entry (procref_entry)
  1874. sym_proc_ref_entry_type *procref_entry;
  1875. {
  1876. /*
  1877. * Local variables
  1878. */
  1879. sym_value_entry_type *value_entry;
  1880. sym_proc_def_entry_type *proc_def_entry;
  1881. int actual_arg_count;
  1882. int expected_arg_type;
  1883. int actual_arg_type;
  1884. int arg_checking;
  1885. /*
  1886. * ignore error entries, consistency check
  1887. */
  1888. if ( procref_entry == NULL ) return;
  1889. if ( procref_entry->header.b_tag == sym_k_error_entry ) return;
  1890. _assert (procref_entry->header.b_tag==sym_k_proc_ref_entry,
  1891. "unexpected non procref entry");
  1892. /*
  1893. ** Validate procedure reference argument:
  1894. ** Correct number of args
  1895. ** Correct datatype of arg - coerce if necessary
  1896. */
  1897. proc_def_entry = procref_entry->az_proc_def;
  1898. /* Could be NULL due to previous compilation errors. */
  1899. if (proc_def_entry == NULL) return;
  1900. /*
  1901. ** if checking is required, check that the values
  1902. ** agree with the parameters
  1903. */
  1904. arg_checking = proc_def_entry->v_arg_checking;
  1905. value_entry = procref_entry->az_arg_value;
  1906. if (arg_checking)
  1907. {
  1908. boolean valid_arg;
  1909. if (value_entry == NULL)
  1910. {
  1911. actual_arg_count = 0;
  1912. actual_arg_type = sym_k_no_value;
  1913. }
  1914. else
  1915. {
  1916. sem_evaluate_value_expr(value_entry);
  1917. actual_arg_count = 1;
  1918. actual_arg_type = value_entry->b_type;
  1919. }
  1920. if (actual_arg_count != proc_def_entry->b_arg_count)
  1921. {
  1922. diag_issue_diagnostic
  1923. ( d_arg_count,
  1924. _sar_source_pos2 (procref_entry),
  1925. proc_def_entry->obj_header.az_name->c_text,
  1926. proc_def_entry->b_arg_count );
  1927. return;
  1928. }
  1929. expected_arg_type = proc_def_entry->b_arg_type;
  1930. valid_arg = (actual_arg_type == expected_arg_type);
  1931. if ( expected_arg_type == sym_k_any_value )
  1932. valid_arg = TRUE;
  1933. if ( actual_arg_type == sym_k_identifier_value )
  1934. valid_arg = TRUE;
  1935. if (( expected_arg_type == sym_k_pixmap_value ) &&
  1936. ( actual_arg_type == sym_k_icon_value ))
  1937. valid_arg = TRUE;
  1938. if (( expected_arg_type == sym_k_color_value) &&/* RAP rgb data type */
  1939. ( actual_arg_type == sym_k_rgb_value))
  1940. valid_arg = TRUE;
  1941. if ((expected_arg_type == sym_k_char_8_value) &&
  1942. (actual_arg_type == sym_k_localized_string_value))
  1943. valid_arg = TRUE;
  1944. if (( expected_arg_type == sym_k_compound_string_value ) &&
  1945. ( actual_arg_type == sym_k_char_8_value ))
  1946. {
  1947. valid_arg = TRUE;
  1948. if ( (value_entry->obj_header.b_flags & sym_m_private) != 0)
  1949. {
  1950. sym_value_entry_type *cstr_value;
  1951. cstr_value = (sym_value_entry_type *) sem_create_cstr();
  1952. cstr_value->b_expr_opr = sym_k_coerce_op;
  1953. cstr_value->az_exp_op1 = value_entry;
  1954. sem_evaluate_value_expr (cstr_value);
  1955. }
  1956. }
  1957. if (( expected_arg_type == sym_k_compound_string_value ) &&
  1958. ( actual_arg_type == sym_k_localized_string_value ))
  1959. {
  1960. valid_arg = TRUE;
  1961. if ( (value_entry->obj_header.b_flags & sym_m_private) != 0)
  1962. {
  1963. sym_value_entry_type *cstr_value;
  1964. cstr_value = (sym_value_entry_type *) sem_create_cstr();
  1965. cstr_value->b_expr_opr = sym_k_coerce_op;
  1966. cstr_value->az_exp_op1 = value_entry;
  1967. sem_evaluate_value_expr (cstr_value);
  1968. }
  1969. }
  1970. if (( expected_arg_type == sym_k_wchar_string_value ) &&
  1971. ( actual_arg_type == sym_k_localized_string_value ))
  1972. {
  1973. valid_arg = TRUE;
  1974. if ( (value_entry->obj_header.b_flags & sym_m_private) != 0)
  1975. {
  1976. sym_value_entry_type *wcstr_value;
  1977. wcstr_value = (sym_value_entry_type *) sem_create_wchar_str();
  1978. wcstr_value->b_expr_opr = sym_k_coerce_op;
  1979. wcstr_value->az_exp_op1 = value_entry;
  1980. sem_evaluate_value_expr (wcstr_value);
  1981. }
  1982. }
  1983. if (( expected_arg_type == sym_k_font_table_value ) &&
  1984. (( actual_arg_type == sym_k_font_value ) ||
  1985. ( actual_arg_type == sym_k_fontset_value )))
  1986. {
  1987. valid_arg = TRUE;
  1988. if ( (value_entry->obj_header.b_flags & sym_m_private) != 0)
  1989. {
  1990. sym_value_entry_type *font_table;
  1991. font_table =
  1992. sem_create_value_entry
  1993. ( (char*)&value_entry, sizeof(long),
  1994. sym_k_font_table_value );
  1995. font_table->b_expr_opr = sym_k_coerce_op;
  1996. font_table->az_exp_op1 = value_entry;
  1997. value_entry = sem_evaluate_value (font_table);
  1998. }
  1999. }
  2000. if ((expected_arg_type == sym_k_widget_ref_value) &&
  2001. (value_entry->header.b_tag == sym_k_widget_entry))
  2002. {
  2003. expected_arg_type = proc_def_entry->b_widget_type;
  2004. actual_arg_type = value_entry->header.b_type;
  2005. if ((expected_arg_type > uil_max_object) ||
  2006. (actual_arg_type == expected_arg_type))
  2007. {
  2008. valid_arg = TRUE;
  2009. }
  2010. else
  2011. {
  2012. diag_issue_diagnostic
  2013. (d_arg_type,
  2014. _sar_source_pos2(procref_entry),
  2015. diag_object_text(actual_arg_type),
  2016. proc_def_entry->obj_header.az_name->c_text,
  2017. diag_object_text(expected_arg_type));
  2018. return;
  2019. }
  2020. }
  2021. if (!valid_arg)
  2022. {
  2023. diag_issue_diagnostic
  2024. ( d_arg_type,
  2025. _sar_source_pos2 (procref_entry),
  2026. diag_value_text( actual_arg_type ),
  2027. proc_def_entry->obj_header.az_name->c_text,
  2028. diag_value_text( expected_arg_type ) );
  2029. return;
  2030. }
  2031. }
  2032. /*
  2033. * Perform validation of tags
  2034. */
  2035. sem_validate_node (( sym_entry_type *)procref_entry->az_arg_value);
  2036. }
  2037. /*
  2038. **++
  2039. ** FUNCTIONAL DESCRIPTION:
  2040. **
  2041. ** This predicate specifies if an argument is allowed in a class.
  2042. **
  2043. ** FORMAL PARAMETERS:
  2044. **
  2045. ** arg_code The sym_k_..._arg code for the argument
  2046. ** class_code The sym_k_..._object code for the class
  2047. **
  2048. ** IMPLICIT INPUTS:
  2049. **
  2050. ** allowed_argument_table
  2051. **
  2052. ** IMPLICIT OUTPUTS:
  2053. **
  2054. ** FUNCTION VALUE:
  2055. **
  2056. ** TRUE argument is allowed
  2057. ** FALSE argument is not allowed
  2058. **
  2059. ** SIDE EFFECTS:
  2060. **
  2061. **--
  2062. **/
  2063. boolean sem_argument_allowed (arg_code, class_code)
  2064. unsigned int arg_code;
  2065. unsigned int class_code;
  2066. {
  2067. unsigned char *entry_vec;
  2068. unsigned char vec_byte;
  2069. entry_vec = allowed_argument_table[arg_code];
  2070. vec_byte = entry_vec[_BIT_INDEX(class_code)];
  2071. return (boolean) vec_byte & _BIT_MASK(class_code);
  2072. }
  2073. /*
  2074. **++
  2075. ** FUNCTIONAL DESCRIPTION:
  2076. **
  2077. ** This predicate specifies if a reason is allowed in a class.
  2078. **
  2079. ** FORMAL PARAMETERS:
  2080. **
  2081. ** rsn_code The sym_k_..._reason code for the reason
  2082. ** class_code The sym_k_..._object code for the class
  2083. **
  2084. ** IMPLICIT INPUTS:
  2085. **
  2086. ** allowed_reason_table
  2087. **
  2088. ** IMPLICIT OUTPUTS:
  2089. **
  2090. ** FUNCTION VALUE:
  2091. **
  2092. ** TRUE reason is allowed
  2093. ** FALSE reason is not allowed
  2094. **
  2095. ** SIDE EFFECTS:
  2096. **
  2097. **--
  2098. **/
  2099. boolean sem_reason_allowed (rsn_code, class_code)
  2100. unsigned int rsn_code;
  2101. unsigned int class_code;
  2102. {
  2103. unsigned char *entry_vec;
  2104. unsigned char vec_byte;
  2105. entry_vec = allowed_reason_table[rsn_code];
  2106. vec_byte = entry_vec[_BIT_INDEX(class_code)];
  2107. return (boolean) vec_byte & _BIT_MASK(class_code);
  2108. }
  2109. /*
  2110. **++
  2111. ** FUNCTIONAL DESCRIPTION:
  2112. **
  2113. ** This predicate specifies if a control is allowed in a class.
  2114. **
  2115. ** FORMAL PARAMETERS:
  2116. **
  2117. ** ctl_code The sym_k_..._object code for the control, that is,
  2118. ** the class of object which is to be a child of
  2119. ** the class below.
  2120. ** class_code The sym_k_..._object code for the class
  2121. **
  2122. ** IMPLICIT INPUTS:
  2123. **
  2124. ** allowed_control_table
  2125. **
  2126. ** IMPLICIT OUTPUTS:
  2127. **
  2128. ** FUNCTION VALUE:
  2129. **
  2130. ** TRUE control is allowed
  2131. ** FALSE control is not allowed
  2132. **
  2133. ** SIDE EFFECTS:
  2134. **
  2135. **--
  2136. **/
  2137. boolean sem_control_allowed (ctl_code, class_code)
  2138. unsigned int ctl_code;
  2139. unsigned int class_code;
  2140. {
  2141. unsigned char *entry_vec;
  2142. unsigned char vec_byte;
  2143. entry_vec = allowed_control_table[ctl_code];
  2144. vec_byte = entry_vec[_BIT_INDEX(class_code)];
  2145. return (boolean) vec_byte & _BIT_MASK(class_code);
  2146. }
  2147. /*
  2148. **++
  2149. ** FUNCTIONAL DESCRIPTION:
  2150. **
  2151. ** This predicate specifies if an automatically create child is
  2152. ** allowed in a class.
  2153. **
  2154. ** FORMAL PARAMETERS:
  2155. **
  2156. ** ctl_code The sym_k_..._child code for the child, that is,
  2157. ** the class of child which is to be automatically
  2158. ** created in the class below.
  2159. ** class_code The sym_k_..._object code for the class
  2160. **
  2161. ** IMPLICIT INPUTS:
  2162. **
  2163. ** allowed_child_table
  2164. **
  2165. ** IMPLICIT OUTPUTS:
  2166. **
  2167. ** FUNCTION VALUE:
  2168. **
  2169. ** TRUE child is allowed
  2170. ** FALSE child is not allowed
  2171. **
  2172. ** SIDE EFFECTS:
  2173. **
  2174. **--
  2175. **/
  2176. boolean sem_child_allowed (ctl_code, class_code)
  2177. unsigned int ctl_code;
  2178. unsigned int class_code;
  2179. {
  2180. unsigned char *entry_vec;
  2181. unsigned char vec_byte;
  2182. entry_vec = allowed_child_table[ctl_code];
  2183. vec_byte = entry_vec[_BIT_INDEX(class_code)];
  2184. return (boolean) vec_byte & _BIT_MASK(class_code);
  2185. }
  2186. /*
  2187. **++
  2188. ** FUNCTIONAL DESCRIPTION:
  2189. **
  2190. ** This function does evaluation and validation of value nodes. It
  2191. ** guarantees that a value usable by the output routine or other consumers
  2192. ** of values is available in the value union of the node, with
  2193. ** any other corollary fields also set. The result of the operation may
  2194. ** be a new node, if coercion is required.
  2195. **
  2196. ** FORMAL PARAMETERS:
  2197. **
  2198. ** val_entry pointer to the value node to be evaluated
  2199. **
  2200. ** IMPLICIT INPUTS:
  2201. **
  2202. ** none
  2203. **
  2204. ** IMPLICIT OUTPUTS:
  2205. **
  2206. ** none
  2207. **
  2208. ** FUNCTION VALUE:
  2209. **
  2210. ** The value node which results from the evaluation/validation operation
  2211. **
  2212. ** SIDE EFFECTS:
  2213. **
  2214. ** The value union and other fields may be modified.
  2215. **
  2216. **--
  2217. **/
  2218. sym_value_entry_type *sem_evaluate_value (val_entry)
  2219. sym_value_entry_type *val_entry;
  2220. {
  2221. /*
  2222. * Force expression evaluation
  2223. */
  2224. sem_evaluate_value_expr (val_entry);
  2225. /* BEGIN HAL Fix CR 4774 */
  2226. /* Do not execute case statement if val_entry was previously
  2227. * a sym_k_valref_op node type. This can be determined by
  2228. * examining the state of the sym_m_exp_eval flag in the
  2229. * b_aux_flags field.
  2230. */
  2231. if ((val_entry->b_aux_flags & sym_m_exp_eval) == 0)
  2232. /*
  2233. * Perform evaluations which depend on the type of the value
  2234. */
  2235. switch ( val_entry->b_type )
  2236. /* END HAL Fix CR 4774 */
  2237. {
  2238. case sym_k_integer_value:
  2239. case sym_k_horizontal_integer_value:
  2240. case sym_k_vertical_integer_value:
  2241. break;
  2242. case sym_k_compound_string_value:
  2243. sem_evaluate_value_cs (val_entry);
  2244. break;
  2245. /* BEGIN OSF Fix CR 4859 */
  2246. /* END OSF Fix CR 4859 */
  2247. case sym_k_string_table_value:
  2248. {
  2249. sym_value_entry_type *value_segment;
  2250. for (value_segment=val_entry->az_first_table_value;
  2251. value_segment!=NULL;
  2252. value_segment=value_segment->az_next_table_value)
  2253. {
  2254. sem_evaluate_value_expr (value_segment);
  2255. if ((value_segment->b_type == sym_k_char_8_value) ||
  2256. (value_segment->b_type == sym_k_localized_string_value))
  2257. {
  2258. sym_value_entry_type *cstr;
  2259. sym_value_entry_type *save_next;
  2260. save_next = (sym_value_entry_type *)
  2261. (value_segment -> az_next_table_value);
  2262. cstr = (sym_value_entry_type *) sem_create_cstr();
  2263. sem_append_str_to_cstr( cstr,
  2264. value_segment, FALSE);
  2265. _sym_copy_entry (value_segment,
  2266. cstr,
  2267. sym_k_value_entry_size );
  2268. value_segment -> az_next_table_value =
  2269. save_next;
  2270. cstr->value.xms_value = NULL;
  2271. cstr->az_first_table_value = NULL;
  2272. sem_free_node (( sym_entry_type *)cstr);
  2273. }
  2274. if (value_segment->b_type != sym_k_compound_string_value)
  2275. diag_issue_diagnostic
  2276. ( d_wrong_type,
  2277. _sar_source_pos2( value_segment ),
  2278. diag_value_text( value_segment->b_type),
  2279. diag_value_text( sym_k_compound_string_value ) );
  2280. sem_evaluate_value_cs (value_segment);
  2281. }
  2282. }
  2283. break;
  2284. case sym_k_integer_table_value:
  2285. {
  2286. sym_value_entry_type *value_segment;
  2287. for (value_segment=val_entry->az_first_table_value;
  2288. value_segment!=NULL;
  2289. value_segment=value_segment->az_next_table_value)
  2290. {
  2291. sem_evaluate_value_expr (value_segment);
  2292. if (value_segment->b_type != sym_k_integer_value &&
  2293. value_segment->b_type != sym_k_horizontal_integer_value &&
  2294. value_segment->b_type != sym_k_vertical_integer_value)
  2295. diag_issue_diagnostic
  2296. ( d_wrong_type,
  2297. _sar_source_pos2( value_segment ),
  2298. diag_value_text( value_segment->b_type),
  2299. diag_value_text( sym_k_integer_value ) );
  2300. }
  2301. }
  2302. break;
  2303. case sym_k_asciz_table_value:
  2304. case sym_k_trans_table_value:
  2305. {
  2306. sym_value_entry_type *value_segment;
  2307. for (value_segment=val_entry->az_first_table_value;
  2308. value_segment!=NULL;
  2309. value_segment=value_segment->az_next_table_value)
  2310. {
  2311. sem_evaluate_value_expr (value_segment);
  2312. if ((value_segment->b_type != sym_k_char_8_value) &&
  2313. (value_segment->b_type != sym_k_localized_string_value))
  2314. diag_issue_diagnostic
  2315. ( d_wrong_type,
  2316. _sar_source_pos2( value_segment ),
  2317. diag_value_text( value_segment->b_type),
  2318. diag_value_text( sym_k_char_8_value ) );
  2319. }
  2320. }
  2321. break;
  2322. case sym_k_font_table_value:
  2323. {
  2324. sym_value_entry_type *value_segment;
  2325. for (value_segment=val_entry->az_first_table_value;
  2326. value_segment!=NULL;
  2327. value_segment=value_segment->az_next_table_value)
  2328. {
  2329. sem_evaluate_value_expr (value_segment);
  2330. if ((value_segment->b_type != sym_k_char_8_value) &&
  2331. (value_segment->b_type != sym_k_localized_string_value) &&
  2332. (value_segment->b_type != sym_k_font_value) &&
  2333. (value_segment->b_type != sym_k_fontset_value))
  2334. diag_issue_diagnostic
  2335. ( d_wrong_type,
  2336. _sar_source_pos2( value_segment ),
  2337. diag_value_text( value_segment->b_type),
  2338. diag_value_text( sym_k_char_8_value ) );
  2339. }
  2340. break;
  2341. }
  2342. /*
  2343. * Fix for CR 5403 - check to make sure each item in the rgb table is an
  2344. * integer value. If not, print an error message. Treat
  2345. * this exactly like the integer_table_value section above.
  2346. */
  2347. case sym_k_rgb_value:
  2348. {
  2349. sym_value_entry_type *value_segment;
  2350. for (value_segment=val_entry->az_first_table_value;
  2351. value_segment!=NULL;
  2352. value_segment=value_segment->az_next_table_value)
  2353. {
  2354. sem_evaluate_value_expr (value_segment);
  2355. if (value_segment->b_type != sym_k_integer_value &&
  2356. value_segment->b_type != sym_k_identifier_value &&
  2357. value_segment->b_type != sym_k_horizontal_integer_value &&
  2358. value_segment->b_type != sym_k_vertical_integer_value)
  2359. diag_issue_diagnostic
  2360. ( d_wrong_type,
  2361. _sar_source_pos2( value_segment ),
  2362. diag_value_text( value_segment->b_type),
  2363. diag_value_text( sym_k_integer_value ) );
  2364. }
  2365. }
  2366. break;
  2367. /*
  2368. * End Fix for CR 5403
  2369. */
  2370. case sym_k_color_table_value:
  2371. {
  2372. sym_color_element *colorVec;
  2373. int ndx;
  2374. colorVec = val_entry->value.z_color;
  2375. for ( ndx=0 ; ndx<(int)val_entry->b_table_count ; ndx++ )
  2376. if ( (int)colorVec[ndx].b_index > 1 ) /* omit FG, BG */
  2377. /*
  2378. * Fix for CR 5428 - check to make sure that the expression result is a
  2379. * color value. If not, print diagnostics.
  2380. */
  2381. {
  2382. sem_evaluate_value_expr (colorVec[ndx].az_color);
  2383. if ((colorVec[ndx].az_color->b_type != sym_k_color_value) &&
  2384. ( colorVec[ndx].az_color->b_type != sym_k_rgb_value))
  2385. diag_issue_diagnostic
  2386. ( d_wrong_type,
  2387. _sar_source_pos2( colorVec[ndx].az_color ),
  2388. diag_value_text( colorVec[ndx].az_color->b_type),
  2389. diag_value_text( sym_k_color_value ) );
  2390. }
  2391. /*
  2392. * End Fix for CR 5428
  2393. */
  2394. break;
  2395. }
  2396. case sym_k_pixmap_value:
  2397. case sym_k_icon_value:
  2398. {
  2399. sym_icon_element *iconDesc;
  2400. sym_value_entry_type *cTable;
  2401. iconDesc = val_entry->value.z_icon;
  2402. /* BEGIN OSF Fix pir 2869*/
  2403. if ( iconDesc == NULL )
  2404. break;
  2405. else cTable = iconDesc->az_color_table;
  2406. /* END OSF Fix pir 2869 */
  2407. if ( cTable == NULL )
  2408. break;
  2409. switch ( cTable->b_type )
  2410. {
  2411. case sym_k_color_table_value:
  2412. {
  2413. sym_color_element *colorVec;
  2414. int vecLen = cTable->b_table_count;
  2415. int ndx;
  2416. int i, j;
  2417. boolean found;
  2418. char *row;
  2419. sym_value_entry_type *rowEntry;
  2420. /*
  2421. * Find each icon character in the table, and replace its
  2422. * character by its index.
  2423. */
  2424. colorVec = cTable->value.z_color;
  2425. rowEntry = iconDesc->az_rows;
  2426. for ( ndx=0 ;
  2427. ndx<(int)iconDesc->w_height ;
  2428. ndx++, rowEntry=rowEntry->az_next_table_value )
  2429. for ( row = rowEntry->value.c_value, i = 0 ;
  2430. i<(int)rowEntry->w_length ;
  2431. i++)
  2432. {
  2433. found = FALSE;
  2434. for ( j=0 ; j<vecLen ; j++ )
  2435. {
  2436. if (colorVec[j].b_letter == row[i])
  2437. {
  2438. found = TRUE;
  2439. row[i] = colorVec[j].b_index;
  2440. break;
  2441. }
  2442. }
  2443. if ( ! found )
  2444. {
  2445. diag_issue_diagnostic
  2446. (d_icon_letter,
  2447. _sar_source_pos2(rowEntry),
  2448. ndx+1,
  2449. i+1,
  2450. row[i]);
  2451. }
  2452. }
  2453. }
  2454. case sym_k_error_value:
  2455. break;
  2456. default:
  2457. diag_issue_diagnostic
  2458. (d_wrong_type,
  2459. _sar_source_pos2(cTable),
  2460. diag_value_text(cTable->b_type),
  2461. diag_value_text(sym_k_color_table_value));
  2462. break;
  2463. }
  2464. break;
  2465. }
  2466. }
  2467. /*
  2468. * Perform evaluations which depend on evaluating expressions
  2469. */
  2470. return(sem_evaluate_value_expr (val_entry));
  2471. }
  2472. /*
  2473. **++
  2474. ** FUNCTIONAL DESCRIPTION:
  2475. **
  2476. ** This function evaluates a compound string value node, and
  2477. ** returns the resulting compound string.
  2478. **
  2479. ** FORMAL PARAMETERS:
  2480. **
  2481. ** csval_entry pointer to the value node to be evaluated
  2482. **
  2483. ** IMPLICIT INPUTS:
  2484. **
  2485. ** none
  2486. **
  2487. ** IMPLICIT OUTPUTS:
  2488. **
  2489. ** none
  2490. **
  2491. ** FUNCTION VALUE:
  2492. **
  2493. ** none
  2494. **
  2495. ** SIDE EFFECTS:
  2496. **
  2497. ** The value and length fields for the value entry are set.
  2498. **
  2499. **--
  2500. **/
  2501. sym_value_entry_type *sem_evaluate_value_cs (csval_entry)
  2502. sym_value_entry_type *csval_entry;
  2503. {
  2504. sym_value_entry_type *next_segment;
  2505. XmString cstr_1;
  2506. XmString cstr_r;
  2507. int charset; /* sym_k_..._charset */
  2508. char *csetptr; /* charset name string */
  2509. _assert( (csval_entry->header.b_tag == sym_k_value_entry) &&
  2510. (csval_entry->b_type == sym_k_compound_string_value),
  2511. "value not compound string" );
  2512. /*
  2513. ** You can't do anyting about imported compound strings so return.
  2514. */
  2515. if ((csval_entry->obj_header.b_flags & sym_m_imported) != 0)
  2516. return(csval_entry);
  2517. /*
  2518. ** If the pointer to the first segment of the compound string has been
  2519. ** cleared (az_first_table_value) and there's a pointer to the evaluated
  2520. ** compound string (value.xms_value), then we must have already evaluated
  2521. ** this compound string. Leave!
  2522. */
  2523. if ((csval_entry->az_first_table_value == NULL) &&
  2524. (csval_entry->value.xms_value != NULL))
  2525. return(csval_entry);
  2526. /*
  2527. ** Get the first segment of the compound string and create
  2528. ** a compound string for it.
  2529. */
  2530. next_segment = csval_entry->az_first_table_value;
  2531. _assert( next_segment != NULL, "compound string with no segments" );
  2532. /*
  2533. ** If the csval_entry direction is set reset the first segments
  2534. ** direction (actually it will be the only segments direction).
  2535. */
  2536. if (csval_entry->b_direction != NOSTRING_DIRECTION)
  2537. {
  2538. next_segment->b_direction = csval_entry->b_direction;
  2539. };
  2540. /*
  2541. ** Initial segment: acquire character set, then
  2542. ** create initial segment.
  2543. */
  2544. charset = sem_map_subclass_to_charset (next_segment->b_charset );
  2545. csetptr = sem_charset_name
  2546. (charset, next_segment->az_charset_value);
  2547. if (next_segment->b_type == sym_k_localized_string_value)
  2548. cstr_r = XmStringCreateLocalized(next_segment->value.c_value);
  2549. else
  2550. cstr_r =
  2551. XmStringConcatAndFree(XmStringDirectionCreate(next_segment->b_direction),
  2552. XmStringCreate(next_segment->value.c_value,
  2553. csetptr));
  2554. if (next_segment->b_aux_flags & sym_m_separate)
  2555. cstr_r = XmStringConcatAndFree(cstr_r,
  2556. XmStringSeparatorCreate());
  2557. /*
  2558. ** Loop through the rest of the segments of the string and append
  2559. ** them to the first segment of the string.
  2560. */
  2561. for (next_segment = next_segment->az_next_table_value;
  2562. next_segment != NULL;
  2563. next_segment = next_segment->az_next_table_value)
  2564. {
  2565. /*
  2566. ** Acquire each segment, and set the character set, as for the
  2567. ** initial segment.
  2568. */
  2569. charset = sem_map_subclass_to_charset (next_segment->b_charset );
  2570. csetptr = sem_charset_name
  2571. (charset, next_segment->az_charset_value);
  2572. /*
  2573. ** Create this segment, then concatenate to the result string.
  2574. ** Free the two inputs now that a concatenated result string
  2575. ** exists.
  2576. */
  2577. cstr_1 =
  2578. XmStringConcatAndFree(XmStringDirectionCreate(next_segment->b_direction),
  2579. XmStringCreate(next_segment->value.c_value,
  2580. csetptr));
  2581. if (next_segment->b_aux_flags & sym_m_separate)
  2582. cstr_1 = XmStringConcatAndFree(cstr_1,
  2583. XmStringSeparatorCreate());
  2584. cstr_r = XmStringConcatAndFree(cstr_r, cstr_1);
  2585. }
  2586. csval_entry->value.xms_value = cstr_r;
  2587. csval_entry->w_length = XmStringLength (cstr_r);
  2588. /*
  2589. ** Now deallocate the nodes for the compound string segments and put a null
  2590. ** in az_first_table_value
  2591. */
  2592. for (next_segment = csval_entry->az_first_table_value;
  2593. next_segment != NULL;
  2594. next_segment = next_segment->az_next_table_value)
  2595. sem_free_node (( sym_entry_type *)next_segment);
  2596. csval_entry->az_first_table_value = NULL;
  2597. _assert( csval_entry->w_length <= MrmMaxResourceSize, "compound string too long" );
  2598. return (csval_entry);
  2599. }
  2600. /* BEGIN OSF Fix CR 4859 */
  2601. /* END OSF Fix CR 4859 */
  2602. /*
  2603. **++
  2604. ** FUNCTIONAL DESCRIPTION:
  2605. **
  2606. ** This function evaluates an expression, placing the resulting value
  2607. ** in the top-level value node of the expression tree. A flag is set
  2608. ** in the top-level node to indicate whether the evaluation has taken
  2609. ** place. The expression tree is left intact so that programs using
  2610. ** the callable UIL compiler will have access to the expression as well
  2611. ** as its evalutated value.
  2612. **
  2613. ** FORMAL PARAMETERS:
  2614. **
  2615. ** value_entry the top-level value node of the expression
  2616. **
  2617. ** IMPLICIT INPUTS:
  2618. **
  2619. ** IMPLICIT OUTPUTS:
  2620. **
  2621. ** FUNCTION VALUE:
  2622. **
  2623. ** The value node resulting from this operation
  2624. **
  2625. ** SIDE EFFECTS:
  2626. **
  2627. **--
  2628. **/
  2629. sym_value_entry_type *sem_evaluate_value_expr (value_entry)
  2630. sym_value_entry_type *value_entry;
  2631. {
  2632. /*
  2633. * Local variables
  2634. */
  2635. char op1_type;
  2636. char op2_type;
  2637. char res_type;
  2638. data_value_type op1_data;
  2639. data_value_type op2_data;
  2640. sym_value_entry_type *op1_entry;
  2641. sym_value_entry_type *op2_entry;
  2642. data_value_type *op1_ptr;
  2643. data_value_type *op2_ptr;
  2644. data_value_type res_data;
  2645. sym_value_entry_type *cat_str_entry;
  2646. /*
  2647. ** If this isn't an operation or if we've already evaluated it, just
  2648. ** leave. Also, guard against attempting to deal with NULLs.
  2649. */
  2650. if ( value_entry == NULL )
  2651. return value_entry;
  2652. if ( (value_entry->b_aux_flags & sym_m_exp_eval) != 0 )
  2653. return value_entry;
  2654. if ( value_entry->b_expr_opr == sym_k_unspecified_op )
  2655. return value_entry;
  2656. /*
  2657. ** If we're just beginning to evaluate a new expression, increment the
  2658. ** value for checking circular references.
  2659. */
  2660. if (!in_expr)
  2661. ref_chk_value++;
  2662. in_expr = TRUE;
  2663. /*
  2664. ** Check for circular references.
  2665. ** Place a value in each node of this expression. If we see the same
  2666. ** value again as we evaluate the expression, we've been here before
  2667. ** (kind of like dropping bread crumbs).
  2668. */
  2669. if (value_entry->l_circular_ref_chk == ref_chk_value)
  2670. {
  2671. if ( value_entry->obj_header.az_name != NULL )
  2672. diag_issue_diagnostic
  2673. (d_circular_ref,
  2674. _sar_source_pos2(value_entry),
  2675. value_entry->obj_header.az_name->c_text);
  2676. else
  2677. diag_issue_diagnostic
  2678. (d_circular_ref,
  2679. _sar_source_pos2(value_entry),
  2680. "unnamed value");
  2681. return NULL;
  2682. }
  2683. value_entry->l_circular_ref_chk = ref_chk_value;
  2684. /*
  2685. ** Validate the first argument for the expression. If it is NULL,
  2686. ** then return with no further processing, since this is usually
  2687. ** due to previous compilation errors.
  2688. */
  2689. if ( value_entry->az_exp_op1 == NULL )
  2690. return NULL;
  2691. sem_evaluate_value_expr(value_entry->az_exp_op1);
  2692. in_expr = TRUE;
  2693. op1_type = validate_arg (value_entry->az_exp_op1,
  2694. value_entry->b_expr_opr);
  2695. op1_entry = value_entry->az_exp_op1;
  2696. res_type = op1_type;
  2697. /*
  2698. ** If it's a binary expression, evaluate the second argument and
  2699. ** perform any necessary conversions
  2700. */
  2701. if (value_entry->az_exp_op2 != NULL)
  2702. {
  2703. sem_evaluate_value_expr(value_entry->az_exp_op2);
  2704. in_expr = TRUE;
  2705. op2_type = validate_arg (value_entry->az_exp_op2,
  2706. value_entry->b_expr_opr);
  2707. /*
  2708. ** Perform conversions
  2709. */
  2710. op2_entry = value_entry->az_exp_op2;
  2711. res_type = op1_type;
  2712. if (res_type < op2_type)
  2713. res_type = op2_type;
  2714. if (op1_type != res_type)
  2715. {
  2716. op1_ptr = &op1_data;
  2717. if (res_type <= error_arg_type)
  2718. op1_type = (* numeric_convert_table[ res_type ])
  2719. ( op1_entry, op1_ptr );
  2720. else if ((res_type != cstr_arg_type) &&
  2721. (res_type != lstr_arg_type))
  2722. {
  2723. diag_issue_diagnostic
  2724. ( d_cannot_convert,
  2725. _sar_source_pos2( value_entry),
  2726. diag_value_text( op1_entry->b_type ),
  2727. diag_value_text( res_type ) );
  2728. res_type = error_arg_type;
  2729. goto continue_after_error;
  2730. }
  2731. }
  2732. else
  2733. {
  2734. op1_ptr = (data_value_type *) &(op1_entry->value);
  2735. }
  2736. if (op2_type != res_type)
  2737. {
  2738. op2_ptr = &op2_data;
  2739. if (res_type <= error_arg_type)
  2740. op2_type = (* numeric_convert_table[ res_type ])
  2741. ( op2_entry, op2_ptr );
  2742. else if ((res_type != cstr_arg_type) &&
  2743. (res_type != lstr_arg_type))
  2744. {
  2745. diag_issue_diagnostic
  2746. ( d_cannot_convert,
  2747. _sar_source_pos2( value_entry),
  2748. diag_value_text( op1_entry->b_type ),
  2749. diag_value_text( res_type ) );
  2750. res_type = error_arg_type;
  2751. goto continue_after_error;
  2752. }
  2753. }
  2754. else
  2755. {
  2756. op2_ptr = (data_value_type *) &(op2_entry->value);
  2757. }
  2758. }
  2759. /*
  2760. ** Perform the operation
  2761. */
  2762. switch (value_entry->b_expr_opr)
  2763. {
  2764. case sym_k_unary_plus_op:
  2765. switch (op1_type)
  2766. {
  2767. case integer_arg_type:
  2768. case horizontal_integer_arg_type:
  2769. case vertical_integer_arg_type:
  2770. value_entry->value.l_integer = op1_entry->value.l_integer;
  2771. value_entry->b_arg_type = op1_entry->b_arg_type;
  2772. break;
  2773. case float_arg_type:
  2774. case horizontal_float_arg_type:
  2775. case vertical_float_arg_type:
  2776. value_entry->value.d_real = op1_entry->value.d_real;
  2777. value_entry->b_arg_type = op1_entry->b_arg_type;
  2778. break;
  2779. case single_float_arg_type: /* single float data type RAP */
  2780. value_entry->value.single_float = op1_entry->value.single_float;
  2781. break;
  2782. case error_arg_type:
  2783. break;
  2784. default:
  2785. diag_issue_diagnostic
  2786. ( d_cannot_convert,
  2787. _sar_source_pos2( value_entry),
  2788. diag_value_text( op1_entry->b_type ),
  2789. diag_value_text( value_entry->b_type ) );
  2790. res_type = error_arg_type;
  2791. }
  2792. break;
  2793. case sym_k_unary_minus_op:
  2794. switch (op1_type)
  2795. {
  2796. case integer_arg_type:
  2797. case horizontal_integer_arg_type:
  2798. case vertical_integer_arg_type:
  2799. value_entry->value.l_integer = - op1_entry->value.l_integer;
  2800. value_entry->b_arg_type = op1_entry->b_arg_type;
  2801. break;
  2802. case float_arg_type:
  2803. case horizontal_float_arg_type:
  2804. case vertical_float_arg_type:
  2805. value_entry->value.d_real = - op1_entry->value.d_real;
  2806. value_entry->b_arg_type = op1_entry->b_arg_type;
  2807. break;
  2808. case single_float_arg_type: /* single float data type RAP */
  2809. value_entry->value.single_float = - op1_entry->value.single_float;
  2810. break;
  2811. case error_arg_type:
  2812. break;
  2813. default:
  2814. diag_issue_diagnostic
  2815. ( d_cannot_convert,
  2816. _sar_source_pos2( value_entry),
  2817. diag_value_text( op1_entry->b_type ),
  2818. diag_value_text( value_entry->b_type ) );
  2819. res_type = error_arg_type;
  2820. }
  2821. break;
  2822. case sym_k_not_op:
  2823. switch (op1_type)
  2824. {
  2825. case boolean_arg_type:
  2826. value_entry->value.l_integer = ! op1_entry->value.l_integer;
  2827. break;
  2828. case integer_arg_type:
  2829. value_entry->value.l_integer = ~ op1_entry->value.l_integer;
  2830. break;
  2831. case error_arg_type:
  2832. break;
  2833. default:
  2834. diag_issue_diagnostic
  2835. ( d_cannot_convert,
  2836. _sar_source_pos2( value_entry),
  2837. diag_value_text( op1_entry->b_type ),
  2838. diag_value_text( value_entry->b_type ) );
  2839. res_type = error_arg_type;
  2840. }
  2841. break;
  2842. case sym_k_comp_str_op:
  2843. switch (op1_type)
  2844. {
  2845. case char_arg_type: /* char_8_type */
  2846. case lstr_arg_type:
  2847. sem_append_str_to_cstr(value_entry, value_entry->az_exp_op1, FALSE);
  2848. value_entry->az_first_table_value->b_aux_flags =
  2849. value_entry->b_aux_flags;
  2850. /*
  2851. * Fix for CN 16149 (DTS 10023) part 2 -- If it exists, put the
  2852. * charset info collected by sar_chk_comp_str_attr() onto the
  2853. * char_8 string data structure.
  2854. */
  2855. if (value_entry->b_charset != sym_k_error_charset) {
  2856. value_entry->az_first_table_value->b_charset =
  2857. value_entry->b_charset;
  2858. if (value_entry->az_charset_value)
  2859. value_entry->az_first_table_value->az_charset_value =
  2860. value_entry->az_charset_value;
  2861. }
  2862. /* End fix for CN 16149 */
  2863. sem_evaluate_value_cs(value_entry);
  2864. res_type = cstr_arg_type;
  2865. break;
  2866. case cstr_arg_type: /* comp_str */;
  2867. {
  2868. XmString cstr;
  2869. /*
  2870. * If we're dealing with a combination 1-byte, 2-byte
  2871. * string, then we have to evaluate it first. (if not
  2872. * already done)
  2873. */
  2874. if (value_entry->az_exp_op1->az_first_table_value != NULL)
  2875. {
  2876. sem_evaluate_value_cs(value_entry->az_exp_op1);
  2877. }
  2878. /*
  2879. * If there is a separater invoved, makes sure it gets
  2880. * concatendated onto the end of the string. Also free
  2881. * up used memory.
  2882. */
  2883. if ((value_entry->b_aux_flags
  2884. & sym_m_separate) != 0 )
  2885. {
  2886. cstr = XmStringSeparatorCreate();
  2887. value_entry->value.l_integer =
  2888. (long)XmStringConcatAndFree((XmString)value_entry->az_exp_op1->
  2889. value.l_integer, cstr);
  2890. }
  2891. else
  2892. {
  2893. value_entry->value.l_integer =
  2894. value_entry->az_exp_op1->value.l_integer;
  2895. }
  2896. sem_evaluate_value_cs(value_entry);
  2897. res_type = cstr_arg_type;
  2898. };
  2899. break;
  2900. default:
  2901. diag_issue_diagnostic
  2902. ( d_cannot_convert,
  2903. _sar_source_pos2( value_entry),
  2904. diag_value_text( op1_entry->b_type ),
  2905. diag_value_text( value_entry->b_type ) );
  2906. res_type = error_arg_type;
  2907. }
  2908. break;
  2909. case sym_k_wchar_str_op:
  2910. switch (op1_type)
  2911. {
  2912. case lstr_arg_type: /* localized string type */
  2913. sem_append_str_to_cstr(value_entry, value_entry->az_exp_op1, FALSE);
  2914. value_entry->az_first_table_value->b_aux_flags =
  2915. value_entry->b_aux_flags;
  2916. /* BEGIN OSF Fix CR 4859 */
  2917. /* END OSF Fix CR 4859 */
  2918. res_type = wcstr_arg_type;
  2919. break;
  2920. default:
  2921. diag_issue_diagnostic
  2922. ( d_cannot_convert,
  2923. _sar_source_pos2( value_entry),
  2924. diag_value_text( op1_entry->b_type ),
  2925. diag_value_text( value_entry->b_type ) );
  2926. res_type = error_arg_type;
  2927. }
  2928. break;
  2929. case sym_k_coerce_op:
  2930. switch (value_entry->b_type)
  2931. {
  2932. case sym_k_compound_string_value:
  2933. switch (op1_entry->b_type)
  2934. {
  2935. case sym_k_char_8_value:
  2936. case sym_k_localized_string_value:
  2937. sem_append_str_to_cstr
  2938. (value_entry,
  2939. op1_entry,
  2940. FALSE);
  2941. sem_evaluate_value_cs(value_entry);
  2942. res_type = cstr_arg_type;
  2943. break;
  2944. case sym_k_compound_string_value:
  2945. _sym_copy_entry (value_entry,
  2946. op1_entry,
  2947. sym_k_value_entry_size);
  2948. res_type = cstr_arg_type;
  2949. break;
  2950. default:
  2951. diag_issue_diagnostic
  2952. ( d_cannot_convert,
  2953. _sar_source_pos2( value_entry),
  2954. diag_value_text( op1_entry->b_type ),
  2955. diag_value_text( value_entry->b_type ) );
  2956. res_type = error_arg_type;
  2957. break;
  2958. }
  2959. break;
  2960. case sym_k_wchar_string_value:
  2961. switch (op1_entry->b_type)
  2962. {
  2963. case sym_k_localized_string_value:
  2964. sem_append_str_to_cstr
  2965. (value_entry,
  2966. op1_entry,
  2967. FALSE);
  2968. /* BEGIN OSF Fix CR 4859 */
  2969. /* END OSF Fix CR 4859 */
  2970. res_type = wcstr_arg_type;
  2971. break;
  2972. default:
  2973. diag_issue_diagnostic
  2974. ( d_cannot_convert,
  2975. _sar_source_pos2( value_entry),
  2976. diag_value_text( op1_entry->b_type ),
  2977. diag_value_text( value_entry->b_type ) );
  2978. res_type = error_arg_type;
  2979. break;
  2980. }
  2981. break;
  2982. case sym_k_font_table_value:
  2983. if ((op1_entry->b_type == sym_k_font_value) ||
  2984. (op1_entry->b_type == sym_k_fontset_value))
  2985. {
  2986. value_entry->b_table_count = 1;
  2987. value_entry->az_first_table_value = op1_entry;
  2988. res_type = font_table_arg_type;
  2989. }
  2990. else
  2991. {
  2992. diag_issue_diagnostic
  2993. ( d_cannot_convert,
  2994. _sar_source_pos2( value_entry),
  2995. diag_value_text( op1_entry->b_type ),
  2996. diag_value_text( value_entry->b_type ) );
  2997. res_type = error_arg_type;
  2998. }
  2999. break;
  3000. case sym_k_font_value:
  3001. if ((op1_entry->b_type == sym_k_char_8_value) ||
  3002. (op1_entry->b_type == sym_k_localized_string_value) ||
  3003. (op1_entry->b_type == sym_k_font_value))
  3004. {
  3005. value_entry->value.c_value = op1_entry->value.c_value;
  3006. value_entry->w_length = op1_entry->w_length;
  3007. res_type = font_arg_type;
  3008. }
  3009. else
  3010. {
  3011. diag_issue_diagnostic
  3012. ( d_cannot_convert,
  3013. _sar_source_pos2( value_entry),
  3014. diag_value_text( op1_entry->b_type ),
  3015. diag_value_text( value_entry->b_type ) );
  3016. res_type = error_arg_type;
  3017. }
  3018. break;
  3019. case sym_k_fontset_value:
  3020. if ((op1_entry->b_type == sym_k_char_8_value) ||
  3021. (op1_entry->b_type == sym_k_localized_string_value) ||
  3022. (op1_entry->b_type == sym_k_fontset_value))
  3023. {
  3024. value_entry->value.c_value = op1_entry->value.c_value;
  3025. value_entry->w_length = op1_entry->w_length;
  3026. res_type = fontset_arg_type;
  3027. }
  3028. else
  3029. {
  3030. diag_issue_diagnostic
  3031. ( d_cannot_convert,
  3032. _sar_source_pos2( value_entry),
  3033. diag_value_text( op1_entry->b_type ),
  3034. diag_value_text( value_entry->b_type ) );
  3035. res_type = error_arg_type;
  3036. }
  3037. case sym_k_color_value:
  3038. case sym_k_xbitmapfile_value:
  3039. case sym_k_reason_value:
  3040. case sym_k_argument_value:
  3041. case sym_k_keysym_value:
  3042. case sym_k_class_rec_name_value:
  3043. switch (value_entry->b_type)
  3044. {
  3045. case sym_k_color_value:
  3046. res_type = color_arg_type;
  3047. break;
  3048. case sym_k_xbitmapfile_value:
  3049. res_type = xbitmap_arg_type;
  3050. break;
  3051. case sym_k_reason_value:
  3052. res_type = reason_arg_type;
  3053. break;
  3054. case sym_k_argument_value:
  3055. res_type = argument_arg_type;
  3056. break;
  3057. case sym_k_keysym_value:
  3058. res_type = keysym_arg_type;
  3059. break;
  3060. /* Begin fixing CR 5429 */
  3061. case sym_k_class_rec_name_value:
  3062. res_type = classrec_arg_type;
  3063. break;
  3064. /* End fixing CR 5429 */
  3065. }
  3066. switch (op1_entry->b_type)
  3067. {
  3068. case sym_k_char_8_value:
  3069. case sym_k_localized_string_value:
  3070. value_entry->value.c_value = op1_entry->value.c_value;
  3071. value_entry->w_length = op1_entry->w_length;
  3072. break;
  3073. default:
  3074. diag_issue_diagnostic
  3075. ( d_cannot_convert,
  3076. _sar_source_pos2( value_entry),
  3077. diag_value_text( op1_entry->b_type ),
  3078. diag_value_text( value_entry->b_type ) );
  3079. res_type = error_arg_type;
  3080. break;
  3081. }
  3082. break;
  3083. case sym_k_integer_value:
  3084. case sym_k_horizontal_integer_value:
  3085. case sym_k_vertical_integer_value:
  3086. res_type = integer_arg_type;
  3087. switch (op1_entry->b_type)
  3088. {
  3089. case sym_k_bool_value:
  3090. case sym_k_integer_value:
  3091. case sym_k_horizontal_integer_value:
  3092. case sym_k_vertical_integer_value:
  3093. value_entry->value.l_integer = op1_entry->value.l_integer;
  3094. value_entry->b_arg_type = op1_entry->b_arg_type;
  3095. break;
  3096. case sym_k_float_value:
  3097. case sym_k_horizontal_float_value:
  3098. case sym_k_vertical_float_value:
  3099. res_type = sem_convert_to_integer( op1_entry, &res_data );
  3100. value_entry->value.l_integer = res_data.integer_value;
  3101. value_entry->b_arg_type = op1_entry->b_arg_type;
  3102. break;
  3103. case sym_k_single_float_value: /* single float data type RAP */
  3104. res_type = sem_convert_to_integer( op1_entry, &res_data );
  3105. value_entry->value.l_integer = res_data.integer_value;
  3106. break;
  3107. default:
  3108. diag_issue_diagnostic
  3109. ( d_cannot_convert,
  3110. _sar_source_pos2( value_entry),
  3111. diag_value_text( op1_entry->b_type ),
  3112. diag_value_text( value_entry->b_type ) );
  3113. res_type = error_arg_type;
  3114. break;
  3115. }
  3116. break;
  3117. case sym_k_float_value:
  3118. case sym_k_horizontal_float_value:
  3119. case sym_k_vertical_float_value:
  3120. res_type = float_arg_type;
  3121. switch (op1_entry->b_type)
  3122. {
  3123. case sym_k_bool_value:
  3124. case sym_k_integer_value:
  3125. case sym_k_single_float_value: /* single float data type RAP */
  3126. case sym_k_horizontal_integer_value:
  3127. case sym_k_vertical_integer_value:
  3128. res_type = sem_convert_to_float( op1_entry, &res_data );
  3129. value_entry->value.d_real = res_data.real_value;
  3130. value_entry->b_arg_type = op1_entry->b_arg_type;
  3131. break;
  3132. case sym_k_float_value:
  3133. case sym_k_horizontal_float_value:
  3134. case sym_k_vertical_float_value:
  3135. value_entry->value.d_real = op1_entry->value.d_real;
  3136. value_entry->b_arg_type = op1_entry->b_arg_type;
  3137. break;
  3138. default:
  3139. diag_issue_diagnostic
  3140. ( d_cannot_convert,
  3141. _sar_source_pos2( value_entry),
  3142. diag_value_text( op1_entry->b_type ),
  3143. diag_value_text( value_entry->b_type ) );
  3144. res_type = error_arg_type;
  3145. break;
  3146. }
  3147. break;
  3148. case sym_k_single_float_value:
  3149. res_type = single_float_arg_type;
  3150. switch (op1_entry->b_type)
  3151. {
  3152. case sym_k_bool_value:
  3153. case sym_k_integer_value:
  3154. case sym_k_horizontal_integer_value:
  3155. case sym_k_vertical_integer_value:
  3156. case sym_k_float_value:
  3157. case sym_k_horizontal_float_value:
  3158. case sym_k_vertical_float_value:
  3159. res_type = sem_convert_to_single_float( op1_entry, &res_data );
  3160. value_entry->value.single_float = res_data.single_float_value;
  3161. value_entry->b_arg_type = op1_entry->b_arg_type;
  3162. break;
  3163. case sym_k_single_float_value:
  3164. value_entry->value.single_float = op1_entry->value.single_float;
  3165. break;
  3166. default:
  3167. diag_issue_diagnostic
  3168. ( d_cannot_convert,
  3169. _sar_source_pos2( value_entry),
  3170. diag_value_text( op1_entry->b_type ),
  3171. diag_value_text( value_entry->b_type ) );
  3172. res_type = error_arg_type;
  3173. break;
  3174. }
  3175. break;
  3176. case sym_k_error_value:
  3177. break;
  3178. default:
  3179. /* Begin fixing CR 5429 */
  3180. if ((op1_entry->b_type != sym_k_char_8_value) &&
  3181. (op1_entry->b_type != sym_k_localized_string_value))
  3182. diag_issue_diagnostic
  3183. ( d_wrong_type,
  3184. _sar_source_pos2( value_entry ),
  3185. diag_value_text( op1_entry->b_type ),
  3186. diag_value_text( sym_k_char_8_value ) );
  3187. else
  3188. diag_issue_diagnostic
  3189. ( d_wrong_type,
  3190. _sar_source_pos2( value_entry ),
  3191. "wrong",
  3192. diag_value_text( sym_k_char_8_value ) );
  3193. value_entry = sym_az_error_value_entry;
  3194. res_type = error_arg_type;
  3195. }
  3196. break;
  3197. /* End fixing CR 5429 */
  3198. case sym_k_valref_op:
  3199. {
  3200. /*
  3201. ** Copy all the value-related fields from the referenced
  3202. ** node to the referencing node. All non value-related fields
  3203. ** are left intact, except that the forward reference flag
  3204. ** is turned off
  3205. */
  3206. value_entry->obj_header.b_flags &= ~sym_m_forward_ref;
  3207. value_entry->b_type = op1_entry->b_type;
  3208. value_entry->w_length = op1_entry->w_length;
  3209. value_entry->b_table_count = op1_entry->b_table_count;
  3210. value_entry->b_aux_flags = op1_entry->b_aux_flags;
  3211. value_entry->b_arg_type = op1_entry->b_arg_type;
  3212. value_entry->b_data_offset = op1_entry->b_data_offset;
  3213. value_entry->b_pixel_type = op1_entry->b_pixel_type;
  3214. value_entry->b_charset = op1_entry->b_charset;
  3215. value_entry->b_direction = op1_entry->b_direction;
  3216. value_entry->b_enumeration_value_code =
  3217. op1_entry->b_enumeration_value_code;
  3218. value_entry->az_first_table_value = op1_entry->az_first_table_value;
  3219. value_entry->az_charset_value = op1_entry->az_charset_value;
  3220. /*
  3221. ** Because of alignment requirements, we can't just move the largest
  3222. ** field of the union, but actually have to move the correct value
  3223. ** field based upon the datatype.
  3224. */
  3225. switch (op1_entry->b_type)
  3226. {
  3227. case sym_k_integer_value:
  3228. case sym_k_horizontal_integer_value:
  3229. case sym_k_vertical_integer_value:
  3230. value_entry->value.l_integer = op1_entry->value.l_integer;
  3231. value_entry->b_arg_type = op1_entry->b_arg_type;
  3232. break;
  3233. case sym_k_float_value:
  3234. case sym_k_horizontal_float_value:
  3235. case sym_k_vertical_float_value:
  3236. value_entry->value.d_real = op1_entry->value.d_real;
  3237. value_entry->b_arg_type = op1_entry->b_arg_type;
  3238. break;
  3239. case sym_k_char_8_value:
  3240. case sym_k_localized_string_value:
  3241. value_entry->value.c_value = op1_entry->value.c_value;
  3242. break;
  3243. case sym_k_single_float_value:
  3244. value_entry->value.single_float = op1_entry->value.single_float;
  3245. break;
  3246. case sym_k_color_value:
  3247. value_entry->value.z_color = op1_entry->value.z_color;
  3248. break;
  3249. case sym_k_icon_value:
  3250. value_entry->value.z_icon = op1_entry->value.z_icon;
  3251. break;
  3252. default:
  3253. value_entry->value.az_data = op1_entry->value.az_data;
  3254. break;
  3255. }
  3256. break;
  3257. }
  3258. case sym_k_add_op:
  3259. switch (res_type)
  3260. {
  3261. case integer_arg_type:
  3262. case horizontal_integer_arg_type:
  3263. case vertical_integer_arg_type:
  3264. value_entry->value.l_integer =
  3265. op1_ptr->integer_value + op2_ptr->integer_value;
  3266. if (op1_entry->b_arg_type != op2_entry->b_arg_type)
  3267. {
  3268. diag_issue_diagnostic(d_different_units,
  3269. _sar_source_pos2(value_entry));
  3270. res_type = error_arg_type;
  3271. }
  3272. else value_entry->b_arg_type = op1_entry->b_arg_type;
  3273. break;
  3274. case float_arg_type:
  3275. case horizontal_float_arg_type:
  3276. case vertical_float_arg_type:
  3277. value_entry->value.d_real =
  3278. op1_ptr->real_value + op2_ptr->real_value;
  3279. if (op1_entry->b_arg_type != op2_entry->b_arg_type)
  3280. {
  3281. diag_issue_diagnostic(d_different_units,
  3282. _sar_source_pos2(value_entry));
  3283. res_type = error_arg_type;
  3284. }
  3285. else value_entry->b_arg_type = op1_entry->b_arg_type;
  3286. break;
  3287. case single_float_arg_type:
  3288. value_entry->value.single_float =
  3289. op1_ptr->single_float_value + op2_ptr->single_float_value;
  3290. break;
  3291. case error_arg_type:
  3292. break;
  3293. default:
  3294. diag_issue_diagnostic
  3295. ( d_cannot_convert,
  3296. _sar_source_pos2( value_entry),
  3297. diag_value_text( op1_entry->b_type ),
  3298. diag_value_text( value_entry->b_type ) );
  3299. res_type = error_arg_type;
  3300. }
  3301. break;
  3302. case sym_k_subtract_op:
  3303. switch (res_type)
  3304. {
  3305. case integer_arg_type:
  3306. case horizontal_integer_arg_type:
  3307. case vertical_integer_arg_type:
  3308. value_entry->value.l_integer =
  3309. op1_ptr->integer_value - op2_ptr->integer_value;
  3310. if (op1_entry->b_arg_type != op2_entry->b_arg_type)
  3311. {
  3312. diag_issue_diagnostic(d_different_units,
  3313. _sar_source_pos2(value_entry));
  3314. res_type = error_arg_type;
  3315. }
  3316. else value_entry->b_arg_type = op1_entry->b_arg_type;
  3317. break;
  3318. case float_arg_type:
  3319. case horizontal_float_arg_type:
  3320. case vertical_float_arg_type:
  3321. value_entry->value.d_real =
  3322. op1_ptr->real_value - op2_ptr->real_value;
  3323. if (op1_entry->b_arg_type != op2_entry->b_arg_type)
  3324. {
  3325. diag_issue_diagnostic(d_different_units,
  3326. _sar_source_pos2(value_entry));
  3327. res_type = error_arg_type;
  3328. }
  3329. else value_entry->b_arg_type = op1_entry->b_arg_type;
  3330. break;
  3331. case single_float_arg_type:
  3332. value_entry->value.single_float =
  3333. op1_ptr->single_float_value - op2_ptr->single_float_value;
  3334. break;
  3335. case error_arg_type:
  3336. break;
  3337. default:
  3338. diag_issue_diagnostic
  3339. ( d_cannot_convert,
  3340. _sar_source_pos2( value_entry),
  3341. diag_value_text( op1_entry->b_type ),
  3342. diag_value_text( value_entry->b_type ) );
  3343. res_type = error_arg_type;
  3344. }
  3345. break;
  3346. case sym_k_multiply_op:
  3347. switch (res_type)
  3348. {
  3349. case integer_arg_type:
  3350. case horizontal_integer_arg_type:
  3351. case vertical_integer_arg_type:
  3352. value_entry->value.l_integer =
  3353. op1_ptr->integer_value * op2_ptr->integer_value;
  3354. if (op1_entry->b_arg_type != op2_entry->b_arg_type)
  3355. {
  3356. diag_issue_diagnostic(d_different_units,
  3357. _sar_source_pos2(value_entry));
  3358. res_type = error_arg_type;
  3359. }
  3360. else value_entry->b_arg_type = op1_entry->b_arg_type;
  3361. break;
  3362. case float_arg_type:
  3363. case horizontal_float_arg_type:
  3364. case vertical_float_arg_type:
  3365. value_entry->value.d_real =
  3366. op1_ptr->real_value * op2_ptr->real_value;
  3367. if (op1_entry->b_arg_type != op2_entry->b_arg_type)
  3368. {
  3369. diag_issue_diagnostic(d_different_units,
  3370. _sar_source_pos2(value_entry));
  3371. res_type = error_arg_type;
  3372. }
  3373. else value_entry->b_arg_type = op1_entry->b_arg_type;
  3374. break;
  3375. case single_float_arg_type:
  3376. value_entry->value.single_float =
  3377. op1_ptr->single_float_value * op2_ptr->single_float_value;
  3378. break;
  3379. case error_arg_type:
  3380. break;
  3381. default:
  3382. diag_issue_diagnostic
  3383. ( d_cannot_convert,
  3384. _sar_source_pos2( value_entry),
  3385. diag_value_text( op1_entry->b_type ),
  3386. diag_value_text( value_entry->b_type ) );
  3387. res_type = error_arg_type;
  3388. }
  3389. break;
  3390. case sym_k_divide_op:
  3391. switch (res_type)
  3392. {
  3393. case integer_arg_type:
  3394. case horizontal_integer_arg_type:
  3395. case vertical_integer_arg_type:
  3396. value_entry->value.l_integer =
  3397. op1_ptr->integer_value / op2_ptr->integer_value;
  3398. if (op1_entry->b_arg_type != op2_entry->b_arg_type)
  3399. {
  3400. diag_issue_diagnostic(d_different_units,
  3401. _sar_source_pos2(value_entry));
  3402. res_type = error_arg_type;
  3403. }
  3404. else value_entry->b_arg_type = op1_entry->b_arg_type;
  3405. break;
  3406. case float_arg_type:
  3407. case horizontal_float_arg_type:
  3408. case vertical_float_arg_type:
  3409. value_entry->value.d_real =
  3410. op1_ptr->real_value / op2_ptr->real_value;
  3411. if (op1_entry->b_arg_type != op2_entry->b_arg_type)
  3412. {
  3413. diag_issue_diagnostic(d_different_units,
  3414. _sar_source_pos2(value_entry));
  3415. res_type = error_arg_type;
  3416. }
  3417. else value_entry->b_arg_type = op1_entry->b_arg_type;
  3418. break;
  3419. case single_float_arg_type:
  3420. value_entry->value.single_float =
  3421. op1_ptr->single_float_value / op2_ptr->single_float_value;
  3422. break;
  3423. case error_arg_type:
  3424. break;
  3425. default:
  3426. diag_issue_diagnostic
  3427. ( d_cannot_convert,
  3428. _sar_source_pos2( value_entry),
  3429. diag_value_text( op1_entry->b_type ),
  3430. diag_value_text( value_entry->b_type ) );
  3431. res_type = error_arg_type;
  3432. }
  3433. break;
  3434. case sym_k_left_shift_op:
  3435. switch (res_type)
  3436. {
  3437. case integer_arg_type:
  3438. {
  3439. int shift_count;
  3440. shift_count = op2_ptr->integer_value;
  3441. if ((shift_count < 0) || (shift_count > 32))
  3442. goto error_occurred;
  3443. value_entry->value.l_integer =
  3444. op1_ptr->integer_value << op2_ptr->integer_value;
  3445. break;
  3446. }
  3447. case error_arg_type:
  3448. break;
  3449. default:
  3450. diag_issue_diagnostic
  3451. ( d_cannot_convert,
  3452. _sar_source_pos2( value_entry),
  3453. diag_value_text( op1_entry->b_type ),
  3454. diag_value_text( value_entry->b_type ) );
  3455. res_type = error_arg_type;
  3456. }
  3457. break;
  3458. case sym_k_right_shift_op:
  3459. switch (res_type)
  3460. {
  3461. case integer_arg_type:
  3462. {
  3463. int shift_count;
  3464. shift_count = op2_ptr->integer_value;
  3465. if ((shift_count < 0) || (shift_count > 32))
  3466. goto error_occurred;
  3467. value_entry->value.l_integer =
  3468. op1_ptr->integer_value >> op2_ptr->integer_value;
  3469. break;
  3470. }
  3471. case error_arg_type:
  3472. break;
  3473. default:
  3474. diag_issue_diagnostic
  3475. ( d_cannot_convert,
  3476. _sar_source_pos2( value_entry),
  3477. diag_value_text( op1_entry->b_type ),
  3478. diag_value_text( value_entry->b_type ) );
  3479. res_type = error_arg_type;
  3480. }
  3481. break;
  3482. case sym_k_and_op:
  3483. switch (res_type)
  3484. {
  3485. case integer_arg_type:
  3486. case boolean_arg_type:
  3487. value_entry->value.l_integer =
  3488. op1_ptr->integer_value & op2_ptr->integer_value;
  3489. break;
  3490. case char_arg_type:
  3491. case lstr_arg_type:
  3492. sar_cat_value_entry( &cat_str_entry, op1_entry, op2_entry );
  3493. value_entry->b_type = cat_str_entry->b_type;
  3494. if (cat_str_entry->b_type == sym_k_compound_string_value)
  3495. {
  3496. res_type = cstr_arg_type;
  3497. value_entry->az_first_table_value = cat_str_entry->az_first_table_value;
  3498. }
  3499. value_entry->b_charset = cat_str_entry->b_charset;
  3500. value_entry->b_direction = cat_str_entry->b_direction;
  3501. value_entry->value.c_value = cat_str_entry->value.c_value;
  3502. value_entry->w_length = cat_str_entry->w_length;
  3503. cat_str_entry->value.c_value = NULL;
  3504. sem_free_node (( sym_entry_type *)cat_str_entry);
  3505. break;
  3506. case cstr_arg_type:
  3507. sar_cat_value_entry( &cat_str_entry, op1_entry, op2_entry );
  3508. value_entry->b_type = cat_str_entry->b_type;
  3509. value_entry->b_charset = cat_str_entry->b_charset;
  3510. value_entry->b_direction = cat_str_entry->b_direction;
  3511. value_entry->value.xms_value = cat_str_entry->value.xms_value;
  3512. value_entry->az_first_table_value =
  3513. cat_str_entry->az_first_table_value;
  3514. value_entry->w_length = cat_str_entry->w_length;
  3515. sem_evaluate_value_cs (value_entry);
  3516. cat_str_entry->value.xms_value = NULL;
  3517. sem_free_node (( sym_entry_type *)cat_str_entry);
  3518. break;
  3519. case error_arg_type:
  3520. break;
  3521. default:
  3522. diag_issue_diagnostic
  3523. ( d_cannot_convert,
  3524. _sar_source_pos2( value_entry),
  3525. diag_value_text( op1_entry->b_type ),
  3526. diag_value_text( value_entry->b_type ) );
  3527. res_type = error_arg_type;
  3528. }
  3529. break;
  3530. case sym_k_or_op:
  3531. switch (res_type)
  3532. {
  3533. case integer_arg_type:
  3534. case boolean_arg_type:
  3535. value_entry->value.l_integer =
  3536. op1_ptr->integer_value | op2_ptr->integer_value;
  3537. break;
  3538. case error_arg_type:
  3539. break;
  3540. default:
  3541. diag_issue_diagnostic
  3542. ( d_cannot_convert,
  3543. _sar_source_pos2( value_entry),
  3544. diag_value_text( op1_entry->b_type ),
  3545. diag_value_text( value_entry->b_type ) );
  3546. res_type = error_arg_type;
  3547. }
  3548. break;
  3549. case sym_k_xor_op:
  3550. switch (res_type)
  3551. {
  3552. case integer_arg_type:
  3553. case boolean_arg_type:
  3554. value_entry->value.l_integer =
  3555. op1_ptr->integer_value ^ op2_ptr->integer_value;
  3556. break;
  3557. case error_arg_type:
  3558. break;
  3559. default:
  3560. diag_issue_diagnostic
  3561. ( d_cannot_convert,
  3562. _sar_source_pos2( value_entry),
  3563. diag_value_text( op1_entry->b_type ),
  3564. diag_value_text( value_entry->b_type ) );
  3565. res_type = error_arg_type;
  3566. }
  3567. break;
  3568. default:
  3569. _assert( FALSE, "unexpected operator" );
  3570. } /* End of switch statement */
  3571. continue_after_error:
  3572. /*
  3573. ** Set data type for expression value. If binary operation, use res_type
  3574. ** because conversions may have taken place. Otherwise use b_type from
  3575. ** the operand of the unary operator.
  3576. */
  3577. if (value_entry->b_expr_opr == sym_k_valref_op)
  3578. value_entry->b_type = op1_entry->b_type;
  3579. else
  3580. switch (res_type)
  3581. {
  3582. case boolean_arg_type:
  3583. value_entry->b_type = sym_k_bool_value;
  3584. break;
  3585. case integer_arg_type:
  3586. value_entry->b_type = sym_k_integer_value;
  3587. break;
  3588. case single_float_arg_type:
  3589. value_entry->b_type = sym_k_single_float_value;
  3590. break;
  3591. case float_arg_type:
  3592. value_entry->b_type = sym_k_float_value;
  3593. break;
  3594. case horizontal_integer_arg_type:
  3595. value_entry->b_type = sym_k_horizontal_integer_value;
  3596. break;
  3597. case vertical_integer_arg_type:
  3598. value_entry->b_type = sym_k_vertical_integer_value;
  3599. break;
  3600. case horizontal_float_arg_type:
  3601. value_entry->b_type = sym_k_horizontal_float_value;
  3602. break;
  3603. case vertical_float_arg_type:
  3604. value_entry->b_type = sym_k_vertical_float_value;
  3605. break;
  3606. case keysym_arg_type:
  3607. value_entry->b_type = sym_k_keysym_value;
  3608. break;
  3609. case char_arg_type:
  3610. case lstr_arg_type:
  3611. value_entry->b_type = sym_k_char_8_value;
  3612. break;
  3613. case cstr_arg_type:
  3614. value_entry->b_type = sym_k_compound_string_value;
  3615. break;
  3616. case wcstr_arg_type:
  3617. value_entry->b_type = sym_k_wchar_string_value;
  3618. break;
  3619. case font_arg_type:
  3620. value_entry->b_type = sym_k_font_value;
  3621. break;
  3622. case fontset_arg_type:
  3623. value_entry->b_type = sym_k_fontset_value;
  3624. break;
  3625. case color_arg_type:
  3626. value_entry->b_type = sym_k_color_value;
  3627. break;
  3628. /* Begin fixing CR 5429 */
  3629. case classrec_arg_type:
  3630. value_entry->b_type = sym_k_class_rec_name_value;
  3631. break;
  3632. /* End fixing CR 5429 */
  3633. case xbitmap_arg_type:
  3634. value_entry->b_type = sym_k_xbitmapfile_value;
  3635. break;
  3636. case reason_arg_type:
  3637. value_entry->b_type = sym_k_reason_value;
  3638. break;
  3639. case argument_arg_type:
  3640. value_entry->b_type = sym_k_argument_value;
  3641. break;
  3642. case font_table_arg_type:
  3643. value_entry->b_type = sym_k_font_table_value;
  3644. break;
  3645. case error_arg_type:
  3646. value_entry->b_type = sym_k_error_value;
  3647. break;
  3648. default:
  3649. _assert( FALSE, "unexpected type" );
  3650. }
  3651. /*
  3652. ** indicate that this expression has been evaluated
  3653. */
  3654. value_entry->b_aux_flags |= sym_m_exp_eval;
  3655. in_expr = FALSE;
  3656. return value_entry;
  3657. /*
  3658. ** Point where errors are transferred
  3659. */
  3660. error_occurred:
  3661. diag_issue_diagnostic
  3662. ( d_out_range,
  3663. _sar_source_pos2( value_entry ),
  3664. value_text[ res_type ],
  3665. ""
  3666. );
  3667. res_type = error_arg_type;
  3668. diag_reset_overflow_handler();
  3669. goto continue_after_error;
  3670. }
  3671. int validate_arg( operand_entry, operator)
  3672. sym_value_entry_type *operand_entry;
  3673. int operator;
  3674. {
  3675. char operand_type;
  3676. operand_type = operand_entry->b_type;
  3677. if (operand_type == sym_k_error_value )
  3678. return error_arg_type;
  3679. if ((( 1 << operand_type ) & legal_operand_type[ operator ]) == 0)
  3680. {
  3681. diag_issue_diagnostic
  3682. ( d_operand_type,
  3683. _sar_source_pos2( operand_entry ),
  3684. diag_value_text( operand_type ),
  3685. operator_symbol[ operator ]
  3686. );
  3687. return error_arg_type;
  3688. }
  3689. if ((operand_entry->obj_header.b_flags & sym_m_imported) != 0)
  3690. {
  3691. sym_value_entry_type *value_entry;
  3692. value_entry = operand_entry;
  3693. diag_issue_diagnostic
  3694. ( d_nonpvt,
  3695. _sar_source_pos2( operand_entry ),
  3696. value_entry->obj_header.az_name->c_text
  3697. );
  3698. return error_arg_type;
  3699. }
  3700. switch (operand_type)
  3701. {
  3702. case sym_k_bool_value:
  3703. return boolean_arg_type;
  3704. case sym_k_integer_value:
  3705. return integer_arg_type;
  3706. case sym_k_float_value:
  3707. return float_arg_type;
  3708. case sym_k_single_float_value:
  3709. return single_float_arg_type;
  3710. case sym_k_horizontal_integer_value:
  3711. return horizontal_integer_arg_type;
  3712. case sym_k_vertical_integer_value:
  3713. return vertical_integer_arg_type;
  3714. case sym_k_horizontal_float_value:
  3715. return horizontal_float_arg_type;
  3716. case sym_k_vertical_float_value:
  3717. return vertical_float_arg_type;
  3718. case sym_k_char_8_value:
  3719. return char_arg_type;
  3720. case sym_k_compound_string_value:
  3721. return cstr_arg_type;
  3722. case sym_k_localized_string_value:
  3723. return lstr_arg_type;
  3724. case sym_k_wchar_string_value:
  3725. return wcstr_arg_type;
  3726. case sym_k_font_value:
  3727. return font_arg_type;
  3728. case sym_k_fontset_value:
  3729. return fontset_arg_type;
  3730. case sym_k_color_value:
  3731. return color_arg_type;
  3732. default:
  3733. return error_arg_type;
  3734. }
  3735. }
  3736. /*
  3737. **++
  3738. ** FUNCTIONAL DESCRIPTION:
  3739. **
  3740. ** This function converts a value to floating point.
  3741. **
  3742. ** FORMAL PARAMETERS:
  3743. **
  3744. ** operand_entry frame of the value to convert
  3745. ** data_value data structure to hold float result
  3746. **
  3747. ** IMPLICIT INPUTS:
  3748. **
  3749. ** none
  3750. **
  3751. ** IMPLICIT OUTPUTS:
  3752. **
  3753. ** none
  3754. **
  3755. ** FUNCTION VALUE:
  3756. **
  3757. ** float_arg_type if operation succeeds
  3758. ** error_arg_type if operation fails
  3759. **
  3760. ** SIDE EFFECTS:
  3761. **
  3762. ** none
  3763. **
  3764. **--
  3765. **/
  3766. int sem_convert_to_float(operand_entry, data_value)
  3767. sym_value_entry_type *operand_entry;
  3768. data_value_type *data_value;
  3769. {
  3770. switch (operand_entry->b_type)
  3771. {
  3772. case sym_k_error_value:
  3773. return error_arg_type;
  3774. case sym_k_integer_value:
  3775. case sym_k_horizontal_integer_value:
  3776. case sym_k_vertical_integer_value:
  3777. case sym_k_bool_value:
  3778. data_value->real_value = operand_entry->value.l_integer;
  3779. return float_arg_type;
  3780. case sym_k_single_float_value: /* single float data type RAP */
  3781. data_value->real_value = operand_entry->value.single_float;
  3782. return float_arg_type;
  3783. case sym_k_float_value:
  3784. case sym_k_horizontal_float_value:
  3785. case sym_k_vertical_float_value:
  3786. data_value->real_value = operand_entry->value.d_real;
  3787. return float_arg_type;
  3788. default:
  3789. _assert( FALSE, "unexpected operand type" );
  3790. }
  3791. return error_arg_type;
  3792. }
  3793. /*
  3794. **++
  3795. ** FUNCTIONAL DESCRIPTION:
  3796. **
  3797. ** This function converts a value to type integer
  3798. **
  3799. ** FORMAL PARAMETERS:
  3800. **
  3801. ** operand_entry frame of the value to convert
  3802. ** data_value data structure to hold integer result
  3803. **
  3804. ** IMPLICIT INPUTS:
  3805. **
  3806. ** none
  3807. **
  3808. ** IMPLICIT OUTPUTS:
  3809. **
  3810. ** none
  3811. **
  3812. ** FUNCTION VALUE:
  3813. **
  3814. ** integer_arg_type if operation succeeds
  3815. ** error_arg_type if operation fails
  3816. **
  3817. ** SIDE EFFECTS:
  3818. **
  3819. ** none
  3820. **
  3821. **--
  3822. **/
  3823. int sem_convert_to_integer(operand_entry, data_value)
  3824. sym_value_entry_type *operand_entry;
  3825. data_value_type *data_value;
  3826. {
  3827. int res_type;
  3828. uil_az_error_env_valid = TRUE;
  3829. if (setjmp(uil_az_error_env_block) == 0 )
  3830. {
  3831. switch (operand_entry->b_type)
  3832. {
  3833. case sym_k_error_value:
  3834. res_type = error_arg_type;
  3835. break;
  3836. case sym_k_integer_value:
  3837. case sym_k_horizontal_integer_value:
  3838. case sym_k_vertical_integer_value:
  3839. case sym_k_bool_value:
  3840. data_value->integer_value = operand_entry->value.l_integer;
  3841. res_type = integer_arg_type;
  3842. break;
  3843. case sym_k_float_value:
  3844. case sym_k_horizontal_float_value:
  3845. case sym_k_vertical_float_value:
  3846. data_value->integer_value = operand_entry->value.d_real;
  3847. res_type = integer_arg_type;
  3848. break;
  3849. case sym_k_single_float_value: /* single float data type RAP */
  3850. data_value->integer_value =
  3851. (int) operand_entry->value.single_float;
  3852. res_type = integer_arg_type;
  3853. break;
  3854. default:
  3855. _assert( FALSE, "unexpected operand type" );
  3856. }
  3857. uil_az_error_env_valid = FALSE;
  3858. return res_type;
  3859. }
  3860. else
  3861. {
  3862. diag_issue_diagnostic
  3863. ( d_out_range,
  3864. _sar_source_pos2( operand_entry ),
  3865. value_text[ integer_arg_type ],
  3866. ""
  3867. );
  3868. diag_reset_overflow_handler();
  3869. uil_az_error_env_valid = FALSE;
  3870. return error_arg_type;
  3871. }
  3872. }
  3873. /*
  3874. **++
  3875. ** FUNCTIONAL DESCRIPTION:
  3876. **
  3877. ** This function converts a value to single floating point.
  3878. ** (RAP single float data type)
  3879. **
  3880. ** FORMAL PARAMETERS:
  3881. **
  3882. ** operand_entry symbol table entry of the value to convert
  3883. ** data_value data structure to hold float result
  3884. **
  3885. ** IMPLICIT INPUTS:
  3886. **
  3887. ** none
  3888. **
  3889. ** IMPLICIT OUTPUTS:
  3890. **
  3891. ** none
  3892. **
  3893. ** FUNCTION VALUE:
  3894. **
  3895. ** single_float_arg_type if operation succeeds
  3896. ** error_arg_type if operation fails
  3897. **
  3898. ** SIDE EFFECTS:
  3899. **
  3900. ** none
  3901. **
  3902. **--
  3903. **/
  3904. int sem_convert_to_single_float(operand_entry, data_value)
  3905. sym_value_entry_type *operand_entry;
  3906. data_value_type *data_value;
  3907. {
  3908. switch (operand_entry->b_type)
  3909. {
  3910. case sym_k_error_value:
  3911. return error_arg_type;
  3912. case sym_k_integer_value:
  3913. case sym_k_horizontal_integer_value:
  3914. case sym_k_vertical_integer_value:
  3915. case sym_k_bool_value:
  3916. data_value->single_float_value = (float)operand_entry->value.l_integer;
  3917. return single_float_arg_type;
  3918. case sym_k_float_value:
  3919. case sym_k_horizontal_float_value:
  3920. case sym_k_vertical_float_value:
  3921. data_value->single_float_value = (float)operand_entry->value.d_real;
  3922. return single_float_arg_type;
  3923. default:
  3924. _assert( FALSE, "unexpected operand type" );
  3925. }
  3926. return error_arg_type;
  3927. }
  3928. /*
  3929. **++
  3930. ** FUNCTIONAL DESCRIPTION:
  3931. **
  3932. ** This function converts a value to an error - just needed to
  3933. ** fill a slot in the conversion table.
  3934. **
  3935. ** FORMAL PARAMETERS:
  3936. **
  3937. ** operand_entry frame of the value to convert
  3938. ** data_value not used
  3939. **
  3940. ** IMPLICIT INPUTS:
  3941. **
  3942. ** none
  3943. **
  3944. ** IMPLICIT OUTPUTS:
  3945. **
  3946. ** none
  3947. **
  3948. ** FUNCTION VALUE:
  3949. **
  3950. ** error_arg_type
  3951. **
  3952. ** SIDE EFFECTS:
  3953. **
  3954. ** none
  3955. **
  3956. **--
  3957. **/
  3958. int sem_convert_to_error(operand_entry, data_value)
  3959. sym_value_entry_type *operand_entry;
  3960. data_value_type *data_value;
  3961. {
  3962. return error_arg_type;
  3963. }
  3964. /*
  3965. **++
  3966. ** FUNCTIONAL DESCRIPTION:
  3967. **
  3968. ** This function processes the concatenation of 2 strings.
  3969. **
  3970. ** FORMAL PARAMETERS:
  3971. **
  3972. ** operator_entry [in/out] pointer to resultant value stack frame
  3973. ** op1_entry [in] pointer to operand 1 value frame
  3974. ** op2_entry [in] pointer to operand 2 value frame
  3975. **
  3976. ** IMPLICIT INPUTS:
  3977. **
  3978. ** none
  3979. **
  3980. ** IMPLICIT OUTPUTS:
  3981. **
  3982. ** none
  3983. **
  3984. ** FUNCTION VALUE:
  3985. **
  3986. ** void
  3987. **
  3988. ** SIDE EFFECTS:
  3989. **
  3990. ** error message is issued if value is out of range
  3991. **
  3992. **--
  3993. **/
  3994. void sar_cat_value_entry( target_entry, op1_entry, op2_entry )
  3995. sym_value_entry_type **target_entry;
  3996. sym_value_entry_type *op1_entry;
  3997. sym_value_entry_type *op2_entry;
  3998. {
  3999. /*
  4000. ** For pcc conversion, use defines instead of this enum.
  4001. **
  4002. ** enum op_state
  4003. ** {
  4004. ** error=0, simple, compound,
  4005. ** };
  4006. */
  4007. #define k_op_state_error 0
  4008. #define k_op_state_simple 1
  4009. #define k_op_state_compound 2
  4010. #define k_op_state_localized 4
  4011. int target_type;
  4012. sym_value_entry_type *value1_entry;
  4013. sym_value_entry_type *value2_entry;
  4014. unsigned int op1_state;
  4015. unsigned int op2_state;
  4016. /*
  4017. ** The target type is dependent on the type of the sources. If both
  4018. ** operands are primitive and have the same writing direction and
  4019. ** charset, the result is still of that type. If both operands are
  4020. ** localized strings, the result is a localized string. If not, the result
  4021. ** is a compound string.
  4022. */
  4023. switch (op1_entry->b_type)
  4024. {
  4025. case sym_k_char_8_value:
  4026. op1_state = k_op_state_simple;
  4027. break;
  4028. case sym_k_compound_string_value:
  4029. op1_state = k_op_state_compound;
  4030. break;
  4031. case sym_k_localized_string_value:
  4032. op1_state = k_op_state_localized;
  4033. break;
  4034. case sym_k_error_value:
  4035. op1_state = k_op_state_error;
  4036. break;
  4037. default:
  4038. diag_issue_diagnostic
  4039. ( d_wrong_type,
  4040. _sar_source_pos2( op1_entry ),
  4041. diag_value_text( op1_entry->b_type),
  4042. "string or compound string" );
  4043. op1_state = k_op_state_error;
  4044. }
  4045. switch (op2_entry->b_type)
  4046. {
  4047. case sym_k_char_8_value:
  4048. op2_state = k_op_state_simple;
  4049. break;
  4050. case sym_k_compound_string_value:
  4051. op2_state = k_op_state_compound;
  4052. break;
  4053. case sym_k_localized_string_value:
  4054. op2_state = k_op_state_localized;
  4055. break;
  4056. case sym_k_error_value:
  4057. op2_state = k_op_state_error;
  4058. break;
  4059. default:
  4060. diag_issue_diagnostic
  4061. ( d_wrong_type,
  4062. _sar_source_pos2( op2_entry ),
  4063. diag_value_text( op2_entry->b_type),
  4064. "string or compound string" );
  4065. op2_state = k_op_state_error;
  4066. }
  4067. value1_entry = op1_entry;
  4068. value2_entry = op2_entry;
  4069. /*
  4070. ** Verify that both operands are private values
  4071. */
  4072. /* Begin fixing OSF CR 5509 */
  4073. if ((op1_entry->obj_header.b_flags & (sym_m_private|sym_m_exported)) == 0)
  4074. {
  4075. op1_state = k_op_state_error;
  4076. diag_issue_diagnostic
  4077. (d_nonpvt,
  4078. _sar_source_pos2 (op1_entry),
  4079. value1_entry->obj_header.az_name->c_text );
  4080. }
  4081. if ((op2_entry->obj_header.b_flags & (sym_m_private|sym_m_exported)) == 0)
  4082. {
  4083. op2_state = k_op_state_error;
  4084. diag_issue_diagnostic
  4085. (d_nonpvt,
  4086. _sar_source_pos2 (op2_entry),
  4087. value2_entry->obj_header.az_name->c_text );
  4088. }
  4089. /* End fixing OSF CR 5509 */
  4090. switch (op1_state + (op2_state<<3))
  4091. {
  4092. /*
  4093. ** This is the case of appending two simple strings or a simple string
  4094. ** and a localized string. Just append them
  4095. ** unless they have different directions or the first one has the separate
  4096. ** attribute.
  4097. */
  4098. case k_op_state_simple + (k_op_state_simple<<3):
  4099. case k_op_state_simple + (k_op_state_localized<<3):
  4100. case k_op_state_localized + (k_op_state_simple<<3):
  4101. if ((value1_entry->b_charset == value2_entry->b_charset)
  4102. &&
  4103. ((value1_entry->b_direction) == (value2_entry->b_direction))
  4104. &&
  4105. ((value1_entry->b_aux_flags & sym_m_separate) == 0))
  4106. {
  4107. *target_entry = (sym_value_entry_type *)
  4108. sem_cat_str_to_str
  4109. (value1_entry, FALSE,
  4110. value2_entry, FALSE);
  4111. target_type = sym_k_char_8_value;
  4112. }
  4113. else
  4114. {
  4115. *target_entry = (sym_value_entry_type *) sem_create_cstr( );
  4116. sem_append_str_to_cstr
  4117. (*target_entry,
  4118. value1_entry, FALSE);
  4119. sem_append_str_to_cstr
  4120. (*target_entry,
  4121. value2_entry, FALSE);
  4122. sem_evaluate_value_cs(*target_entry);
  4123. target_type = sym_k_compound_string_value;
  4124. }
  4125. break;
  4126. /*
  4127. ** This is the case of one simple/localized and one compound string.
  4128. ** Change the
  4129. ** simple/localized to a compound and append them together. Depend on
  4130. ** the append
  4131. ** routine to do the right thing.
  4132. */
  4133. case k_op_state_simple + (k_op_state_compound<<3):
  4134. case k_op_state_localized + (k_op_state_compound<<3):
  4135. *target_entry = (sym_value_entry_type *) sem_create_cstr( );
  4136. sem_append_str_to_cstr
  4137. (*target_entry,
  4138. value1_entry, FALSE);
  4139. sem_evaluate_value_cs(*target_entry);
  4140. /*
  4141. * We must evaluate both entries to the XmStringConcat routine so
  4142. * that it will work properly. However this MAY be a pointer to
  4143. * a compound string, use that value instead or we will concat a
  4144. * NULL value and lose part of the string.
  4145. */
  4146. if ((value2_entry->az_first_table_value == NULL) &&
  4147. (value2_entry->value.xms_value == NULL))
  4148. value2_entry->value.xms_value =
  4149. value2_entry->az_exp_op1->value.xms_value;
  4150. else
  4151. sem_evaluate_value_cs(value2_entry);
  4152. (*target_entry)->value.xms_value =
  4153. XmStringConcat((*target_entry)->value.xms_value,
  4154. value2_entry->value.xms_value);
  4155. target_type = sym_k_compound_string_value;
  4156. break;
  4157. /*
  4158. ** This is the case of one simple/localized and one compound string.
  4159. ** Append the simple/localized to the compound.
  4160. */
  4161. case k_op_state_compound + (k_op_state_simple<<3):
  4162. case k_op_state_compound + (k_op_state_localized<<3):
  4163. *target_entry = (sym_value_entry_type *) sem_create_cstr( );
  4164. sem_append_str_to_cstr
  4165. (*target_entry,
  4166. value2_entry, FALSE);
  4167. sem_evaluate_value_cs (*target_entry);
  4168. /*
  4169. * We must evaluate both entries to the XmStringConcat routine so
  4170. * that it will work properly. However this MAY be a pointer to
  4171. * a compound string, use that value instead or we will concat a
  4172. * NULL value and lose part of the string.
  4173. */
  4174. if ((value1_entry->az_first_table_value == NULL) &&
  4175. (value1_entry->value.xms_value == NULL))
  4176. value1_entry->value.xms_value =
  4177. value1_entry->az_exp_op1->value.xms_value;
  4178. else
  4179. sem_evaluate_value_cs(value1_entry);
  4180. (*target_entry)->value.xms_value =
  4181. XmStringConcat (value1_entry->value.xms_value,
  4182. (*target_entry)->value.xms_value);
  4183. target_type = sym_k_compound_string_value;
  4184. break;
  4185. /*
  4186. ** This is the case of two compound strings. Just let the append routine
  4187. ** do the right thing.
  4188. */
  4189. case k_op_state_compound + (k_op_state_compound<<3):
  4190. *target_entry = (sym_value_entry_type *) sem_create_cstr( );
  4191. /*
  4192. * We must evaluate both entries to the XmStringConcat routine so
  4193. * that it will work properly. However this MAY be a pointer to
  4194. * a compound string, use that value instead or we will concat a
  4195. * NULL value and lose part of the string.
  4196. */
  4197. if ((value1_entry->az_first_table_value == NULL) &&
  4198. (value1_entry->value.xms_value == NULL))
  4199. value1_entry->value.xms_value =
  4200. value1_entry->az_exp_op1->value.xms_value;
  4201. else
  4202. sem_evaluate_value_cs(value1_entry);
  4203. if ((value2_entry->az_first_table_value == NULL) &&
  4204. (value2_entry->value.xms_value == NULL))
  4205. value2_entry->value.xms_value =
  4206. value2_entry->az_exp_op1->value.xms_value;
  4207. else
  4208. sem_evaluate_value_cs(value2_entry);
  4209. (*target_entry)->value.xms_value =
  4210. XmStringConcat(value1_entry->value.xms_value,
  4211. value2_entry->value.xms_value);
  4212. target_type = sym_k_compound_string_value;
  4213. break;
  4214. /*
  4215. ** This is the case of two localized strings. Just concatenate them.
  4216. */
  4217. case k_op_state_localized + (k_op_state_localized<<3):
  4218. *target_entry = (sym_value_entry_type *)
  4219. sem_cat_str_to_str
  4220. (value1_entry, FALSE,
  4221. value2_entry, FALSE);
  4222. target_type = sym_k_localized_string_value;
  4223. default: /* some form of error */
  4224. target_type = sym_k_error_value;
  4225. *target_entry = (sym_value_entry_type *) sym_az_error_value_entry;
  4226. break;
  4227. }
  4228. }