UilSarVal.c 92 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870
  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: UilSarVal.c /main/13 1997/12/06 16:14:16 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 supports values in UIL. UIL values are
  49. ** quite primitive in terms of operators, however, there is a
  50. ** concept of a private value that is local to this module
  51. ** and a imported or exported value which needs to be
  52. ** resolved via a lookup at runtime. The runtime resolved values
  53. ** cannot be modified with operators.
  54. **
  55. **--
  56. **/
  57. /*
  58. **
  59. ** INCLUDE FILES
  60. **
  61. **/
  62. #include <Xm/Xm.h>
  63. #include "UilDefI.h"
  64. #include "UilSymGen.h" /* For sym_k_[TRUE|FALSE]_enumval */
  65. /*
  66. **
  67. ** TABLE OF CONTENTS
  68. **
  69. **/
  70. /*
  71. ** FORWARD DECLARATIONS
  72. */
  73. static sym_value_entry_type *standard_color_table _ARGUMENTS(( void ));
  74. /*
  75. **
  76. ** DEFINE and MACRO DEFINITIONS
  77. **
  78. **/
  79. #define clear_class_mask \
  80. (~(sym_m_private | sym_m_imported | sym_m_exported | sym_m_builtin))
  81. /*
  82. **
  83. ** EXTERNAL VARIABLE DECLARATIONS
  84. **
  85. **/
  86. extern yystype yylval;
  87. /*
  88. **
  89. ** GLOBAL VARIABLE DECLARATIONS
  90. **
  91. **/
  92. /*
  93. **
  94. ** OWN VARIABLE DECLARATIONS
  95. **
  96. **/
  97. /*
  98. **++
  99. ** FUNCTIONAL DESCRIPTION:
  100. **
  101. ** This function takes a non-reserved keyword and makes a name
  102. ** entry for it. In the context in which the keyword is used,
  103. ** it is not being used as a keyword.
  104. **
  105. ** FORMAL PARAMETERS:
  106. **
  107. ** target_frame pointer to resultant token stack frame
  108. ** keyword_frame pointer to token stack frame holding the keyword
  109. **
  110. ** IMPLICIT INPUTS:
  111. **
  112. ** none
  113. **
  114. ** IMPLICIT OUTPUTS:
  115. **
  116. ** none
  117. **
  118. ** FUNCTION VALUE:
  119. **
  120. ** void
  121. **
  122. ** SIDE EFFECTS:
  123. **
  124. ** a name entry is generated
  125. **
  126. **--
  127. **/
  128. void sar_map_keyword_to_name( target_frame, keyword_frame )
  129. yystype *target_frame;
  130. yystype *keyword_frame;
  131. {
  132. sym_name_entry_type *name_entry;
  133. _assert( keyword_frame->b_tag == sar_k_token_frame,
  134. "keyword frame missing from stack" );
  135. /*
  136. ** make the target frame a token frame for a name token
  137. */
  138. _sar_move_source_info( target_frame, keyword_frame );
  139. target_frame->b_tag = sar_k_token_frame;
  140. target_frame->b_type = NAME;
  141. /*
  142. ** insert the keyword name into the symbol table
  143. */
  144. name_entry =
  145. sym_insert_name
  146. ( keyword_frame->value.az_keyword_entry->b_length,
  147. keyword_frame->value.az_keyword_entry->at_name );
  148. target_frame->value.az_symbol_entry = (sym_entry_type *) name_entry;
  149. }
  150. /*
  151. **++
  152. ** FUNCTIONAL DESCRIPTION:
  153. **
  154. ** This function processes an id that is being used as an operand
  155. ** in a value. It can be either a value or an identifier.
  156. **
  157. ** FORMAL PARAMETERS:
  158. **
  159. ** target_frame pointer to resultant value stack frame
  160. ** id_frame pointer to token stack frame holding the id
  161. **
  162. ** IMPLICIT INPUTS:
  163. **
  164. ** none
  165. **
  166. ** IMPLICIT OUTPUTS:
  167. **
  168. ** none
  169. **
  170. ** FUNCTION VALUE:
  171. **
  172. ** void
  173. **
  174. ** SIDE EFFECTS:
  175. **
  176. ** error may be issued for undefined name
  177. **
  178. **--
  179. **/
  180. void sar_process_id( target_frame, id_frame )
  181. yystype *target_frame;
  182. yystype *id_frame;
  183. {
  184. sym_name_entry_type *name_entry;
  185. sym_value_entry_type *value_entry;
  186. int enum_code;
  187. _assert( id_frame->b_tag == sar_k_token_frame,
  188. "id frame missing from stack" );
  189. /*
  190. ** make the target frame an expression frame
  191. */
  192. _sar_move_source_info( target_frame, id_frame );
  193. target_frame->b_tag = sar_k_value_frame;
  194. /* id frame may be a:
  195. ** font_name, color_name, reason_name, argument_name...
  196. ** name
  197. ** if the font_name, color_name, etc... has a name been defined by
  198. ** the user, we use that name, otherwise these special names are
  199. ** treated as private values.
  200. */
  201. if (id_frame->b_type != NAME)
  202. {
  203. name_entry =
  204. sym_find_name
  205. ( id_frame->value.az_keyword_entry->b_length,
  206. id_frame->value.az_keyword_entry->at_name );
  207. if (name_entry == NULL)
  208. {
  209. int source_type;
  210. unsigned short int arg_code;
  211. unsigned short int rel_code;
  212. switch (id_frame->b_type)
  213. {
  214. case FONT_NAME:
  215. source_type = sym_k_font_value;
  216. break;
  217. case CHILD_NAME:
  218. source_type = sym_k_child_value;
  219. break;
  220. case ARGUMENT_NAME:
  221. source_type = sym_k_argument_value;
  222. /*
  223. ** Indicate that this argument is used so we can later
  224. ** generate appropriate compression code for it.
  225. ** If this argument has a related argument, also mark it as
  226. ** being used so we can later generate its comprssion code.
  227. */
  228. arg_code = id_frame->value.az_keyword_entry->b_subclass;
  229. uil_arg_compr[arg_code] = 1;
  230. rel_code = related_argument_table[arg_code];
  231. if (rel_code != 0)
  232. uil_arg_compr[rel_code] = 1;
  233. break;
  234. case COLOR_NAME:
  235. source_type = sym_k_color_value;
  236. break;
  237. case REASON_NAME:
  238. source_type = sym_k_reason_value;
  239. uil_reas_compr[id_frame->value.az_keyword_entry->b_subclass]
  240. = 1;
  241. break;
  242. case ENUMVAL_NAME:
  243. source_type = sym_k_integer_value;
  244. enum_code = id_frame->value.az_keyword_entry->b_subclass;
  245. break;
  246. default:
  247. _assert( FALSE, "unexpected token" );
  248. }
  249. value_entry =
  250. sem_create_value_entry
  251. ( (char*)&(id_frame->value.az_keyword_entry), sizeof(long),
  252. source_type );
  253. if ( id_frame->b_type == ENUMVAL_NAME )
  254. {
  255. value_entry->b_enumeration_value_code = enum_code;
  256. _assert (( (enum_code > 0) && (enum_code <= uil_max_enumval) ),
  257. "Enumeration code out of range");
  258. value_entry->value.l_integer =
  259. enumval_values_table[enum_code];
  260. }
  261. target_frame->b_flags = value_entry->obj_header.b_flags;
  262. target_frame->b_type = value_entry->b_type;
  263. target_frame->value.az_symbol_entry =
  264. (sym_entry_type *) value_entry;
  265. return;
  266. }
  267. id_frame->value.az_symbol_entry = (sym_entry_type *) name_entry;
  268. }
  269. /*
  270. ** first check if the name entry points to a value.
  271. ** If the value_entry is NULL, this is a forward reference.
  272. */
  273. name_entry = (sym_name_entry_type *) id_frame->value.az_symbol_entry;
  274. value_entry = (sym_value_entry_type *) name_entry->az_object;
  275. if (value_entry == NULL)
  276. {
  277. value_entry = sem_create_value_entry ("0", 0, sym_k_any_value);
  278. value_entry->obj_header.b_flags = sym_m_forward_ref;
  279. value_entry->obj_header.az_name = name_entry;
  280. target_frame->b_flags = value_entry->obj_header.b_flags;
  281. target_frame->b_type = value_entry->b_type;
  282. target_frame->value.az_symbol_entry = (sym_entry_type *) value_entry;
  283. return;
  284. }
  285. if (value_entry->header.b_tag != sym_k_value_entry &&
  286. value_entry->header.b_tag != sym_k_widget_entry)
  287. {
  288. diag_issue_diagnostic
  289. ( d_ctx_req,
  290. _sar_source_position( id_frame ),
  291. diag_tag_text( sym_k_value_entry ),
  292. diag_tag_text( value_entry->header.b_tag ) );
  293. goto error_path;
  294. }
  295. /*
  296. ** set up the target frame
  297. */
  298. target_frame->b_flags = value_entry->obj_header.b_flags;
  299. target_frame->b_type = value_entry->b_type;
  300. target_frame->value.az_symbol_entry = (sym_entry_type *) value_entry;
  301. return;
  302. error_path:
  303. target_frame->b_flags = sym_m_private;
  304. target_frame->b_type = sym_k_error_value;
  305. target_frame->value.az_symbol_entry =
  306. (sym_entry_type *) sym_az_error_value_entry;
  307. }
  308. /*
  309. **++
  310. ** FUNCTIONAL DESCRIPTION:
  311. **
  312. ** This function checks an identifier and makes a name
  313. ** entry for it if it is not already a name.
  314. **
  315. ** FORMAL PARAMETERS:
  316. **
  317. ** id_frame pointer to token stack frame holding the identifier
  318. **
  319. ** IMPLICIT INPUTS:
  320. **
  321. ** none
  322. **
  323. ** IMPLICIT OUTPUTS:
  324. **
  325. ** none
  326. **
  327. ** FUNCTION VALUE:
  328. **
  329. ** void
  330. **
  331. ** SIDE EFFECTS:
  332. **
  333. ** a name entry may be generated
  334. **
  335. **--
  336. **/
  337. void sar_process_id_ref ( id_frame )
  338. yystype * id_frame;
  339. {
  340. _assert( id_frame->b_tag == sar_k_token_frame,
  341. "id frame missing from stack" );
  342. switch (id_frame->b_type) {
  343. /*
  344. ** if already a name, then do nothing.
  345. */
  346. case NAME:
  347. return;
  348. /*
  349. ** make the keyword into a name and insert it into the symbol table
  350. */
  351. case FONT_NAME:
  352. case ARGUMENT_NAME:
  353. case COLOR_NAME:
  354. case REASON_NAME:
  355. case CHILD_NAME:
  356. id_frame->b_type = NAME;
  357. id_frame->value.az_symbol_entry =
  358. (sym_entry_type *) sym_insert_name (
  359. id_frame->value.az_keyword_entry->b_length,
  360. id_frame->value.az_keyword_entry->at_name );
  361. break;
  362. default:
  363. _assert( FALSE, "unexpected token" );
  364. break;
  365. }
  366. }
  367. /*
  368. **++
  369. ** FUNCTIONAL DESCRIPTION:
  370. **
  371. ** This function takes a parse frame, extracts the string for the token
  372. ** out of it and converts the string into a units type.
  373. **
  374. ** FORMAL PARAMETERS:
  375. **
  376. ** parse_frame pointer to parse stack frame holding the value
  377. **
  378. ** IMPLICIT INPUTS:
  379. **
  380. ** none
  381. **
  382. ** IMPLICIT OUTPUTS:
  383. **
  384. ** none
  385. **
  386. ** FUNCTION VALUE:
  387. **
  388. ** void
  389. **
  390. ** SIDE EFFECTS:
  391. **
  392. **
  393. **
  394. **--
  395. **/
  396. int sar_get_units_type ( parse_frame )
  397. yystype *parse_frame;
  398. {
  399. char *units_name;
  400. int units_type;
  401. XmParseResult result;
  402. units_name = parse_frame->value.az_keyword_entry->at_name;
  403. result = XmeParseUnits(units_name, &units_type);
  404. switch(result)
  405. {
  406. case XmPARSE_ERROR:
  407. /* I don't expect a parse error since the UIL compiler knows what
  408. the valid unit strings are. */
  409. units_type = XmPIXELS;
  410. break;
  411. case XmPARSE_NO_UNITS:
  412. /* For now, just set the units to XmPIXELS when none specified.
  413. What we really need is to be able to specify that there were
  414. no units and therefore no conversion should be done. We can
  415. sort of do that by specifying XmPIXELS here. */
  416. units_type = XmPIXELS;
  417. break;
  418. case XmPARSE_UNITS_OK:
  419. /* Everything is groovy */
  420. break;
  421. }
  422. return(units_type);
  423. }
  424. /*
  425. **++
  426. ** FUNCTIONAL DESCRIPTION:
  427. **
  428. ** This function takes a token frame for a value and converts it
  429. ** into a value frame.
  430. **
  431. ** FORMAL PARAMETERS:
  432. **
  433. ** value_frame pointer to resultant value stack frame
  434. ** token_frame pointer to token stack frame holding the value
  435. ** value_type type of value being created
  436. ** keyword_frame frame to use as locator for the value
  437. ** arg_type type of argument value being created - for args only
  438. **
  439. ** IMPLICIT INPUTS:
  440. **
  441. ** none
  442. **
  443. ** IMPLICIT OUTPUTS:
  444. **
  445. ** none
  446. **
  447. ** FUNCTION VALUE:
  448. **
  449. ** void
  450. **
  451. ** SIDE EFFECTS:
  452. **
  453. **
  454. **
  455. **--
  456. **/
  457. void sar_make_private_value
  458. ( value_frame, token_frame, value_type, keyword_frame, arg_type )
  459. yystype *value_frame;
  460. yystype *token_frame;
  461. int value_type;
  462. yystype *keyword_frame;
  463. int arg_type;
  464. {
  465. sym_value_entry_type *value_entry;
  466. /*
  467. ** This should be a long because the call to sem_create_value_entry passes the sizeof(long). This also
  468. ** maps on top of value.l_integer which is a long and is used in sar_chk_comp_str_attr.
  469. */
  470. long boolean_value;
  471. /* Empty string tables and translation tables can have a null token frame. */
  472. _assert( (token_frame->b_tag == sar_k_token_frame) ||
  473. (token_frame->b_tag == sar_k_value_frame) ||
  474. (token_frame->b_tag == sar_k_null_frame),
  475. "token or value frame missing from stack" );
  476. /*
  477. ** The goal of the routine is to create a value entry in the
  478. ** symbol table for each constant and then place a pointer to
  479. ** that value entry in a value frame on the parse stack.
  480. ** Based on the type of constant, it may or may not already be
  481. ** in the symbol table.
  482. */
  483. switch (value_type)
  484. {
  485. case sym_k_char_8_value:
  486. case sym_k_compound_string_value:
  487. case sym_k_integer_value:
  488. case sym_k_float_value:
  489. case sym_k_single_float_value:
  490. case sym_k_localized_string_value:
  491. value_entry =
  492. (sym_value_entry_type *) token_frame->value.az_symbol_entry;
  493. /* Save the arg_type. This value should be zero for all cases above,
  494. except when the integer or float has units specified. In that case,
  495. the arg_type is used to store the type of units specified. */
  496. value_entry->b_arg_type = arg_type;
  497. value_entry->b_type = value_type;
  498. break;
  499. case sym_k_font_value:
  500. case sym_k_fontset_value:
  501. case sym_k_reason_value:
  502. case sym_k_argument_value:
  503. case sym_k_xbitmapfile_value:
  504. case sym_k_keysym_value:
  505. case sym_k_class_rec_name_value:
  506. /*
  507. ** transform the char 8 value entry into one for this
  508. ** special type. Before doing this, we need to insure
  509. ** that the char 8 value is not in error or non private.
  510. */
  511. value_entry =
  512. (sym_value_entry_type *) token_frame->value.az_symbol_entry;
  513. if (token_frame->b_type == sym_k_error_value)
  514. {
  515. value_type = sym_k_error_value;
  516. }
  517. else
  518. {
  519. sym_value_entry_type *value_save;
  520. value_save = value_entry;
  521. if ((value_entry->obj_header.az_name != NULL) ||
  522. (token_frame->b_type == sym_k_any_value))
  523. {
  524. value_entry =
  525. sem_create_value_entry ("",0,sym_k_any_value);
  526. value_entry->b_expr_opr = sym_k_coerce_op;
  527. if ((token_frame -> b_flags & sym_m_forward_ref) != 0)
  528. sym_make_value_forward_ref (token_frame,
  529. (char*)&(value_entry->az_exp_op1), sym_k_patch_add);
  530. else
  531. value_entry->az_exp_op1 = value_save;
  532. }
  533. value_entry->b_type = value_type;
  534. value_entry->obj_header.b_flags = sym_m_private;
  535. /* save the arg type for arguments */
  536. if (value_type == sym_k_argument_value)
  537. value_entry->b_arg_type = arg_type;
  538. }
  539. break;
  540. case sym_k_bool_value:
  541. boolean_value = 0;
  542. if ((token_frame->b_type == UILTRUE) ||
  543. (token_frame->b_type == ON ))
  544. boolean_value = 1;
  545. value_entry =
  546. sem_create_value_entry
  547. ( (char*)&boolean_value, sizeof(long), sym_k_bool_value );
  548. break;
  549. case sym_k_integer_table_value:
  550. case sym_k_asciz_table_value:
  551. case sym_k_trans_table_value:
  552. case sym_k_string_table_value:
  553. case sym_k_rgb_value:
  554. {
  555. int count;
  556. sym_value_entry_type * table_entry;
  557. /* Save the pointer to the table elements */
  558. table_entry =
  559. (sym_value_entry_type *) token_frame->value.az_symbol_entry;
  560. value_entry =
  561. sem_create_value_entry
  562. (0, 0, value_type );
  563. value_entry->az_first_table_value = table_entry;
  564. /* Get the count of elements in the table. Resets table_entry */
  565. for (table_entry=value_entry->az_first_table_value,
  566. count = 0;
  567. table_entry != NULL;
  568. table_entry = table_entry->az_next_table_value,
  569. count++) {
  570. }
  571. value_entry->b_table_count = count;
  572. break;
  573. }
  574. default:
  575. _assert( FALSE, "unexpected value type" );
  576. break;
  577. }
  578. /*
  579. ** make the target frame a value frame
  580. */
  581. _sar_move_source_info( value_frame, keyword_frame );
  582. value_frame->b_tag = sar_k_value_frame;
  583. value_frame->b_type = value_type;
  584. value_frame->b_flags = value_entry->obj_header.b_flags;
  585. value_frame->value.az_symbol_entry = (sym_entry_type *) value_entry;
  586. }
  587. void sar_make_rgb_private_value
  588. ( value_frame, token_frame, value_type, keyword_frame, arg_type )
  589. yystype *value_frame;
  590. yystype *token_frame;
  591. int value_type;
  592. yystype *keyword_frame;
  593. int arg_type;
  594. {
  595. /* placeholder RAP for RGB data type */
  596. }
  597. /*
  598. **++
  599. ** FUNCTIONAL DESCRIPTION:
  600. **
  601. ** This function takes a value frame which is the contents
  602. ** of a table of strings and appends it to a value entry which is
  603. ** the next entry in that table. It is used by string_table, icon,
  604. ** and translation_table value types.
  605. **
  606. ** FORMAL PARAMETERS:
  607. **
  608. ** value_frame pointer to current table entry stack frame
  609. ** table_frame pointer to stack frame holding the table
  610. ** table_type dictates the type of table being generated
  611. **
  612. ** IMPLICIT INPUTS:
  613. **
  614. ** none
  615. **
  616. ** IMPLICIT OUTPUTS:
  617. **
  618. ** none
  619. **
  620. ** FUNCTION VALUE:
  621. **
  622. ** void
  623. **
  624. ** SIDE EFFECTS:
  625. **
  626. **
  627. **
  628. **--
  629. **/
  630. void sar_append_table_value( value_frame, table_frame, table_type, comma_frame )
  631. yystype *value_frame;
  632. yystype *table_frame;
  633. int table_type;
  634. yystype *comma_frame;
  635. {
  636. sym_value_entry_type *value_entry, *table_entry;
  637. int value_type;
  638. _assert( (value_frame->b_tag == sar_k_value_frame),
  639. "value frame missing from stack" );
  640. value_entry = (sym_value_entry_type *) value_frame->value.az_symbol_entry;
  641. value_type = value_entry->b_type;
  642. if (value_type == sym_k_error_value) return;
  643. table_entry = (sym_value_entry_type *) table_frame->value.az_symbol_entry;
  644. /*
  645. ** Some entries require checking for a forward reference. If the
  646. ** table entry is named, than a valref entry linked to it is placed
  647. ** in the table. If the new entry is a forward reference, than a
  648. ** valref is always required, but we can use the value node which
  649. ** is supplied as it is a parser artifact, and has no other use.
  650. */
  651. switch (table_type)
  652. {
  653. case sym_k_icon_value:
  654. if ((value_frame->b_flags & sym_m_forward_ref) != 0)
  655. {
  656. diag_issue_diagnostic
  657. (d_undefined,
  658. _sar_source_position(value_frame),
  659. "icon row",
  660. value_entry->obj_header.az_name->c_text);
  661. }
  662. if (value_entry->obj_header.az_name != NULL)
  663. {
  664. sym_value_entry_type *value_save;
  665. value_save = value_entry;
  666. value_entry = sem_create_value_entry (0, 0, value_type);
  667. value_entry->b_type = value_type;
  668. value_entry->obj_header.b_flags = sym_m_private;
  669. value_entry->b_expr_opr = sym_k_valref_op;
  670. value_entry->az_exp_op1 = value_save;
  671. }
  672. break;
  673. case sym_k_trans_table_value:
  674. case sym_k_asciz_table_value:
  675. case sym_k_integer_table_value:
  676. case sym_k_rgb_value:
  677. if (value_entry->obj_header.az_name != NULL)
  678. {
  679. sym_value_entry_type *value_save;
  680. if ( (value_frame->b_flags & sym_m_forward_ref) != 0)
  681. {
  682. value_entry->obj_header.b_flags = sym_m_private;
  683. value_entry->b_expr_opr = sym_k_valref_op;
  684. sym_make_value_forward_ref
  685. (value_frame,
  686. (char*)&(value_entry->az_exp_op1),
  687. sym_k_patch_add);
  688. }
  689. else
  690. {
  691. value_save = value_entry;
  692. value_entry = sem_create_value_entry (0, 0, value_type);
  693. value_entry->b_type = value_type;
  694. value_entry->obj_header.b_flags = sym_m_private;
  695. value_entry->b_expr_opr = sym_k_valref_op;
  696. value_entry->az_exp_op1 = value_save;
  697. }
  698. }
  699. break;
  700. case sym_k_string_table_value:
  701. /*
  702. ** value needs to be a compound string, so a coerce operator is
  703. ** inserted as required. We don't need both a coerce and a
  704. ** valref entry; if coerce is applied to a name, it also
  705. ** functions as the valref.
  706. */
  707. if (value_entry->obj_header.az_name != NULL)
  708. {
  709. sym_value_entry_type *value_save;
  710. if ( (value_frame->b_flags & sym_m_forward_ref) != 0)
  711. {
  712. value_entry->obj_header.b_flags = sym_m_private;
  713. value_entry->b_type = sym_k_compound_string_value;
  714. value_entry->b_expr_opr = sym_k_coerce_op;
  715. sym_make_value_forward_ref
  716. (value_frame,
  717. (char*)&(value_entry->az_exp_op1),
  718. sym_k_patch_add);
  719. }
  720. else
  721. {
  722. value_save = value_entry;
  723. value_entry = sem_create_value_entry (0, 0, value_type);
  724. value_entry->obj_header.b_flags = sym_m_private;
  725. value_entry->b_type = sym_k_compound_string_value;
  726. value_entry->az_exp_op1 = value_save;
  727. if ( value_type == sym_k_compound_string_value )
  728. value_entry->b_expr_opr = sym_k_valref_op;
  729. else
  730. value_entry->b_expr_opr = sym_k_coerce_op;
  731. }
  732. }
  733. break;
  734. default:
  735. _assert ( FALSE, "unknown table type found");
  736. }
  737. /*
  738. ** Prepend the value to the table. The table elements will be
  739. ** in reverse order.
  740. */
  741. value_entry->b_aux_flags |= sym_m_table_entry;
  742. value_entry->az_next_table_value = table_entry;
  743. /*
  744. ** Save source information
  745. */
  746. _sar_save_source_info ( &value_entry->header, comma_frame, value_frame);
  747. value_entry->header.b_type = value_frame->b_source_pos;
  748. /*
  749. ** make the target frame a value frame
  750. */
  751. value_frame->b_tag = sar_k_value_frame;
  752. value_frame->b_type = value_type;
  753. value_frame->b_flags = value_entry->obj_header.b_flags;
  754. value_frame->value.az_symbol_entry = (sym_entry_type *) value_entry;
  755. }
  756. /*
  757. **++
  758. ** FUNCTIONAL DESCRIPTION:
  759. **
  760. ** This function issues an error message saying that a feature is
  761. ** not implemented yet.
  762. **
  763. ** FORMAL PARAMETERS:
  764. **
  765. ** value_frame pointer to resultant value stack frame
  766. ** token_frame pointer to source token frame (error position info)
  767. ** error_text pointer to text to be substituted in message
  768. **
  769. ** IMPLICIT INPUTS:
  770. **
  771. ** none
  772. **
  773. ** IMPLICIT OUTPUTS:
  774. **
  775. ** none
  776. **
  777. ** FUNCTION VALUE:
  778. **
  779. ** void
  780. **
  781. ** SIDE EFFECTS:
  782. **
  783. ** error message is issued
  784. **
  785. **--
  786. **/
  787. void sar_value_not_implemented( value_frame, token_frame, error_text )
  788. yystype *value_frame;
  789. yystype *token_frame;
  790. char *error_text;
  791. {
  792. /*
  793. ** make the target frame an error value frame
  794. */
  795. _sar_move_source_info( value_frame, token_frame );
  796. value_frame->b_tag = sar_k_value_frame;
  797. value_frame->b_type = sym_k_error_value;
  798. value_frame->b_flags = sym_m_private;
  799. value_frame->value.az_symbol_entry =
  800. (sym_entry_type *) sym_az_error_value_entry;
  801. diag_issue_diagnostic
  802. ( d_not_impl,
  803. _sar_source_position( value_frame ),
  804. error_text );
  805. }
  806. /*
  807. **++
  808. ** FUNCTIONAL DESCRIPTION:
  809. **
  810. ** This function processes the concatenation of 2 strings.
  811. **
  812. ** FORMAL PARAMETERS:
  813. **
  814. ** operator_frame [in/out] pointer to resultant value stack frame
  815. ** op1_frame [in] pointer to operand 1 value frame
  816. ** op2_frame [in] pointer to operand 2 value frame
  817. **
  818. ** IMPLICIT INPUTS:
  819. **
  820. ** none
  821. **
  822. ** IMPLICIT OUTPUTS:
  823. **
  824. ** none
  825. **
  826. ** FUNCTION VALUE:
  827. **
  828. ** void
  829. **
  830. ** SIDE EFFECTS:
  831. **
  832. ** error message is issued if value is out of range
  833. **
  834. **--
  835. **/
  836. void sar_cat_value( operator_frame, op1_frame, op2_frame )
  837. yystype *operator_frame;
  838. yystype *op1_frame;
  839. yystype *op2_frame;
  840. {
  841. /*
  842. ** For pcc conversion, use defines instead of this enum.
  843. **
  844. ** enum op_state
  845. ** {
  846. ** error=0, simple, compound, localized
  847. ** };
  848. */
  849. #define k_op_state_error 0
  850. #define k_op_state_simple 1
  851. #define k_op_state_compound 2
  852. #define k_op_state_localized 4
  853. int target_type;
  854. sym_value_entry_type *value1_entry;
  855. sym_value_entry_type *value2_entry;
  856. sym_value_entry_type *target_entry;
  857. unsigned int op1_state;
  858. unsigned int op2_state;
  859. _assert( (op1_frame->b_tag == sar_k_value_frame) &&
  860. (op2_frame->b_tag == sar_k_value_frame), "value frame missing" );
  861. /*
  862. ** The target type is dependent on the type of the sources. If both
  863. ** operands are primitive and have the same writing direction and
  864. ** charset, the result is still of that type. If not, the result
  865. ** is a compound string.
  866. */
  867. switch (op1_frame->b_type)
  868. {
  869. case sym_k_char_8_value:
  870. op1_state = k_op_state_simple;
  871. break;
  872. case sym_k_compound_string_value:
  873. op1_state = k_op_state_compound;
  874. break;
  875. case sym_k_localized_string_value:
  876. op1_state = k_op_state_localized;
  877. break;
  878. case sym_k_error_value:
  879. op1_state = k_op_state_error;
  880. break;
  881. default:
  882. diag_issue_diagnostic
  883. (d_wrong_type,
  884. _sar_source_position( op1_frame ),
  885. diag_value_text( op1_frame->b_type),
  886. "string or compound string");
  887. op1_state = k_op_state_error;
  888. }
  889. switch (op2_frame->b_type)
  890. {
  891. case sym_k_char_8_value:
  892. op2_state = k_op_state_simple;
  893. break;
  894. case sym_k_compound_string_value:
  895. op2_state = k_op_state_compound;
  896. break;
  897. case sym_k_localized_string_value:
  898. op2_state = k_op_state_localized;
  899. break;
  900. case sym_k_error_value:
  901. op2_state = k_op_state_error;
  902. break;
  903. default:
  904. diag_issue_diagnostic
  905. (d_wrong_type,
  906. _sar_source_position( op2_frame ),
  907. diag_value_text( op2_frame->b_type),
  908. "string or compound string");
  909. op2_state = k_op_state_error;
  910. }
  911. value1_entry = (sym_value_entry_type *) op1_frame->value.az_symbol_entry;
  912. value2_entry = (sym_value_entry_type *) op2_frame->value.az_symbol_entry;
  913. /*
  914. ** Verify that both operands are private values
  915. */
  916. if ((op1_frame->b_flags & sym_m_private) == 0)
  917. {
  918. op1_state = k_op_state_error;
  919. diag_issue_diagnostic
  920. (d_nonpvt,
  921. _sar_source_position (op1_frame),
  922. value1_entry->obj_header.az_name->c_text );
  923. }
  924. if ((op2_frame->b_flags & sym_m_private) == 0)
  925. {
  926. op2_state = k_op_state_error;
  927. diag_issue_diagnostic
  928. (d_nonpvt,
  929. _sar_source_position (op2_frame),
  930. value2_entry->obj_header.az_name->c_text );
  931. }
  932. switch (op1_state + (op2_state<<2))
  933. {
  934. /*
  935. ** This is the case of appending to simple strings. Just append them
  936. ** unless they have different directions or the first one has the separate
  937. ** attribute.
  938. */
  939. case k_op_state_simple + (k_op_state_simple<<2):
  940. if ((value1_entry->b_charset == value2_entry->b_charset)
  941. &&
  942. ((value1_entry->b_direction) == (value2_entry->b_direction))
  943. &&
  944. ((value1_entry->b_aux_flags & sym_m_separate) == 0))
  945. {
  946. target_entry = (sym_value_entry_type *)
  947. sem_cat_str_to_str
  948. (value1_entry, (value1_entry->obj_header.az_name==NULL),
  949. value2_entry, (value2_entry->obj_header.az_name==NULL));
  950. target_type = sym_k_char_8_value;
  951. }
  952. else
  953. {
  954. target_entry = (sym_value_entry_type *) sem_create_cstr( );
  955. sem_append_str_to_cstr
  956. (target_entry,
  957. value1_entry, (value1_entry->obj_header.az_name==NULL));
  958. sem_append_str_to_cstr
  959. (target_entry,
  960. value2_entry, (value2_entry->obj_header.az_name==NULL));
  961. target_type = sym_k_compound_string_value;
  962. }
  963. break;
  964. /*
  965. ** This is the case of one simple and one compound string. Change the
  966. ** simple to a compound and append them together. Depend on the append
  967. ** routine to do the right thing.
  968. */
  969. case k_op_state_simple + (k_op_state_compound<<2):
  970. target_entry = (sym_value_entry_type *) sem_create_cstr( );
  971. sem_append_str_to_cstr
  972. (target_entry,
  973. value1_entry, (value1_entry->obj_header.az_name==NULL));
  974. sem_append_cstr_to_cstr
  975. (target_entry,
  976. value2_entry, (value2_entry->obj_header.az_name==NULL));
  977. target_type = sym_k_compound_string_value;
  978. break;
  979. /*
  980. ** This is the case of one simple and one compound string. Append the
  981. ** simple to the compound. Depend on the append routine to do the right
  982. ** thing.
  983. */
  984. case k_op_state_compound + (k_op_state_simple<<2):
  985. target_entry = (sym_value_entry_type *) sem_create_cstr( );
  986. sem_append_cstr_to_cstr
  987. (target_entry,
  988. value1_entry, (value1_entry->obj_header.az_name==NULL));
  989. sem_append_str_to_cstr
  990. (target_entry,
  991. value2_entry, (value2_entry->obj_header.az_name==NULL));
  992. target_type = sym_k_compound_string_value;
  993. break;
  994. /*
  995. ** This is the case of two compound strings. Just let the append routine
  996. ** do the right thing.
  997. */
  998. case k_op_state_compound + (k_op_state_compound<<2):
  999. target_entry = (sym_value_entry_type *) sem_create_cstr( );
  1000. sem_append_cstr_to_cstr
  1001. (target_entry,
  1002. value1_entry, (value1_entry->obj_header.az_name==NULL));
  1003. sem_append_cstr_to_cstr
  1004. (target_entry,
  1005. value2_entry, (value2_entry->obj_header.az_name==NULL));
  1006. target_type = sym_k_compound_string_value;
  1007. break;
  1008. default: /* some form of error */
  1009. target_type = sym_k_error_value;
  1010. target_entry = (sym_value_entry_type *) sym_az_error_value_entry;
  1011. break;
  1012. }
  1013. /*
  1014. ** initialize the target frame
  1015. */
  1016. _sar_save_source_pos ( &target_entry->header, op2_frame);
  1017. /* target_entry->az_source_rec = op2_frame->az_source_record; */
  1018. operator_frame->b_tag = sar_k_value_frame;
  1019. operator_frame->b_type = target_type;
  1020. operator_frame->b_flags = sym_m_private;
  1021. operator_frame->value.az_symbol_entry = (sym_entry_type *) target_entry;
  1022. }
  1023. /*
  1024. **++
  1025. ** FUNCTIONAL DESCRIPTION:
  1026. **
  1027. ** This function checks the attributes of COMPOUND_STRING function.
  1028. **
  1029. ** FORMAL PARAMETERS:
  1030. **
  1031. ** target_frame pointer to resultant token stack frame
  1032. ** value_frame pointer to frame holding keyword and value
  1033. ** prior_value_frame pointer to previous properties
  1034. **
  1035. ** IMPLICIT INPUTS:
  1036. **
  1037. ** none
  1038. **
  1039. ** IMPLICIT OUTPUTS:
  1040. **
  1041. ** none
  1042. **
  1043. ** FUNCTION VALUE:
  1044. **
  1045. ** void
  1046. **
  1047. ** SIDE EFFECTS:
  1048. **
  1049. ** attribute information is stuffed in target frame
  1050. **
  1051. **--
  1052. **/
  1053. void sar_chk_comp_str_attr( target_frame, value_frame, prior_value_frame )
  1054. yystype *target_frame;
  1055. yystype *value_frame;
  1056. yystype *prior_value_frame;
  1057. {
  1058. sym_value_entry_type *value_entry;
  1059. /*
  1060. ** Set up not specified values in the target frame.
  1061. ** b_type will hold the writing direction and separate propertied
  1062. ** az_symbol_entry will hold the pointer to the character set.
  1063. */
  1064. switch (prior_value_frame->b_tag)
  1065. {
  1066. case sar_k_null_frame:
  1067. /*
  1068. ** no prior values
  1069. */
  1070. target_frame->b_tag = sar_k_token_frame;
  1071. target_frame->b_direction = NOSTRING_DIRECTION;
  1072. /* Fix for CN 16149 (DTS 10023) part 3 -- flag b_charset as non-existent */
  1073. target_frame->b_charset = sym_k_error_charset;
  1074. target_frame->b_type = 0;
  1075. target_frame->value.az_symbol_entry = NULL;
  1076. break;
  1077. case sar_k_token_frame:
  1078. case sar_k_value_frame:
  1079. /*
  1080. ** prior values - transfer them
  1081. */
  1082. target_frame->b_tag = sar_k_token_frame;
  1083. target_frame->b_direction = prior_value_frame->b_direction;
  1084. target_frame->b_charset = prior_value_frame->b_charset;
  1085. target_frame->b_type = prior_value_frame->b_type;
  1086. target_frame->value.az_symbol_entry =
  1087. target_frame->value.az_symbol_entry;
  1088. break;
  1089. default:
  1090. _assert( FALSE, "prior value frame missing from stack" );
  1091. }
  1092. /*
  1093. ** Case on the keyword for the attribute given
  1094. */
  1095. value_entry =
  1096. (sym_value_entry_type *) value_frame->value.az_symbol_entry;
  1097. if ((value_entry != NULL) && (value_frame->b_type != CHARACTER_SET) &&
  1098. (value_entry->obj_header.b_flags & sym_m_forward_ref) != 0)
  1099. {
  1100. diag_issue_diagnostic
  1101. (d_undefined,
  1102. _sar_source_position(value_frame),
  1103. "compound string attribute",
  1104. value_entry->obj_header.az_name->c_text);
  1105. }
  1106. switch (value_frame->b_type)
  1107. {
  1108. case RIGHT_TO_LEFT:
  1109. {
  1110. /*
  1111. ** If the value is a boolean, then set the b_direction field.
  1112. */
  1113. if (value_entry->b_type == sym_k_bool_value)
  1114. if (value_entry->value.l_integer == TRUE)
  1115. target_frame->b_direction = XmSTRING_DIRECTION_R_TO_L;
  1116. else
  1117. target_frame->b_direction = XmSTRING_DIRECTION_L_TO_R;
  1118. break;
  1119. }
  1120. case SEPARATE:
  1121. {
  1122. /*
  1123. ** If the value is a boolean, then just set the corresponding mask
  1124. ** accordingly.
  1125. */
  1126. if (value_entry->b_type == sym_k_bool_value)
  1127. if (value_entry->value.l_integer == TRUE)
  1128. target_frame->b_type |= sym_m_separate;
  1129. else
  1130. target_frame->b_type &= ~sym_m_separate;
  1131. break;
  1132. }
  1133. case CHARACTER_SET:
  1134. {
  1135. /*
  1136. ** There are two different kinds of character sets. One is a
  1137. ** token frame, the other is a value frame which points to a
  1138. ** char8 string value in the symbol table that represents the charset.
  1139. */
  1140. switch (value_frame->b_tag)
  1141. {
  1142. /*
  1143. ** For token frames, acquire the charset from the keytable entry
  1144. ** and set frame type so sar_make_comp_str knows how to interpret
  1145. ** the frame.
  1146. */
  1147. case sar_k_token_frame:
  1148. {
  1149. key_keytable_entry_type *keyword_entry;
  1150. keyword_entry = (key_keytable_entry_type *)
  1151. value_frame->value.az_keyword_entry;
  1152. target_frame->b_tag = sar_k_token_frame;
  1153. target_frame->b_charset =
  1154. sem_map_subclass_to_charset( keyword_entry->b_subclass );
  1155. break;
  1156. }
  1157. /*
  1158. ** For value frames, save the value pointer and mark the
  1159. ** frame again for correct use by sar_make_comp_str.
  1160. */
  1161. case sar_k_value_frame:
  1162. target_frame->b_tag = sar_k_value_frame;
  1163. target_frame->value.az_symbol_entry =
  1164. value_frame->value.az_symbol_entry;
  1165. break;
  1166. }
  1167. break;
  1168. }
  1169. default:
  1170. _assert( FALSE, "keyword missing from stack" );
  1171. }
  1172. }
  1173. /*
  1174. **++
  1175. ** FUNCTIONAL DESCRIPTION:
  1176. **
  1177. ** This function makes a COMPOUND_STRING and sets the properties
  1178. ** of the string.
  1179. **
  1180. ** FORMAL PARAMETERS:
  1181. **
  1182. ** target_frame pointer to resultant token stack frame
  1183. ** value_frame pointer to string value
  1184. ** attr_frame pointer to strings attributes
  1185. ** keyword_frame frame to use as locator for result
  1186. **
  1187. ** IMPLICIT INPUTS:
  1188. **
  1189. ** none
  1190. **
  1191. ** IMPLICIT OUTPUTS:
  1192. **
  1193. ** none
  1194. **
  1195. ** FUNCTION VALUE:
  1196. **
  1197. ** void
  1198. **
  1199. ** SIDE EFFECTS:
  1200. **
  1201. ** none
  1202. **
  1203. **--
  1204. **/
  1205. void sar_make_comp_str
  1206. ( target_frame, value_frame, attr_frame, keyword_frame )
  1207. yystype *target_frame;
  1208. yystype *value_frame;
  1209. yystype *attr_frame;
  1210. yystype *keyword_frame;
  1211. {
  1212. sym_value_entry_type *value_entry;
  1213. sym_value_entry_type *cstr_entry;
  1214. _assert( value_frame->b_tag == sar_k_value_frame,
  1215. "value frame missing from stack" );
  1216. /*
  1217. ** Make a compound string operation. The compound string will be created
  1218. ** during expression evaluation in UilSemVal.c.
  1219. */
  1220. cstr_entry = (sym_value_entry_type *) sem_create_cstr();
  1221. cstr_entry->b_expr_opr = sym_k_comp_str_op;
  1222. if ((value_frame->b_flags & sym_m_forward_ref) != 0)
  1223. sym_make_value_forward_ref (value_frame,
  1224. (char*)&(cstr_entry->az_exp_op1), sym_k_patch_add);
  1225. else
  1226. {
  1227. value_entry =
  1228. (sym_value_entry_type *) value_frame->value.az_symbol_entry;
  1229. cstr_entry->az_exp_op1 = value_entry;
  1230. }
  1231. /*
  1232. ** If the attr_frame is not null, it must be a value frame with contains
  1233. ** a pointer to the value entry for the userdefined charset, or a token frame
  1234. ** which contains the charset token subclass.
  1235. */
  1236. switch (attr_frame->b_tag)
  1237. {
  1238. case sar_k_value_frame:
  1239. /*
  1240. ** Set the attributes of the string, as specified by the options
  1241. ** to the COMPOUND_STRING function, without disturbing any
  1242. ** existing bits.
  1243. */
  1244. cstr_entry->b_direction = attr_frame->b_direction;
  1245. cstr_entry->b_aux_flags |= (attr_frame->b_type & sym_m_separate);
  1246. /*
  1247. ** If the symbol_entry pointer is not null then a charset was
  1248. ** specified for this CS, just copy the b_charset and
  1249. ** az_charset_value pointers into the value entry for this CS.
  1250. */
  1251. if ((attr_frame->value.az_symbol_entry) != 0)
  1252. {
  1253. sym_value_entry_type * az_value_entry;
  1254. az_value_entry = (sym_value_entry_type *)
  1255. attr_frame->value.az_symbol_entry;
  1256. cstr_entry->b_charset = az_value_entry->b_charset;
  1257. cstr_entry->b_direction = az_value_entry->b_direction;
  1258. cstr_entry->az_charset_value =
  1259. az_value_entry;
  1260. }
  1261. break;
  1262. case sar_k_token_frame:
  1263. if ((attr_frame->b_charset) != 0)
  1264. cstr_entry->b_charset =
  1265. sem_map_subclass_to_charset (attr_frame->b_charset);
  1266. cstr_entry->b_direction = attr_frame->b_direction;
  1267. cstr_entry->b_aux_flags |= (attr_frame->b_type & sym_m_separate);
  1268. break;
  1269. }
  1270. /*
  1271. ** initialize the target frame
  1272. */
  1273. _sar_move_source_info( target_frame, keyword_frame );
  1274. _sar_save_source_pos ( &cstr_entry->header, value_frame );
  1275. /* cstr_entry->az_source_rec = value_frame->az_source_record; */
  1276. target_frame->b_tag = sar_k_value_frame;
  1277. target_frame->b_type = sym_k_compound_string_value;
  1278. target_frame->b_flags = sym_m_private;
  1279. target_frame->value.az_symbol_entry =
  1280. (sym_entry_type *) cstr_entry;
  1281. }
  1282. /*
  1283. **++
  1284. ** FUNCTIONAL DESCRIPTION:
  1285. **
  1286. ** This function makes a COMPOUND_STRING_COMPONENT and sets the properties
  1287. ** of the string.
  1288. **
  1289. ** FORMAL PARAMETERS:
  1290. **
  1291. ** target_frame pointer to resultant token stack frame
  1292. ** type_frame pointer to type value
  1293. ** value_frame pointer to component value
  1294. ** keyword_frame frame to use as locator for result
  1295. **
  1296. ** IMPLICIT INPUTS:
  1297. **
  1298. ** none
  1299. **
  1300. ** IMPLICIT OUTPUTS:
  1301. **
  1302. ** none
  1303. **
  1304. ** FUNCTION VALUE:
  1305. **
  1306. ** void
  1307. **
  1308. ** SIDE EFFECTS:
  1309. **
  1310. ** none
  1311. **
  1312. **--
  1313. **/
  1314. void sar_make_comp_str_comp
  1315. ( target_frame, type_frame, value_frame, keyword_frame )
  1316. yystype *target_frame;
  1317. yystype *type_frame;
  1318. yystype *value_frame;
  1319. yystype *keyword_frame;
  1320. {
  1321. key_keytable_entry_type *type_entry;
  1322. key_keytable_entry_type *value_entry;
  1323. sym_value_entry_type *cstr_entry;
  1324. unsigned short int enumval_code;
  1325. unsigned short int enumset_code;
  1326. unsigned short int type;
  1327. char *cset_name;
  1328. int i;
  1329. Boolean found;
  1330. String str;
  1331. XmStringDirection dir;
  1332. XmDirection lay_dir;
  1333. XmString cstr_r = NULL;
  1334. _assert(type_frame->b_tag == sar_k_token_frame,
  1335. "value frame missing from stack" );
  1336. /*
  1337. ** Make a compound string component.
  1338. */
  1339. cstr_entry = (sym_value_entry_type *) sem_create_cstr();
  1340. /* Evaluate type. */
  1341. type_entry = (key_keytable_entry_type *)type_frame->value.az_keyword_entry;
  1342. enumval_code = type_entry->b_subclass;
  1343. enumset_code = argument_enumset_table[sym_k_XmStringComponent_arg];
  1344. found = FALSE;
  1345. for (i = 0; i < enum_set_table[enumset_code].values_cnt; i++)
  1346. if (enum_set_table[enumset_code].values[i] == enumval_code)
  1347. {
  1348. found = TRUE;
  1349. break;
  1350. }
  1351. if (found) type = enumval_values_table[enumval_code];
  1352. else
  1353. {
  1354. diag_issue_diagnostic(d_arg_type,
  1355. _sar_source_position(type_frame),
  1356. uil_enumval_names[enumval_code],
  1357. "compound_string_component",
  1358. "XmStringComponentType");
  1359. type = XmSTRING_COMPONENT_UNKNOWN;
  1360. }
  1361. switch (type)
  1362. {
  1363. case XmSTRING_COMPONENT_UNKNOWN:
  1364. case XmSTRING_COMPONENT_SEPARATOR:
  1365. case XmSTRING_COMPONENT_LAYOUT_POP:
  1366. case XmSTRING_COMPONENT_TAB:
  1367. /* If value_frame is not null, issue diagnostic. */
  1368. if (value_frame->b_tag != sar_k_null_frame)
  1369. diag_issue_diagnostic(d_arg_type,
  1370. _sar_source_position(value_frame),
  1371. "non-NULL",
  1372. "compound_string_component",
  1373. "NULL");
  1374. cstr_r = XmStringComponentCreate(type, 0, NULL);
  1375. break;
  1376. case XmSTRING_COMPONENT_LOCALE:
  1377. if ((value_frame->b_tag != sar_k_null_frame) &&
  1378. (value_frame->b_type != CHARSET_NAME))
  1379. diag_issue_diagnostic(d_arg_type,
  1380. _sar_source_position(value_frame),
  1381. "non-NULL",
  1382. "compound_string_component",
  1383. "NULL or _MOTIF_DEFAULT_LOCALE");
  1384. else if (value_frame->b_type == CHARSET_NAME)
  1385. {
  1386. cset_name =
  1387. sem_charset_name((value_frame->value.az_keyword_entry)->b_subclass,
  1388. (sym_value_entry_type *)
  1389. (value_frame->value.az_keyword_entry));
  1390. if (strcmp(cset_name, "_MOTIF_DEFAULT_LOCALE") != 0)
  1391. diag_issue_diagnostic(d_arg_type,
  1392. _sar_source_position(value_frame),
  1393. cset_name,
  1394. "compound_string_component",
  1395. "_MOTIF_DEFAULT_LOCALE");
  1396. }
  1397. cstr_r = XmStringComponentCreate(type, strlen(_MOTIF_DEFAULT_LOCALE),
  1398. _MOTIF_DEFAULT_LOCALE);
  1399. break;
  1400. case XmSTRING_COMPONENT_CHARSET:
  1401. case XmSTRING_COMPONENT_TEXT:
  1402. case XmSTRING_COMPONENT_LOCALE_TEXT:
  1403. case XmSTRING_COMPONENT_WIDECHAR_TEXT:
  1404. case XmSTRING_COMPONENT_RENDITION_BEGIN:
  1405. case XmSTRING_COMPONENT_RENDITION_END:
  1406. str = "";
  1407. if (value_frame->b_tag == sar_k_null_frame)
  1408. diag_issue_diagnostic(d_arg_type,
  1409. type_frame->az_source_record,
  1410. type_frame->b_source_end,
  1411. "NULL",
  1412. "compound_string_component",
  1413. diag_value_text(sym_k_char_8_value));
  1414. else if ((value_frame->b_type != CHAR_8_LITERAL) &&
  1415. (value_frame->b_type != LOC_STRING) &&
  1416. ((value_frame->b_type != CHARSET_NAME) ||
  1417. (type != XmSTRING_COMPONENT_CHARSET)))
  1418. diag_issue_diagnostic(d_arg_type,
  1419. _sar_source_position(value_frame),
  1420. tok_token_name_table[value_frame->b_type],
  1421. "compound_string_component",
  1422. diag_value_text(sym_k_char_8_value));
  1423. else
  1424. {
  1425. if (value_frame->b_type == CHARSET_NAME)
  1426. {
  1427. cset_name =
  1428. sem_charset_name((value_frame->value.az_keyword_entry)->b_subclass,
  1429. (sym_value_entry_type *)
  1430. (value_frame->value.az_keyword_entry));
  1431. if (strcmp(cset_name, "XmFONTLIST_DEFAULT_TAG") == 0)
  1432. str = XmFONTLIST_DEFAULT_TAG;
  1433. else str = cset_name;
  1434. }
  1435. else
  1436. /* Extract string */
  1437. str = ((sym_value_entry_type *)
  1438. (value_frame->value.az_symbol_entry))->value.c_value;
  1439. }
  1440. cstr_r = XmStringComponentCreate(type, strlen(str), (XtPointer)str);
  1441. break;
  1442. case XmSTRING_COMPONENT_DIRECTION:
  1443. if (value_frame->b_tag == sar_k_null_frame)
  1444. diag_issue_diagnostic(d_arg_type,
  1445. type_frame->az_source_record,
  1446. type_frame->b_source_end,
  1447. "NULL",
  1448. "compound_string_component",
  1449. "XmStringDirection");
  1450. else if (value_frame->b_type != ENUMVAL_NAME)
  1451. diag_issue_diagnostic(d_arg_type,
  1452. _sar_source_position(value_frame),
  1453. diag_value_text(value_frame->b_type),
  1454. "compound_string_component",
  1455. "XmStringDirection");
  1456. else
  1457. {
  1458. /* Extract and validate enumval */
  1459. value_entry = (key_keytable_entry_type *)value_frame->value.az_keyword_entry;
  1460. enumval_code = value_entry->b_subclass;
  1461. enumset_code = argument_enumset_table[sym_k_XmNstringDirection_arg];
  1462. found = FALSE;
  1463. for (i = 0; i < enum_set_table[enumset_code].values_cnt; i++)
  1464. if (enum_set_table[enumset_code].values[i] == enumval_code)
  1465. {
  1466. found = TRUE;
  1467. break;
  1468. }
  1469. if (found) dir = enumval_values_table[enumval_code];
  1470. else
  1471. {
  1472. diag_issue_diagnostic(d_arg_type,
  1473. _sar_source_position(value_frame),
  1474. uil_enumval_names[enumval_code],
  1475. "compound_string_component",
  1476. "XmStringDirection");
  1477. dir = XmSTRING_DIRECTION_L_TO_R;
  1478. }
  1479. }
  1480. cstr_r = XmStringComponentCreate(type, sizeof(XmStringDirection), &dir);
  1481. break;
  1482. case XmSTRING_COMPONENT_LAYOUT_PUSH:
  1483. if (value_frame->b_tag == sar_k_null_frame)
  1484. diag_issue_diagnostic(d_arg_type,
  1485. type_frame->az_source_record,
  1486. type_frame->b_source_end,
  1487. "NULL",
  1488. "compound_string_component",
  1489. "XmDirection");
  1490. else if (value_frame->b_type != ENUMVAL_NAME)
  1491. diag_issue_diagnostic(d_arg_type,
  1492. _sar_source_position(value_frame),
  1493. diag_value_text(value_frame->b_type),
  1494. "compound_string_component",
  1495. "XmDirection");
  1496. else
  1497. {
  1498. /* Extract and validate enumval */
  1499. value_entry = (key_keytable_entry_type *)value_frame->value.az_keyword_entry;
  1500. enumval_code = value_entry->b_subclass;
  1501. enumset_code = argument_enumset_table[sym_k_XmNlayoutDirection_arg];
  1502. found = FALSE;
  1503. for (i = 0; i < enum_set_table[enumset_code].values_cnt; i++)
  1504. if (enum_set_table[enumset_code].values[i] == enumval_code)
  1505. {
  1506. found = TRUE;
  1507. break;
  1508. }
  1509. if (found) lay_dir = enumval_values_table[enumval_code];
  1510. else
  1511. {
  1512. diag_issue_diagnostic(d_arg_type,
  1513. _sar_source_position(value_frame),
  1514. uil_enumval_names[enumval_code],
  1515. "compound_string_component",
  1516. "XmDirection");
  1517. lay_dir = XmLEFT_TO_RIGHT;
  1518. }
  1519. }
  1520. cstr_r = XmStringComponentCreate(type, sizeof(XmDirection), &lay_dir);
  1521. break;
  1522. }
  1523. cstr_entry->value.xms_value = cstr_r;
  1524. cstr_entry->w_length = XmStringLength(cstr_r);
  1525. cstr_entry->az_first_table_value = NULL;
  1526. _assert(cstr_entry->w_length <= MrmMaxResourceSize, "compound string too long" );
  1527. /*
  1528. ** initialize the target frame
  1529. */
  1530. _sar_move_source_info( target_frame, keyword_frame );
  1531. _sar_save_source_pos ( &cstr_entry->header, type_frame );
  1532. target_frame->b_tag = sar_k_value_frame;
  1533. target_frame->b_type = sym_k_compound_string_value;
  1534. target_frame->b_flags = sym_m_private;
  1535. target_frame->value.az_symbol_entry = (sym_entry_type *)cstr_entry;
  1536. }
  1537. /*
  1538. **++
  1539. ** FUNCTIONAL DESCRIPTION:
  1540. **
  1541. ** This function makes a WIDE_CHARACTER and sets the properties
  1542. ** of the string.
  1543. **
  1544. ** FORMAL PARAMETERS:
  1545. **
  1546. ** target_frame pointer to resultant token stack frame
  1547. ** value_frame pointer to string value
  1548. ** attr_frame pointer to strings attributes
  1549. ** keyword_frame frame to use as locator for result
  1550. **
  1551. ** IMPLICIT INPUTS:
  1552. **
  1553. ** none
  1554. **
  1555. ** IMPLICIT OUTPUTS:
  1556. **
  1557. ** none
  1558. **
  1559. ** FUNCTION VALUE:
  1560. **
  1561. ** void
  1562. **
  1563. ** SIDE EFFECTS:
  1564. **
  1565. ** none
  1566. **
  1567. **--
  1568. **/
  1569. void sar_make_wchar_str
  1570. ( target_frame, value_frame, attr_frame, keyword_frame )
  1571. yystype *target_frame;
  1572. yystype *value_frame;
  1573. yystype *attr_frame;
  1574. yystype *keyword_frame;
  1575. {
  1576. sym_value_entry_type *value_entry;
  1577. sym_value_entry_type *wchar_str_entry;
  1578. _assert( value_frame->b_tag == sar_k_value_frame,
  1579. "value frame missing from stack" );
  1580. /*
  1581. ** Make a wide_character string operation. The wide_character string will
  1582. ** be created during retrieval from the UID file.
  1583. */
  1584. wchar_str_entry = (sym_value_entry_type *) sem_create_wchar_str();
  1585. wchar_str_entry->b_expr_opr = sym_k_wchar_str_op;
  1586. if ((value_frame->b_flags & sym_m_forward_ref) != 0)
  1587. sym_make_value_forward_ref (value_frame,
  1588. (char*)&(wchar_str_entry->az_exp_op1), sym_k_patch_add);
  1589. else
  1590. {
  1591. value_entry =
  1592. (sym_value_entry_type *) value_frame->value.az_symbol_entry;
  1593. value_entry->b_type = value_frame->b_type;
  1594. wchar_str_entry->az_exp_op1 = value_entry;
  1595. }
  1596. /*
  1597. ** initialize the target frame
  1598. */
  1599. _sar_move_source_info( target_frame, keyword_frame );
  1600. _sar_save_source_pos ( &wchar_str_entry->header, value_frame );
  1601. target_frame->b_tag = sar_k_value_frame;
  1602. target_frame->b_type = sym_k_wchar_string_value;
  1603. target_frame->b_flags = sym_m_private;
  1604. target_frame->value.az_symbol_entry =
  1605. (sym_entry_type *)wchar_str_entry;
  1606. }
  1607. /*
  1608. **++
  1609. ** FUNCTIONAL DESCRIPTION:
  1610. **
  1611. ** This function issues an error message saying that the value is
  1612. ** the wrong type for this context.
  1613. **
  1614. ** FORMAL PARAMETERS:
  1615. **
  1616. ** value_frame pointer to resultant value stack frame
  1617. ** expected_type type of constant required by this context
  1618. **
  1619. ** IMPLICIT INPUTS:
  1620. **
  1621. ** none
  1622. **
  1623. ** IMPLICIT OUTPUTS:
  1624. **
  1625. ** none
  1626. **
  1627. ** FUNCTION VALUE:
  1628. **
  1629. ** void
  1630. **
  1631. ** SIDE EFFECTS:
  1632. **
  1633. ** error message is issued
  1634. **
  1635. **--
  1636. **/
  1637. void sar_value_type_error( value_frame, expected_type )
  1638. yystype *value_frame;
  1639. int expected_type;
  1640. {
  1641. _assert( value_frame->b_tag == sar_k_value_frame, "value frame missing" );
  1642. /*
  1643. ** make the target frame an error value frame
  1644. */
  1645. if (value_frame->b_type != sym_k_error_value)
  1646. diag_issue_diagnostic
  1647. ( d_wrong_type,
  1648. _sar_source_position( value_frame ),
  1649. diag_value_text( value_frame->b_type ),
  1650. diag_value_text( expected_type ) );
  1651. value_frame->b_type = sym_k_error_value;
  1652. value_frame->b_flags = sym_m_private;
  1653. value_frame->value.az_symbol_entry =
  1654. (sym_entry_type *) sym_az_error_value_entry;
  1655. }
  1656. /*
  1657. **++
  1658. ** FUNCTIONAL DESCRIPTION:
  1659. **
  1660. ** This function issues an error message saying that the value
  1661. ** must be private. Expect for arguments and argument values,
  1662. ** values used by UIL need to be private rather than public.
  1663. ** To make them public would mean that URM would need to perform
  1664. ** the function at runtime.
  1665. **
  1666. ** FORMAL PARAMETERS:
  1667. **
  1668. ** value_frame pointer to resultant value stack frame
  1669. **
  1670. ** IMPLICIT INPUTS:
  1671. **
  1672. ** none
  1673. **
  1674. ** IMPLICIT OUTPUTS:
  1675. **
  1676. ** none
  1677. **
  1678. ** FUNCTION VALUE:
  1679. **
  1680. ** void
  1681. **
  1682. ** SIDE EFFECTS:
  1683. **
  1684. ** error message is issued
  1685. **
  1686. **--
  1687. **/
  1688. void sar_private_error( value_frame )
  1689. yystype *value_frame;
  1690. {
  1691. _assert( value_frame->b_tag == sar_k_value_frame, "value frame missing" );
  1692. /*
  1693. ** make the target frame an error value frame
  1694. */
  1695. if (value_frame->b_type != sym_k_error_value)
  1696. {
  1697. sym_value_entry_type *value_entry;
  1698. value_entry =
  1699. (sym_value_entry_type *) value_frame->value.az_symbol_entry;
  1700. diag_issue_diagnostic
  1701. ( d_nonpvt,
  1702. _sar_source_position( value_frame ),
  1703. value_entry->obj_header.az_name->c_text );
  1704. }
  1705. value_frame->b_type = sym_k_error_value;
  1706. value_frame->b_flags = sym_m_private;
  1707. value_frame->value.az_symbol_entry =
  1708. (sym_entry_type *) sym_az_error_value_entry;
  1709. }
  1710. /*
  1711. **++
  1712. ** FUNCTIONAL DESCRIPTION:
  1713. **
  1714. ** This function creates a value entry for an imported value.
  1715. **
  1716. ** FORMAL PARAMETERS:
  1717. **
  1718. ** target_frame ptr to target value frame on parse stack
  1719. ** token_frame ptr to token frame giving the data type
  1720. **
  1721. ** IMPLICIT INPUTS:
  1722. **
  1723. ** none
  1724. **
  1725. ** IMPLICIT OUTPUTS:
  1726. **
  1727. ** none
  1728. **
  1729. ** FUNCTION VALUE:
  1730. **
  1731. ** void
  1732. **
  1733. ** SIDE EFFECTS:
  1734. **
  1735. ** none
  1736. **
  1737. **--
  1738. **/
  1739. void sar_import_value_entry(target_frame, token_frame)
  1740. yystype *target_frame;
  1741. yystype *token_frame;
  1742. {
  1743. sym_value_entry_type *value_entry;
  1744. _assert( token_frame->b_tag == sar_k_token_frame, "token frame missing" );
  1745. /*
  1746. ** Need to create a value entry and mark it as imported.
  1747. ** The b_type field of the token has been set to the type of value
  1748. ** by a prior grammar reduction
  1749. */
  1750. value_entry = (sym_value_entry_type *)
  1751. sem_allocate_node (sym_k_value_entry, sym_k_value_entry_size);
  1752. _sar_save_source_pos ( &value_entry->header, &yylval );
  1753. /* value_entry->az_source_rec = yylval.az_source_record; */
  1754. value_entry->b_type = token_frame->b_type;
  1755. value_entry->obj_header.b_flags = sym_m_imported;
  1756. /*
  1757. ** set up the target frame
  1758. */
  1759. target_frame->b_tag = sar_k_value_frame;
  1760. target_frame->b_flags = sym_m_imported;
  1761. target_frame->b_type = value_entry->b_type;
  1762. target_frame->value.az_symbol_entry =
  1763. (sym_entry_type *) value_entry;
  1764. }
  1765. /*
  1766. **++
  1767. ** FUNCTIONAL DESCRIPTION:
  1768. **
  1769. ** This function binds the name of a value with its value.
  1770. **
  1771. ** FORMAL PARAMETERS:
  1772. **
  1773. ** id_frame ptr to token frame holding the name for the value
  1774. ** value_frame ptr to value frame
  1775. **
  1776. ** IMPLICIT INPUTS:
  1777. **
  1778. ** sym_az_current_section_entry global pointer to the "current" section list
  1779. **
  1780. ** IMPLICIT OUTPUTS:
  1781. **
  1782. ** none
  1783. **
  1784. ** FUNCTION VALUE:
  1785. **
  1786. ** void
  1787. **
  1788. ** SIDE EFFECTS:
  1789. **
  1790. ** errors if name has previously been used to declare another object
  1791. ** may be a new value entry
  1792. **
  1793. **--
  1794. **/
  1795. void sar_bind_value_name(id_frame, value_frame, semi_frame)
  1796. yystype *id_frame;
  1797. yystype *value_frame;
  1798. yystype *semi_frame;
  1799. {
  1800. sym_name_entry_type *name_entry;
  1801. sym_value_entry_type *value_entry;
  1802. sym_section_entry_type *section_entry;
  1803. int flags;
  1804. boolean error;
  1805. _assert( id_frame->b_tag == sar_k_token_frame, "id frame missing" );
  1806. _assert( value_frame->b_tag == sar_k_value_frame, "value frame missing" );
  1807. /*
  1808. ** First we check on the name to see if it has been previously used.
  1809. ** This function returns NULL if name cannot be used, in which case
  1810. ** processing is over.
  1811. */
  1812. name_entry = sem_dcl_name( id_frame );
  1813. if (name_entry == NULL)
  1814. return;
  1815. /*
  1816. ** Processing is now based on where the value is private, imported, or
  1817. ** exported.
  1818. */
  1819. value_entry = (sym_value_entry_type *) value_frame->value.az_symbol_entry;
  1820. flags = value_frame->b_flags;
  1821. error = (value_frame->b_type == sym_k_error_value);
  1822. if ((flags & sym_m_imported) == 0)
  1823. {
  1824. if ((value_entry->obj_header.az_name != NULL) || error)
  1825. {
  1826. /*
  1827. ** Create a new value node for the unary value reference operator.
  1828. ** az_exp_op1 will point to the node being referenced.
  1829. */
  1830. sym_value_entry_type *saved_value_entry_ptr;
  1831. saved_value_entry_ptr = value_entry;
  1832. value_entry =
  1833. sem_create_value_entry ("",0,sym_k_any_value);
  1834. value_entry->b_expr_opr = sym_k_valref_op;
  1835. /*
  1836. ** If the value is a forward reference, we'll patch in the
  1837. ** address of the the referenced value between passes. Otherwise,
  1838. ** just point to the referenced value node.
  1839. */
  1840. if ((value_frame->b_flags & sym_m_forward_ref) != 0)
  1841. sym_make_value_forward_ref (value_frame,
  1842. (char*)&(value_entry->az_exp_op1), sym_k_patch_add);
  1843. else
  1844. value_entry->az_exp_op1 =
  1845. saved_value_entry_ptr;
  1846. }
  1847. if ((flags & sym_m_exported) != 0)
  1848. sym_make_external_def( name_entry );
  1849. }
  1850. /*
  1851. ** Place the name and flags in the value entry.
  1852. */
  1853. value_entry->obj_header.az_name = name_entry;
  1854. value_entry->obj_header.b_flags =
  1855. (value_entry->obj_header.b_flags & clear_class_mask) | flags;
  1856. name_entry->az_object = (sym_entry_type *) value_entry;
  1857. /*
  1858. ** save the source file info for this value entry
  1859. */
  1860. _sar_save_source_info (&value_entry->header, id_frame, semi_frame );
  1861. /*
  1862. ** allocate a section entry to link the value entry into the structure
  1863. */
  1864. section_entry = (sym_section_entry_type *) sem_allocate_node
  1865. (sym_k_section_entry, sym_k_section_entry_size);
  1866. /*
  1867. ** Link this entry off of the current section list
  1868. */
  1869. section_entry->next = (sym_entry_type *)
  1870. sym_az_current_section_entry->entries;
  1871. sym_az_current_section_entry->entries = (sym_entry_type *) section_entry;
  1872. section_entry->entries = (sym_entry_type *)value_entry;
  1873. }
  1874. /*
  1875. **++
  1876. ** FUNCTIONAL DESCRIPTION:
  1877. **
  1878. ** This function checks to see if a name is available for naming a
  1879. ** construct.
  1880. **
  1881. ** FORMAL PARAMETERS:
  1882. **
  1883. ** id_frame ptr to a token frame on the parse stack holding the name
  1884. **
  1885. ** IMPLICIT INPUTS:
  1886. **
  1887. ** none
  1888. **
  1889. ** IMPLICIT OUTPUTS:
  1890. **
  1891. ** none
  1892. **
  1893. ** FUNCTION VALUE:
  1894. **
  1895. ** ptr to name entry or NULL
  1896. **
  1897. ** SIDE EFFECTS:
  1898. **
  1899. ** name entry may be created
  1900. ** error message for duplicate declaration may be issued
  1901. **
  1902. **--
  1903. **/
  1904. sym_name_entry_type
  1905. *sem_dcl_name(id_frame)
  1906. XmConst yystype *id_frame;
  1907. {
  1908. sym_name_entry_type *name_entry;
  1909. char * ptr;
  1910. _assert( id_frame->b_tag == sar_k_token_frame, "arg1 not id frame" );
  1911. /*
  1912. ** The id frame may hold a name or the keyword for a font name, color
  1913. ** name, reason name etc. If it is one of these special name, then
  1914. ** we insert the special name in the symbol table as a name. This has
  1915. ** the effect of creating a name entry if one doesn't existing or finding
  1916. ** the name entry if one does.
  1917. */
  1918. if (id_frame->b_type != NAME)
  1919. {
  1920. diag_issue_diagnostic
  1921. ( d_override_builtin,
  1922. _sar_source_position( id_frame ),
  1923. id_frame->value.az_keyword_entry->at_name);
  1924. name_entry =
  1925. sym_insert_name
  1926. ( id_frame->value.az_keyword_entry->b_length,
  1927. id_frame->value.az_keyword_entry->at_name );
  1928. }
  1929. else
  1930. name_entry = (sym_name_entry_type *) id_frame->value.az_symbol_entry;
  1931. /*
  1932. ** If the name entry already has an object linked from it, we have an
  1933. ** duplicate definition of the same name. Otherwise, everything is fine.
  1934. */
  1935. if (name_entry->az_object == NULL )
  1936. return name_entry;
  1937. if (name_entry->az_object->header.b_tag == sym_k_value_entry) {
  1938. ptr = diag_value_text (
  1939. ((sym_value_entry_type *) (name_entry->az_object))->b_type);
  1940. } else if (name_entry->az_object->header.b_tag == sym_k_widget_entry) {
  1941. ptr = diag_object_text (
  1942. ((sym_widget_entry_type *) (name_entry->az_object))
  1943. -> header.b_type);
  1944. } else {
  1945. ptr = diag_tag_text( name_entry->az_object->header.b_tag );
  1946. }
  1947. diag_issue_diagnostic
  1948. ( d_previous_def,
  1949. _sar_source_position( id_frame ),
  1950. name_entry->c_text,
  1951. ptr );
  1952. return NULL;
  1953. }
  1954. /*
  1955. **++
  1956. ** FUNCTIONAL DESCRIPTION:
  1957. **
  1958. ** This function creates a value entry for a token that represents
  1959. ** a value.
  1960. **
  1961. ** FORMAL PARAMETERS:
  1962. **
  1963. ** value pointer to value
  1964. ** length length of the value in bytes
  1965. ** value_type type of value to create
  1966. **
  1967. ** IMPLICIT INPUTS:
  1968. **
  1969. ** none
  1970. **
  1971. ** IMPLICIT OUTPUTS:
  1972. **
  1973. ** none
  1974. **
  1975. ** FUNCTION VALUE:
  1976. **
  1977. ** a value_entry
  1978. **
  1979. ** SIDE EFFECTS:
  1980. **
  1981. ** value entry is created in the symbol table
  1982. **
  1983. **--
  1984. **/
  1985. sym_value_entry_type
  1986. *sem_create_value_entry( value, length, value_type )
  1987. char *value;
  1988. int length;
  1989. int value_type;
  1990. {
  1991. sym_value_entry_type *value_entry;
  1992. /*
  1993. ** the value can be a string, integer, float, boolean, or
  1994. ** a font_name, argument_name, color_name, or reason_name
  1995. */
  1996. /*
  1997. ** the strategy of the function is to determine the contents
  1998. ** of the value entry, then centrally allocate and initialize it.
  1999. **
  2000. ** Allocate the entry and save the source position. Initialize
  2001. ** all fields to either default values or call parameters.
  2002. */
  2003. value_entry = (sym_value_entry_type *)
  2004. sem_allocate_node (sym_k_value_entry, sym_k_value_entry_size);
  2005. _sar_save_source_pos ( &value_entry->header, &yylval );
  2006. sar_assoc_comment ((sym_obj_entry_type *)value_entry); /* preserve comments */
  2007. value_entry->b_type = value_type;
  2008. value_entry->obj_header.b_flags = (sym_m_private | sym_m_builtin);
  2009. value_entry->w_length = length;
  2010. value_entry->output_state = 0;
  2011. value_entry->b_table_count = 0;
  2012. value_entry->b_aux_flags = 0;
  2013. value_entry->b_arg_type = 0;
  2014. value_entry->b_data_offset = 0;
  2015. value_entry->b_pixel_type = sym_k_unspecified_color;
  2016. value_entry->b_charset = 0;
  2017. value_entry->b_direction = NOSTRING_DIRECTION;
  2018. value_entry->b_max_index = 0;
  2019. value_entry->b_expr_opr = sym_k_unspecified_op;
  2020. value_entry->b_enumeration_value_code = 0;
  2021. value_entry->resource_id = 0;
  2022. value_entry->obj_header.az_name = NULL;
  2023. value_entry->az_charset_value = NULL;
  2024. value_entry->az_next_table_value = NULL;
  2025. value_entry->value.l_integer = 0;
  2026. if ((value_type == sym_k_char_8_value ||
  2027. value_type == sym_k_font_value ||
  2028. value_type == sym_k_fontset_value ||
  2029. value_type == sym_k_keysym_value ||
  2030. value_type == sym_k_xbitmapfile_value ||
  2031. value_type == sym_k_class_rec_name_value ||
  2032. value_type == sym_k_identifier_value) &&
  2033. (length > 0))
  2034. {
  2035. value_entry->value.c_value = (char *) XtCalloc(1,length);
  2036. _move( value_entry->value.c_value, value, length );
  2037. }
  2038. else if (value_type == sym_k_compound_string_value && (length > 0))
  2039. {
  2040. value_entry->value.xms_value = (XmString) XtCalloc(1,length);
  2041. _move( value_entry->value.xms_value, value, length );
  2042. }
  2043. else
  2044. if ( length > 0 )
  2045. _move( &(value_entry->value.c_value), value, length );
  2046. /* For enumerations which accept boolean values */
  2047. if (value_type == sym_k_bool_value)
  2048. value_entry->b_enumeration_value_code =
  2049. (*value) ? sym_k_TRUE_enumval : sym_k_FALSE_enumval;
  2050. return value_entry;
  2051. }
  2052. /*
  2053. **++
  2054. ** FUNCTIONAL DESCRIPTION:
  2055. **
  2056. ** This function creates the value symbol node for an
  2057. ** identifier declaration.
  2058. **
  2059. ** FORMAL PARAMETERS:
  2060. **
  2061. ** id_frame ptr to token frame for the identifier name
  2062. **
  2063. ** IMPLICIT INPUTS:
  2064. **
  2065. ** sym_az_current_section_entry global that points to the "current" section list
  2066. **
  2067. ** IMPLICIT OUTPUTS:
  2068. **
  2069. ** none
  2070. **
  2071. ** FUNCTION VALUE:
  2072. **
  2073. ** void
  2074. **
  2075. ** SIDE EFFECTS:
  2076. **
  2077. ** errors may be issued for previously defined name
  2078. **
  2079. **--
  2080. **/
  2081. void sar_create_identifier (id_frame, semi_frame)
  2082. XmConst yystype *id_frame;
  2083. XmConst yystype *semi_frame;
  2084. {
  2085. sym_name_entry_type *name_entry;
  2086. sym_value_entry_type *value_entry;
  2087. sym_section_entry_type *section_entry;
  2088. int len;
  2089. char * ptr;
  2090. /*
  2091. ** Call standard routine to check name entry for id_frame.
  2092. ** This routine handles font name, color names, etc used as ids
  2093. */
  2094. name_entry = sem_dcl_name( id_frame );
  2095. if (name_entry == NULL)
  2096. return;
  2097. /*
  2098. ** Allocate the value entry and fill it in. The b_type field
  2099. ** in name entries holds the length of the name. Add one for null.
  2100. */
  2101. len = name_entry->header.b_type + 1;
  2102. ptr = name_entry->c_text;
  2103. value_entry = sem_create_value_entry ( ptr, len, sym_k_identifier_value );
  2104. _move (value_entry->value.c_value, ptr, len);
  2105. value_entry->obj_header.b_flags |= sym_m_private;
  2106. value_entry->obj_header.az_name = name_entry;
  2107. name_entry->az_object = (sym_entry_type *) value_entry;
  2108. /*
  2109. ** save the source file info for this identifier entry
  2110. */
  2111. _sar_save_source_info (&name_entry->header, id_frame, semi_frame );
  2112. /*
  2113. ** allocate a section entry to link the identifier entry into the structure
  2114. */
  2115. section_entry = (sym_section_entry_type *) sem_allocate_node
  2116. (sym_k_section_entry, sym_k_section_entry_size);
  2117. /*
  2118. ** Link this entry off of the current section list
  2119. */
  2120. section_entry->next =
  2121. (sym_entry_type *) sym_az_current_section_entry->entries;
  2122. sym_az_current_section_entry->entries =
  2123. (sym_entry_type *) section_entry;
  2124. section_entry->entries = (sym_entry_type *)name_entry;
  2125. }
  2126. /*
  2127. **++
  2128. ** FUNCTIONAL DESCRIPTION:
  2129. **
  2130. ** This function builds a font table. This font table
  2131. ** is a list of symbol table entries of font items.
  2132. **
  2133. ** FORMAL PARAMETERS:
  2134. **
  2135. ** target_frame frame holding the font table generated
  2136. ** font_frame value frame specifying the font value
  2137. ** prior_target_frame frame holding the font table generated so far
  2138. ** keyword_frame frame holding the font_table keyword
  2139. **
  2140. ** IMPLICIT INPUTS:
  2141. **
  2142. ** none
  2143. **
  2144. ** IMPLICIT OUTPUTS:
  2145. **
  2146. ** target_frame
  2147. **
  2148. ** FUNCTION VALUE:
  2149. **
  2150. ** void
  2151. **
  2152. ** SIDE EFFECTS:
  2153. **
  2154. ** font table symbol entry is generated if prior target is null
  2155. **
  2156. **--
  2157. **/
  2158. void sar_make_font_table
  2159. (target_frame, font_frame, prior_target_frame, keyword_frame)
  2160. yystype *target_frame;
  2161. yystype *font_frame;
  2162. yystype *prior_target_frame;
  2163. yystype *keyword_frame;
  2164. {
  2165. sym_value_entry_type *font_table_entry;
  2166. sym_value_entry_type *font_item;
  2167. _assert( font_frame->b_tag == sar_k_value_frame, "font item missing" );
  2168. font_item = (sym_value_entry_type *) font_frame->value.az_symbol_entry;
  2169. /*
  2170. ** If the prior frame is null, this is the first item in the
  2171. ** table. We need to generate the font table symbol entry.
  2172. */
  2173. switch (prior_target_frame->b_tag)
  2174. {
  2175. case sar_k_null_frame:
  2176. font_table_entry =
  2177. sem_create_value_entry ((char*)&font_item, sizeof(long),
  2178. sym_k_font_table_value);
  2179. font_table_entry->b_table_count = 1;
  2180. /*
  2181. * If we are dealing with an indirect reference in the table,
  2182. * make it a valref node so we reference it correctly.
  2183. */
  2184. if (font_item->obj_header.az_name != NULL)
  2185. {
  2186. sym_value_entry_type *font_save;
  2187. font_save = font_item;
  2188. font_item = sem_create_value_entry (0, 0, font_save->b_type);
  2189. font_item->b_type = font_save->b_type;
  2190. font_item->obj_header.b_flags = sym_m_private;
  2191. font_item->b_expr_opr = sym_k_valref_op;
  2192. font_item->az_exp_op1 = font_save;
  2193. }
  2194. font_table_entry->az_first_table_value = font_item;
  2195. break;
  2196. case sar_k_value_frame:
  2197. {
  2198. int count;
  2199. sym_value_entry_type *last_font_item;
  2200. font_table_entry = (sym_value_entry_type *)
  2201. prior_target_frame->value.az_symbol_entry;
  2202. for (count = 0,
  2203. last_font_item = font_table_entry->az_first_table_value;
  2204. last_font_item->az_next_table_value != NULL;
  2205. last_font_item =
  2206. last_font_item->az_next_table_value)
  2207. count++;
  2208. if (count >= sym_k_max_list_count)
  2209. diag_issue_diagnostic
  2210. (d_too_many,
  2211. _sar_source_position( font_frame ),
  2212. diag_value_text( sym_k_font_value ),
  2213. diag_value_text( sym_k_font_table_value ),
  2214. sym_k_max_list_count );
  2215. else
  2216. {
  2217. /*
  2218. * If we are dealing with an indirect reference in the table,
  2219. * make it a valref node so we reference it correctly.
  2220. */
  2221. if (font_item->obj_header.az_name != NULL)
  2222. {
  2223. sym_value_entry_type *font_save;
  2224. font_save = font_item;
  2225. font_item = sem_create_value_entry (0, 0, font_save->b_type);
  2226. font_item->b_type = font_save->b_type;
  2227. font_item->obj_header.b_flags = sym_m_private;
  2228. font_item->b_expr_opr = sym_k_valref_op;
  2229. font_item->az_exp_op1 = font_save;
  2230. }
  2231. last_font_item->az_next_table_value = font_item;
  2232. font_table_entry->b_table_count = count + 1;
  2233. }
  2234. break;
  2235. }
  2236. default:
  2237. _assert( FALSE, "prior frame in error" );
  2238. }
  2239. /*
  2240. ** font item needs to be marked as a table entry
  2241. */
  2242. font_item->b_aux_flags |= sym_m_table_entry;
  2243. font_item->az_next_table_value = NULL;
  2244. /*
  2245. ** initialize the target frame
  2246. */
  2247. _sar_move_source_info (target_frame, keyword_frame);
  2248. target_frame->b_tag = sar_k_value_frame;
  2249. target_frame->b_type = sym_k_font_table_value;
  2250. target_frame->b_flags = sym_m_private;
  2251. target_frame->value.az_symbol_entry =
  2252. (sym_entry_type *) font_table_entry;
  2253. }
  2254. /*
  2255. **++
  2256. ** FUNCTIONAL DESCRIPTION:
  2257. **
  2258. ** This function builds a item for a font table. This font table
  2259. ** is a list of symbol table entries of font items.
  2260. **
  2261. ** FORMAL PARAMETERS:
  2262. **
  2263. ** target_frame frame holding the font item generated
  2264. ** charset_frame token or null frame holding charset token
  2265. ** font_frame value frame specifying the font value
  2266. **
  2267. ** IMPLICIT INPUTS:
  2268. **
  2269. ** none
  2270. **
  2271. ** IMPLICIT OUTPUTS:
  2272. **
  2273. ** target_frame
  2274. **
  2275. ** FUNCTION VALUE:
  2276. **
  2277. ** void
  2278. **
  2279. ** SIDE EFFECTS:
  2280. **
  2281. ** copy the font value unless it is unnamed
  2282. **
  2283. **--
  2284. **/
  2285. void sar_make_font_item(target_frame, charset_frame, font_frame)
  2286. yystype *target_frame;
  2287. yystype *charset_frame;
  2288. yystype *font_frame;
  2289. {
  2290. sym_value_entry_type *font_value_entry;
  2291. int item_type;
  2292. _assert( font_frame->b_tag == sar_k_value_frame, "font exp is missing" );
  2293. font_value_entry =
  2294. (sym_value_entry_type *) font_frame->value.az_symbol_entry;
  2295. if ((font_frame->b_flags & sym_m_forward_ref) != 0)
  2296. {
  2297. diag_issue_diagnostic
  2298. (d_undefined,
  2299. _sar_source_position(font_frame),
  2300. "font entry",
  2301. font_value_entry->obj_header.az_name->c_text);
  2302. }
  2303. item_type = font_value_entry->b_type;
  2304. switch (item_type)
  2305. {
  2306. case sym_k_font_value:
  2307. case sym_k_fontset_value:
  2308. {
  2309. int charset;
  2310. charset = font_value_entry->b_charset;
  2311. /*
  2312. ** If the attr_frame is not null, it must be a value frame with contains
  2313. ** a pointer to the value entry for the userdefined charset, or a token frame
  2314. ** which contains the charset token subclass.
  2315. */
  2316. switch (charset_frame->b_tag)
  2317. {
  2318. case sar_k_value_frame:
  2319. {
  2320. sym_value_entry_type * az_value_entry;
  2321. az_value_entry = (sym_value_entry_type *)charset_frame->value.az_symbol_entry;
  2322. font_value_entry->b_charset = az_value_entry->b_charset;
  2323. font_value_entry->az_charset_value =
  2324. az_value_entry->az_charset_value;
  2325. break;
  2326. }
  2327. case sar_k_token_frame:
  2328. {
  2329. key_keytable_entry_type *keyword_entry;
  2330. keyword_entry = (key_keytable_entry_type *)
  2331. charset_frame->value.az_keyword_entry;
  2332. font_value_entry->b_charset =
  2333. sem_map_subclass_to_charset( keyword_entry->b_subclass );
  2334. break;
  2335. }
  2336. }
  2337. break;
  2338. }
  2339. case sym_k_error_value:
  2340. break;
  2341. default:
  2342. diag_issue_diagnostic
  2343. ( d_wrong_type,
  2344. _sar_source_position( font_frame ),
  2345. diag_value_text( item_type ),
  2346. diag_value_text( sym_k_font_value ) );
  2347. item_type = sym_k_error_value;
  2348. font_value_entry = (sym_value_entry_type *) sym_az_error_value_entry;
  2349. }
  2350. /*
  2351. ** initialize the target frame
  2352. */
  2353. _sar_move_source_info( target_frame, font_frame );
  2354. target_frame->b_tag = sar_k_value_frame;
  2355. target_frame->b_type = item_type;
  2356. target_frame->b_flags = sym_m_private;
  2357. target_frame->value.az_symbol_entry =
  2358. (sym_entry_type *) font_value_entry;
  2359. }
  2360. /*
  2361. **++
  2362. ** FUNCTIONAL DESCRIPTION:
  2363. **
  2364. ** This function builds a font value.
  2365. **
  2366. ** FORMAL PARAMETERS:
  2367. **
  2368. ** target_frame frame holding the font item generated
  2369. ** charset_frame token or null frame holding charset token
  2370. ** value_frame value frame specifying the font value
  2371. ** keyword_frame frame to use as locator for result
  2372. **
  2373. ** IMPLICIT INPUTS:
  2374. **
  2375. ** none
  2376. **
  2377. ** IMPLICIT OUTPUTS:
  2378. **
  2379. ** target_frame
  2380. **
  2381. ** FUNCTION VALUE:
  2382. **
  2383. ** void
  2384. **
  2385. ** SIDE EFFECTS:
  2386. **
  2387. ** create a font symbol table entry
  2388. **
  2389. **--
  2390. **/
  2391. void sar_make_font(target_frame, charset_frame, value_frame, keyword_frame)
  2392. yystype *target_frame;
  2393. yystype *charset_frame;
  2394. yystype *value_frame;
  2395. yystype *keyword_frame;
  2396. {
  2397. sym_value_entry_type *font_value_entry;
  2398. sym_value_entry_type *value_entry;
  2399. _assert( value_frame->b_tag == sar_k_value_frame, "font name is missing" );
  2400. font_value_entry = sem_create_value_entry ("", 0, sym_k_font_value );
  2401. font_value_entry->b_type = sym_k_font_value;
  2402. font_value_entry->obj_header.b_flags = sym_m_private;
  2403. font_value_entry->b_expr_opr = sym_k_coerce_op;
  2404. if ((value_frame->b_flags & sym_m_forward_ref) != 0)
  2405. sym_make_value_forward_ref (value_frame,
  2406. (char*)&(font_value_entry->az_exp_op1),
  2407. sym_k_patch_add);
  2408. else
  2409. {
  2410. value_entry =
  2411. (sym_value_entry_type *) value_frame->value.az_symbol_entry;
  2412. font_value_entry->az_exp_op1 = value_entry;
  2413. }
  2414. /*
  2415. ** If the attr_frame is not null, it must be a value frame with contains
  2416. ** a pointer to the value entry for the userdefined charset, or a token frame
  2417. ** which contains the charset token subclass.
  2418. */
  2419. switch (charset_frame->b_tag)
  2420. {
  2421. case sar_k_value_frame:
  2422. {
  2423. sym_value_entry_type * az_value_entry;
  2424. az_value_entry = (sym_value_entry_type *)
  2425. charset_frame->value.az_symbol_entry;
  2426. font_value_entry->b_charset = az_value_entry->b_charset;
  2427. /* BEGIN HAL Fix CR 5266 */
  2428. font_value_entry->az_charset_value = az_value_entry;
  2429. /* END HAL Fix CR 5266 */
  2430. break;
  2431. }
  2432. case sar_k_token_frame:
  2433. {
  2434. key_keytable_entry_type *keyword_entry;
  2435. keyword_entry = (key_keytable_entry_type *)
  2436. charset_frame->value.az_keyword_entry;
  2437. font_value_entry->b_charset =
  2438. sem_map_subclass_to_charset( keyword_entry->b_subclass );
  2439. break;
  2440. }
  2441. default:
  2442. /* BEGIN OSF Fix CR 5443 */
  2443. font_value_entry->b_charset = Uil_lex_l_user_default_charset;
  2444. /* END OSF Fix CR 5443 */
  2445. break;
  2446. }
  2447. /*
  2448. ** initialize the target frame
  2449. */
  2450. _sar_move_source_info( target_frame, keyword_frame );
  2451. target_frame->b_tag = sar_k_value_frame;
  2452. target_frame->b_type = sym_k_font_value;
  2453. target_frame->b_flags = sym_m_private;
  2454. target_frame->value.az_symbol_entry =
  2455. (sym_entry_type *) font_value_entry;
  2456. }
  2457. /*
  2458. **++
  2459. ** FUNCTIONAL DESCRIPTION:
  2460. **
  2461. ** This function builds a fontset value.
  2462. **
  2463. ** FORMAL PARAMETERS:
  2464. **
  2465. ** target_frame frame holding the font item generated
  2466. ** charset_frame token or null frame holding charset token
  2467. ** value_frame value frame specifying the font value
  2468. ** keyword_frame frame to use as locator for result
  2469. **
  2470. ** IMPLICIT INPUTS:
  2471. **
  2472. ** none
  2473. **
  2474. ** IMPLICIT OUTPUTS:
  2475. **
  2476. ** target_frame
  2477. **
  2478. ** FUNCTION VALUE:
  2479. **
  2480. ** void
  2481. **
  2482. ** SIDE EFFECTS:
  2483. **
  2484. ** create a font symbol table entry
  2485. **
  2486. **--
  2487. **/
  2488. void sar_make_fontset(target_frame, charset_frame, value_frame, keyword_frame)
  2489. yystype *target_frame;
  2490. yystype *charset_frame;
  2491. yystype *value_frame;
  2492. yystype *keyword_frame;
  2493. {
  2494. sym_value_entry_type *font_value_entry;
  2495. sym_value_entry_type *value_entry;
  2496. _assert( value_frame->b_tag == sar_k_value_frame, "font name is missing" );
  2497. font_value_entry = sem_create_value_entry ("", 0, sym_k_fontset_value );
  2498. font_value_entry->b_type = sym_k_fontset_value;
  2499. font_value_entry->obj_header.b_flags = sym_m_private;
  2500. font_value_entry->b_expr_opr = sym_k_coerce_op;
  2501. if ((value_frame->b_flags & sym_m_forward_ref) != 0)
  2502. sym_make_value_forward_ref (value_frame,
  2503. (char*)&(font_value_entry->az_exp_op1),
  2504. sym_k_patch_add);
  2505. else
  2506. {
  2507. value_entry =
  2508. (sym_value_entry_type *) value_frame->value.az_symbol_entry;
  2509. font_value_entry->az_exp_op1 = value_entry;
  2510. }
  2511. /*
  2512. ** If the attr_frame is not null, it must be a value frame with contains
  2513. ** a pointer to the value entry for the userdefined charset, or a token frame
  2514. ** which contains the charset token subclass.
  2515. */
  2516. switch (charset_frame->b_tag)
  2517. {
  2518. case sar_k_value_frame:
  2519. {
  2520. sym_value_entry_type * az_value_entry;
  2521. az_value_entry = (sym_value_entry_type *)
  2522. charset_frame->value.az_symbol_entry;
  2523. font_value_entry->b_charset = az_value_entry->b_charset;
  2524. /* BEGIN HAL Fix CR 5266 */
  2525. font_value_entry->az_charset_value = az_value_entry;
  2526. /* END HAL Fix CR 5266 */
  2527. break;
  2528. }
  2529. case sar_k_token_frame:
  2530. {
  2531. key_keytable_entry_type *keyword_entry;
  2532. keyword_entry = (key_keytable_entry_type *)
  2533. charset_frame->value.az_keyword_entry;
  2534. font_value_entry->b_charset =
  2535. sem_map_subclass_to_charset( keyword_entry->b_subclass );
  2536. break;
  2537. }
  2538. default:
  2539. /* BEGIN OSF Fix CR 5443 */
  2540. font_value_entry->b_charset = Uil_lex_l_user_default_charset;
  2541. /* END OSF Fix CR 5443 */
  2542. break;
  2543. }
  2544. /*
  2545. ** initialize the target frame
  2546. */
  2547. _sar_move_source_info( target_frame, keyword_frame );
  2548. target_frame->b_tag = sar_k_value_frame;
  2549. target_frame->b_type = sym_k_fontset_value;
  2550. target_frame->b_flags = sym_m_private;
  2551. target_frame->value.az_symbol_entry =
  2552. (sym_entry_type *) font_value_entry;
  2553. }
  2554. /*
  2555. **++
  2556. ** FUNCTIONAL DESCRIPTION:
  2557. **
  2558. ** This function builds a color item which is a temporary respository
  2559. ** to hold data for a single color to be placed in a color table. The
  2560. ** color item is deleted when the color table is built by
  2561. ** sar_make_color_table.
  2562. **
  2563. ** FORMAL PARAMETERS:
  2564. **
  2565. ** target_frame frame holding the color item generated
  2566. ** color_frame token or value frame giving the color
  2567. ** letter_frame value frame specifying the letter to use for color
  2568. ** keyword_frame frame to use as locator for result
  2569. **
  2570. ** IMPLICIT INPUTS:
  2571. **
  2572. ** none
  2573. **
  2574. ** IMPLICIT OUTPUTS:
  2575. **
  2576. ** target_frame
  2577. **
  2578. ** FUNCTION VALUE:
  2579. **
  2580. ** void
  2581. **
  2582. ** SIDE EFFECTS:
  2583. **
  2584. ** create a color item symbol table entry
  2585. **
  2586. **--
  2587. **/
  2588. void sar_make_color_item
  2589. (target_frame, color_frame, letter_frame )
  2590. yystype *target_frame;
  2591. yystype *color_frame;
  2592. yystype *letter_frame;
  2593. {
  2594. sym_color_item_entry_type *item_entry;
  2595. sym_value_entry_type *letter_entry;
  2596. _assert( letter_frame->b_tag == sar_k_value_frame, "letter frame missing" );
  2597. /*
  2598. ** initialize the target frame
  2599. */
  2600. _sar_move_source_info( target_frame, color_frame );
  2601. target_frame->b_tag = sar_k_value_frame;
  2602. target_frame->b_type = 0;
  2603. target_frame->b_flags = 0;
  2604. target_frame->value.az_symbol_entry = 0;
  2605. /*
  2606. ** The color can be either a color value or the keyword background or
  2607. ** foreground. Want to step up:
  2608. ** target_frame->b_tag: with either sar_k_value_frame for no error
  2609. ** or sar_k_null_frame for an error
  2610. ** color_entry: color value if there is one
  2611. ** 0 for background
  2612. ** 1 for foreground
  2613. */
  2614. /*
  2615. ** Allocate the color item and fill it in
  2616. */
  2617. item_entry = (sym_color_item_entry_type *)
  2618. sem_allocate_node(sym_k_color_item_entry,
  2619. sym_k_color_item_entry_size );
  2620. _sar_save_source_pos (&item_entry->header, color_frame);
  2621. item_entry->b_index = 0;
  2622. item_entry->az_next = NULL;
  2623. switch (color_frame->b_tag)
  2624. {
  2625. case sar_k_token_frame:
  2626. {
  2627. key_keytable_entry_type *keyword_entry;
  2628. /*
  2629. ** This is the foreground or background case
  2630. */
  2631. keyword_entry = color_frame->value.az_keyword_entry;
  2632. switch (keyword_entry->b_token)
  2633. {
  2634. case BACKGROUND:
  2635. item_entry->az_color = (sym_value_entry_type *) URMColorTableBG;
  2636. break;
  2637. case FOREGROUND:
  2638. item_entry->az_color = (sym_value_entry_type *) URMColorTableFG;
  2639. break;
  2640. default:
  2641. _assert( FALSE, "missing keyword frame" );
  2642. }
  2643. break;
  2644. }
  2645. case sar_k_value_frame:
  2646. if ((color_frame->b_flags & sym_m_forward_ref) != 0)
  2647. {
  2648. sym_value_entry_type *diag_value;
  2649. diag_value = (sym_value_entry_type *)
  2650. color_frame->value.az_symbol_entry;
  2651. diag_issue_diagnostic
  2652. (d_undefined,
  2653. _sar_source_position(color_frame),
  2654. "color entry",
  2655. diag_value->obj_header.az_name->c_text);
  2656. }
  2657. else
  2658. {
  2659. item_entry->az_color =
  2660. (sym_value_entry_type *) color_frame->value.az_symbol_entry;
  2661. }
  2662. break;
  2663. default:
  2664. _assert( FALSE, "color frame missing" );
  2665. }
  2666. /*
  2667. ** Letter frame has already been checked in the grammar to be a character
  2668. ** string. Need to further check that it has a length of 1.
  2669. */
  2670. letter_entry =
  2671. (sym_value_entry_type *) letter_frame->value.az_symbol_entry;
  2672. if (letter_entry->w_length != 1)
  2673. {
  2674. diag_issue_diagnostic
  2675. ( d_single_letter,
  2676. _sar_source_position( letter_frame ) );
  2677. target_frame->b_tag = sar_k_null_frame;
  2678. return;
  2679. }
  2680. item_entry->b_letter = letter_entry->value.c_value[0];
  2681. /*
  2682. ** If the tag is in error - return
  2683. */
  2684. if (target_frame->b_tag == sar_k_null_frame)
  2685. return;
  2686. /*
  2687. ** Save source information
  2688. */
  2689. _sar_save_source_info ( &item_entry->header, color_frame, letter_frame);
  2690. target_frame->value.az_symbol_entry = (sym_entry_type *) item_entry;
  2691. }
  2692. /*
  2693. **++
  2694. ** FUNCTIONAL DESCRIPTION:
  2695. **
  2696. ** This function builds a list of the color items that are used to
  2697. ** produce the color table. Each color is checked to see that
  2698. ** its letter is unique. The new color item is placed on the
  2699. ** front of the list.
  2700. **
  2701. ** FORMAL PARAMETERS:
  2702. **
  2703. ** target_frame frame holding the color item list
  2704. ** item_frame color item to be added to list
  2705. ** prior_target_frame existing color list
  2706. **
  2707. ** IMPLICIT INPUTS:
  2708. **
  2709. ** none
  2710. **
  2711. ** IMPLICIT OUTPUTS:
  2712. **
  2713. ** target_frame
  2714. **
  2715. ** FUNCTION VALUE:
  2716. **
  2717. ** void
  2718. **
  2719. ** SIDE EFFECTS:
  2720. **
  2721. ** none
  2722. **
  2723. **--
  2724. **/
  2725. void sar_append_color_item(target_frame, item_frame, prior_target_frame)
  2726. yystype *target_frame;
  2727. yystype *item_frame;
  2728. yystype *prior_target_frame;
  2729. {
  2730. sym_color_item_entry_type *item_entry;
  2731. sym_color_item_entry_type *prior_item_entry;
  2732. /*
  2733. ** Tag for the prior_target frame indicates if this is the first
  2734. ** or a subsequent color item on the list.
  2735. */
  2736. switch (prior_target_frame->b_tag)
  2737. {
  2738. case sar_k_null_frame:
  2739. prior_item_entry = NULL;
  2740. break;
  2741. case sar_k_value_frame:
  2742. prior_item_entry =
  2743. (sym_color_item_entry_type *)
  2744. prior_target_frame->value.az_symbol_entry;
  2745. break;
  2746. default:
  2747. _assert( FALSE, "prior frame missing" );
  2748. }
  2749. /*
  2750. ** initialize the target frame
  2751. */
  2752. _sar_move_source_info( target_frame, item_frame );
  2753. target_frame->b_tag = sar_k_value_frame;
  2754. target_frame->b_type = 0;
  2755. target_frame->b_flags = 0;
  2756. target_frame->value.az_symbol_entry =
  2757. (sym_entry_type *) prior_item_entry;
  2758. /*
  2759. ** Need to verify that the letter associated with the current color
  2760. ** item is unique.
  2761. */
  2762. switch (item_frame->b_tag)
  2763. {
  2764. case sar_k_value_frame:
  2765. {
  2766. sym_color_item_entry_type *next_item_entry;
  2767. item_entry =
  2768. (sym_color_item_entry_type *) item_frame->value.az_symbol_entry;
  2769. for (next_item_entry = prior_item_entry;
  2770. next_item_entry != NULL;
  2771. next_item_entry = next_item_entry->az_next)
  2772. if (next_item_entry->b_letter == item_entry->b_letter)
  2773. {
  2774. diag_issue_diagnostic
  2775. ( d_dup_letter,
  2776. _sar_source_position( item_frame ) );
  2777. return;
  2778. }
  2779. item_entry->az_next = prior_item_entry;
  2780. target_frame->value.az_symbol_entry =
  2781. (sym_entry_type *) item_entry;
  2782. return;
  2783. }
  2784. case sar_k_null_frame:
  2785. return;
  2786. default:
  2787. _assert( FALSE, "list frame missing" );
  2788. }
  2789. }
  2790. /*
  2791. **++
  2792. ** FUNCTIONAL DESCRIPTION:
  2793. **
  2794. ** This function builds a color table. It takes a series of
  2795. ** color items and repackages them within the color table.
  2796. **
  2797. ** FORMAL PARAMETERS:
  2798. **
  2799. ** target_frame frame for holding the color table
  2800. ** list_frame frame holding first of color item lists
  2801. ** keyword_frame frame for COLOR_TABLE keyword
  2802. **
  2803. ** IMPLICIT INPUTS:
  2804. **
  2805. ** none
  2806. **
  2807. ** IMPLICIT OUTPUTS:
  2808. **
  2809. ** target_frame
  2810. **
  2811. ** FUNCTION VALUE:
  2812. **
  2813. ** void
  2814. **
  2815. ** SIDE EFFECTS:
  2816. **
  2817. ** none
  2818. **
  2819. **--
  2820. **/
  2821. void sar_make_color_table(target_frame, list_frame, keyword_frame)
  2822. yystype *target_frame;
  2823. yystype *list_frame;
  2824. yystype *keyword_frame;
  2825. {
  2826. sym_color_item_entry_type *next_item_entry;
  2827. sym_value_entry_type *color_table_entry;
  2828. int target_type;
  2829. /*
  2830. ** Tag for the list frame indicates if there are any color items.
  2831. */
  2832. switch (list_frame->b_tag)
  2833. {
  2834. case sar_k_null_frame:
  2835. target_type = sym_k_error_value;
  2836. color_table_entry = sym_az_error_value_entry;
  2837. break;
  2838. case sar_k_value_frame:
  2839. {
  2840. int count;
  2841. int index;
  2842. count = 0;
  2843. index = 1;
  2844. for (next_item_entry =
  2845. (sym_color_item_entry_type *) list_frame->value.az_symbol_entry;
  2846. next_item_entry != NULL;
  2847. next_item_entry = next_item_entry->az_next)
  2848. {
  2849. count++;
  2850. switch ((long)next_item_entry->az_color)
  2851. {
  2852. case 0:
  2853. next_item_entry->b_index = URMColorTableBG;
  2854. break;
  2855. case 1:
  2856. next_item_entry->b_index = URMColorTableFG;
  2857. break;
  2858. default:
  2859. next_item_entry->b_index = (unsigned char) ++index;
  2860. break;
  2861. }
  2862. }
  2863. if (index >= sym_k_max_color_count)
  2864. {
  2865. diag_issue_diagnostic
  2866. (d_too_many,
  2867. _sar_source_position( keyword_frame ),
  2868. diag_value_text( sym_k_color_value ),
  2869. diag_value_text( sym_k_color_table_value ),
  2870. sym_k_max_color_count );
  2871. target_type = sym_k_error_value;
  2872. color_table_entry = sym_az_error_value_entry;
  2873. break;
  2874. }
  2875. color_table_entry = (sym_value_entry_type *)
  2876. sem_allocate_node (sym_k_value_entry, sym_k_value_entry_size);
  2877. color_table_entry->value.z_color = (sym_color_element *)
  2878. XtCalloc(1,sizeof(sym_color_element)*count);
  2879. color_table_entry->b_type = sym_k_color_table_value;
  2880. color_table_entry->b_table_count = (unsigned char) count;
  2881. color_table_entry->b_max_index = (unsigned char) index;
  2882. color_table_entry->obj_header.b_flags = sym_m_private;
  2883. _sar_save_source_pos ( &color_table_entry->header, list_frame);
  2884. for (index = 0,
  2885. next_item_entry = (sym_color_item_entry_type *)
  2886. list_frame->value.az_symbol_entry;
  2887. next_item_entry != NULL;
  2888. index++ )
  2889. {
  2890. sym_color_item_entry_type *temp;
  2891. color_table_entry->value.z_color[index].b_index =
  2892. next_item_entry->b_index;
  2893. color_table_entry->value.z_color[index].b_letter =
  2894. next_item_entry->b_letter;
  2895. color_table_entry->value.z_color[index].az_color =
  2896. next_item_entry->az_color;
  2897. temp = next_item_entry;
  2898. next_item_entry = next_item_entry->az_next;
  2899. sem_free_node(( sym_entry_type *) temp );
  2900. }
  2901. target_type = sym_k_color_table_value;
  2902. break;
  2903. }
  2904. default:
  2905. _assert( FALSE, "list frame missing" );
  2906. }
  2907. /*
  2908. ** initialize the target frame
  2909. */
  2910. _sar_move_source_info( target_frame, keyword_frame );
  2911. target_frame->b_tag = sar_k_value_frame;
  2912. target_frame->b_type = target_type;
  2913. target_frame->b_flags = sym_m_private;
  2914. target_frame->value.az_symbol_entry =
  2915. (sym_entry_type *) color_table_entry;
  2916. }
  2917. /*
  2918. **++
  2919. ** FUNCTIONAL DESCRIPTION:
  2920. **
  2921. ** This function builds a color value. Input to the function is a
  2922. ** character string give the color name and an option keyword specifying
  2923. ** display of the color on a monochrome device.
  2924. **
  2925. ** FORMAL PARAMETERS:
  2926. **
  2927. ** target_frame frame to hold the created color value
  2928. ** color_frame frame giving the character string specifying the color
  2929. ** mono_frame frame describing monochrome attribute
  2930. ** keyword_frame frame pointing to COLOR keyword
  2931. **
  2932. ** IMPLICIT INPUTS:
  2933. **
  2934. ** none
  2935. **
  2936. ** IMPLICIT OUTPUTS:
  2937. **
  2938. ** target_frame
  2939. **
  2940. ** FUNCTION VALUE:
  2941. **
  2942. ** void
  2943. **
  2944. ** SIDE EFFECTS:
  2945. **
  2946. ** icon value is created
  2947. **
  2948. **--
  2949. **/
  2950. void sar_make_color(target_frame, color_frame, mono_frame, keyword_frame)
  2951. yystype *target_frame;
  2952. yystype *color_frame;
  2953. yystype *mono_frame;
  2954. yystype *keyword_frame;
  2955. {
  2956. sym_value_entry_type *color_entry;
  2957. sym_value_entry_type *value_entry;
  2958. int state;
  2959. /*
  2960. ** Mono frame can point to the keyword FOREGROUND or BACKGROUND
  2961. ** or be null meaning unspecified.
  2962. */
  2963. switch (mono_frame->b_tag)
  2964. {
  2965. case sar_k_null_frame:
  2966. state = sym_k_unspecified_color;
  2967. break;
  2968. case sar_k_token_frame:
  2969. switch (mono_frame->value.az_keyword_entry->b_token)
  2970. {
  2971. case BACKGROUND:
  2972. state = sym_k_background_color;
  2973. break;
  2974. case FOREGROUND:
  2975. state = sym_k_foreground_color;
  2976. break;
  2977. default:
  2978. _assert( FALSE, "monochrome info missing" );
  2979. }
  2980. break;
  2981. default:
  2982. _assert( FALSE, "monochrome info missing" );
  2983. }
  2984. /*
  2985. ** Transform the char 8 value entry into a color value.
  2986. ** Before doing this, we need to insure that the string
  2987. ** is not in error or named.
  2988. */
  2989. _assert( color_frame->b_tag == sar_k_value_frame, "value missing" );
  2990. color_entry =
  2991. sem_create_value_entry
  2992. ( "",
  2993. 0,
  2994. sym_k_color_value );
  2995. color_entry->b_type = sym_k_color_value;
  2996. color_entry->obj_header.b_flags = sym_m_private;
  2997. color_entry->b_arg_type = state;
  2998. color_entry->b_expr_opr = sym_k_coerce_op;
  2999. if ((color_frame->b_flags & sym_m_forward_ref) != 0)
  3000. sym_make_value_forward_ref (color_frame,
  3001. (char*)&(color_entry->az_exp_op1),
  3002. sym_k_patch_add);
  3003. else
  3004. {
  3005. value_entry =
  3006. (sym_value_entry_type *) color_frame->value.az_symbol_entry;
  3007. color_entry->az_exp_op1 = value_entry;
  3008. }
  3009. /*
  3010. ** initialize the target frame
  3011. */
  3012. _sar_move_source_info( target_frame, keyword_frame );
  3013. target_frame->b_tag = sar_k_value_frame;
  3014. target_frame->b_type = sym_k_color_value;
  3015. target_frame->b_flags = sym_m_private;
  3016. target_frame->value.az_symbol_entry =
  3017. (sym_entry_type *) color_entry;
  3018. }
  3019. /*
  3020. **++
  3021. ** FUNCTIONAL DESCRIPTION:
  3022. **
  3023. ** This function builds a icon value. Input to the function is a
  3024. ** color table and a list of string that represent the rows of the
  3025. ** icon.
  3026. **
  3027. ** FORMAL PARAMETERS:
  3028. **
  3029. ** target_frame frame to hold the created icon value
  3030. ** table_frame frame describing the color table
  3031. ** list_frame frame pointing to the list of row strings
  3032. ** keyword_frame frame pointing to the icon keyword
  3033. **
  3034. ** IMPLICIT INPUTS:
  3035. **
  3036. ** none
  3037. **
  3038. ** IMPLICIT OUTPUTS:
  3039. **
  3040. ** target_frame
  3041. **
  3042. ** FUNCTION VALUE:
  3043. **
  3044. ** void
  3045. **
  3046. ** SIDE EFFECTS:
  3047. **
  3048. ** icon value is created
  3049. **
  3050. **--
  3051. **/
  3052. void sar_make_icon(target_frame, list_frame, table_frame, keyword_frame)
  3053. yystype *target_frame;
  3054. yystype *table_frame;
  3055. yystype *list_frame;
  3056. yystype *keyword_frame;
  3057. {
  3058. sym_value_entry_type *table_entry;
  3059. sym_value_entry_type *icon_entry;
  3060. sym_value_entry_type *head_row_entry;
  3061. int target_type;
  3062. int width;
  3063. int height;
  3064. /*
  3065. ** Table_frame specifies the color table for the icon. If this
  3066. ** argument is null, use the standard color table.
  3067. */
  3068. target_type = sym_k_icon_value;
  3069. height = 0;
  3070. width = 0;
  3071. switch (table_frame->b_tag)
  3072. {
  3073. case sar_k_null_frame:
  3074. table_entry = standard_color_table();
  3075. break;
  3076. case sar_k_value_frame:
  3077. table_entry =
  3078. (sym_value_entry_type *) table_frame->value.az_symbol_entry;
  3079. /*
  3080. ** Check that the table is indeed a color table
  3081. ** Forward references are set up once the icon entry is created
  3082. */
  3083. if ((table_frame->b_flags & sym_m_forward_ref) != 0)
  3084. table_entry = NULL;
  3085. else
  3086. switch (table_entry->b_type)
  3087. {
  3088. case sym_k_color_table_value:
  3089. break;
  3090. case sym_k_error_value:
  3091. default:
  3092. /* BEGIN OSF Fix CR 5421 */
  3093. /*
  3094. * If the value_frame is not a color_table_value, print
  3095. * a diagnostic to flag it as an error further down the
  3096. * road. Otherwise, if it is exported, will cause problems.
  3097. */
  3098. diag_issue_diagnostic
  3099. ( d_wrong_type,
  3100. _sar_source_position(table_frame),
  3101. diag_value_text(table_entry->b_type),
  3102. diag_value_text(sym_k_color_table_value) );
  3103. /* END OSF Fix CR 5421 */
  3104. target_type = sym_k_error_value;
  3105. table_entry = standard_color_table();
  3106. break;
  3107. }
  3108. break;
  3109. default:
  3110. _assert( FALSE, "color table missing" );
  3111. }
  3112. /*
  3113. ** Now start checking the rows of the table. If the tag on list
  3114. ** frame is null, there are no rows (this is due to prior errors).
  3115. ** Rows are linked in reverse order. We reorder them at this
  3116. ** point since it simplifies .uid generation.
  3117. */
  3118. switch (list_frame->b_tag)
  3119. {
  3120. case sar_k_null_frame:
  3121. target_type = sym_k_error_value;
  3122. break;
  3123. case sar_k_value_frame:
  3124. {
  3125. sym_value_entry_type *row_entry;
  3126. sym_value_entry_type *temp_row_entry;
  3127. /*
  3128. ** Reorder the rows
  3129. */
  3130. for (row_entry =
  3131. (sym_value_entry_type *) list_frame->value.az_symbol_entry,
  3132. head_row_entry = NULL;
  3133. row_entry != NULL;
  3134. temp_row_entry = row_entry,
  3135. row_entry = row_entry->az_next_table_value,
  3136. temp_row_entry->az_next_table_value =
  3137. head_row_entry,
  3138. head_row_entry = temp_row_entry)
  3139. ;
  3140. for (row_entry = head_row_entry,
  3141. width = row_entry->w_length;
  3142. row_entry != NULL;
  3143. row_entry = row_entry->az_next_table_value)
  3144. {
  3145. /* BEGIN OSF Fix CR 5420 */
  3146. /*
  3147. * Check to make sure each row_entry is a character string.
  3148. * If it isn't, print a diagnostic message indicating an error.
  3149. */
  3150. if ((row_entry->b_type != sym_k_char_8_value) &&
  3151. (row_entry->b_type != sym_k_localized_string_value))
  3152. {
  3153. diag_issue_diagnostic
  3154. ( d_wrong_type,
  3155. _sar_source_pos2(row_entry),
  3156. diag_value_text(row_entry->b_type),
  3157. diag_value_text(sym_k_char_8_value) );
  3158. target_type = sym_k_error_value;
  3159. }
  3160. /* END OSF Fix CR 5420 */
  3161. height++;
  3162. if (width != row_entry->w_length)
  3163. {
  3164. diag_issue_diagnostic
  3165. ( d_icon_width,
  3166. row_entry->header.az_src_rec, /* line info */
  3167. row_entry->header.b_type, /* column infor */
  3168. height );
  3169. target_type = sym_k_error_value;
  3170. }
  3171. }
  3172. break;
  3173. }
  3174. default:
  3175. _assert( FALSE, "row list missing" );
  3176. }
  3177. if (width > sym_k_max_list_count)
  3178. {
  3179. diag_issue_diagnostic
  3180. ( d_too_many,
  3181. _sar_source_position( keyword_frame ),
  3182. "column", diag_value_text( sym_k_icon_value ),
  3183. sym_k_max_list_count );
  3184. target_type = sym_k_error_value;
  3185. }
  3186. if (height > sym_k_max_list_count)
  3187. {
  3188. diag_issue_diagnostic
  3189. ( d_too_many,
  3190. _sar_source_position( keyword_frame ),
  3191. "row", diag_value_text( sym_k_icon_value ),
  3192. sym_k_max_list_count );
  3193. target_type = sym_k_error_value;
  3194. }
  3195. /*
  3196. ** If we have no errors, allocate the icon
  3197. */
  3198. if (target_type == sym_k_error_value)
  3199. icon_entry = sym_az_error_value_entry;
  3200. else
  3201. {
  3202. icon_entry = (sym_value_entry_type *)
  3203. sem_allocate_node (sym_k_value_entry, sym_k_value_entry_size);
  3204. icon_entry->value.z_icon = (sym_icon_element *)
  3205. XtCalloc(1,sizeof(sym_icon_element));
  3206. icon_entry->b_type = sym_k_icon_value;
  3207. icon_entry->value.z_icon->w_height = height;
  3208. icon_entry->value.z_icon->w_width = width;
  3209. icon_entry->value.z_icon->az_color_table = table_entry;
  3210. icon_entry->value.z_icon->az_rows = head_row_entry;
  3211. icon_entry->obj_header.b_flags = sym_m_private;
  3212. _sar_save_source_pos (&icon_entry->header, list_frame );
  3213. if ((table_frame->b_flags & sym_m_forward_ref) != 0)
  3214. sym_make_value_forward_ref
  3215. (table_frame,
  3216. (char*)&icon_entry->value.z_icon->az_color_table,
  3217. sym_k_patch_add);
  3218. }
  3219. /*
  3220. ** initialize the target frame
  3221. */
  3222. _sar_move_source_info( target_frame, keyword_frame );
  3223. target_frame->b_tag = sar_k_value_frame;
  3224. target_frame->b_type = target_type;
  3225. target_frame->b_flags = sym_m_private;
  3226. target_frame->value.az_symbol_entry =
  3227. (sym_entry_type *) icon_entry;
  3228. }
  3229. /*
  3230. **++
  3231. ** FUNCTIONAL DESCRIPTION:
  3232. **
  3233. ** This function defines the standard color table.
  3234. **
  3235. ** FORMAL PARAMETERS:
  3236. **
  3237. ** none
  3238. **
  3239. ** IMPLICIT INPUTS:
  3240. **
  3241. ** color_table local static storage
  3242. **
  3243. ** IMPLICIT OUTPUTS:
  3244. **
  3245. ** none
  3246. **
  3247. ** FUNCTION VALUE:
  3248. **
  3249. ** address of standard color table entry
  3250. **
  3251. ** SIDE EFFECTS:
  3252. **
  3253. ** may allocate the standard color table
  3254. **
  3255. **--
  3256. **/
  3257. static sym_value_entry_type *standard_color_table()
  3258. {
  3259. static sym_value_entry_type *color_table = NULL;
  3260. if (color_table == NULL)
  3261. {
  3262. color_table = (sym_value_entry_type *)
  3263. sem_allocate_node (sym_k_value_entry,
  3264. sym_k_value_entry_size);
  3265. color_table->value.z_color = (sym_color_element *)
  3266. XtCalloc(1,sizeof(sym_color_element)*2);
  3267. color_table->b_type = sym_k_color_table_value;
  3268. color_table->b_table_count = 2;
  3269. color_table->b_max_index = 1;
  3270. color_table->obj_header.b_flags = sym_m_private;
  3271. color_table->header.az_src_rec = src_az_module_source_record;
  3272. color_table->value.z_color[0].b_index = URMColorTableBG;
  3273. color_table->value.z_color[0].b_letter = ' ';
  3274. color_table->value.z_color[0].az_color =
  3275. (sym_value_entry_type *) URMColorTableBG;
  3276. color_table->value.z_color[1].b_index = URMColorTableFG;
  3277. color_table->value.z_color[1].b_letter = '*';
  3278. color_table->value.z_color[1].az_color =
  3279. (sym_value_entry_type *) URMColorTableFG;
  3280. }
  3281. return color_table;
  3282. }