ooRexx  4.2.0-source
About: ooRexx (Open Object Rexx) is a free implementation of Object Rexx. Object Rexx is an enhancement of the classic Rexx interpreter; a full-featured programming language with a human-oriented syntax.
  Fossies Dox: ooRexx-4.2.0-source.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

RexxVariableDictionary.cpp
Go to the documentation of this file.
1 /*----------------------------------------------------------------------------*/
2 /* */
3 /* Copyright (c) 1995, 2004 IBM Corporation. All rights reserved. */
4 /* Copyright (c) 2005-2009 Rexx Language Association. All rights reserved. */
5 /* */
6 /* This program and the accompanying materials are made available under */
7 /* the terms of the Common Public License v1.0 which accompanies this */
8 /* distribution. A copy is also available at the following address: */
9 /* http://www.oorexx.org/license.html */
10 /* */
11 /* Redistribution and use in source and binary forms, with or */
12 /* without modification, are permitted provided that the following */
13 /* conditions are met: */
14 /* */
15 /* Redistributions of source code must retain the above copyright */
16 /* notice, this list of conditions and the following disclaimer. */
17 /* Redistributions in binary form must reproduce the above copyright */
18 /* notice, this list of conditions and the following disclaimer in */
19 /* the documentation and/or other materials provided with the distribution. */
20 /* */
21 /* Neither the name of Rexx Language Association nor the names */
22 /* of its contributors may be used to endorse or promote products */
23 /* derived from this software without specific prior written permission. */
24 /* */
25 /* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS */
26 /* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT */
27 /* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS */
28 /* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT */
29 /* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
30 /* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED */
31 /* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
32 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY */
33 /* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
34 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS */
35 /* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
36 /* */
37 /*----------------------------------------------------------------------------*/
38 /******************************************************************************/
39 /* REXX Kernel RexxVariableDictionary.cpp */
40 /* */
41 /* Primitive Variable Dictionary Class */
42 /* */
43 /******************************************************************************/
44 #include "RexxCore.h"
45 #include "StringClass.hpp"
46 #include "DirectoryClass.hpp"
47 #include "RexxNativeActivation.hpp"
48 #include "RexxActivity.hpp"
49 #include "ArrayClass.hpp"
50 #include "ListClass.hpp"
52 #include "StemClass.hpp"
54 #include "ExpressionStem.hpp"
55 #include "ExpressionVariable.hpp"
58 #include "ProtectedObject.hpp"
59 #include "SupplierClass.hpp"
60 #include "RexxCompoundTail.hpp"
61 #include "SourceFile.hpp"
62 
63 
65 /******************************************************************************/
66 /* Function: Copy a variable dictionary */
67 /******************************************************************************/
68 {
69  /* create a new object */
71  /* copy the behaviour pointer */
72  OrefSet(copyObj, copyObj->behaviour, this->behaviour);
73  ProtectedObject p(copyObj);
74  /* copy the hash table */
75  OrefSet(copyObj, copyObj->contents, (RexxHashTable *)this->contents->copy());
76  /* make sure we copy the scope too */
77  OrefSet(copyObj, copyObj->scope, this->scope);
78  copyObj->copyValues(); /* copy all of the variables */
79  return(RexxObject *)copyObj; /* return the new vdict */
80 }
81 
83 /******************************************************************************/
84 /* Function: Copy all of the values in a vdict */
85 /******************************************************************************/
86 {
87  /* loop through the hash table */
88  for (size_t i = this->contents->first();
89  i < this->contents->totalSlotsSize();
90  i = this->contents->next(i))
91  {
92  RexxObject *value = this->contents->value(i); /* get the next value */
93  RexxObject *copyObj = value->copy(); /* copy the value */
94  this->contents->replace(copyObj, i); /* replace with the copied value */
95  }
96 }
97 
99  RexxString *name) /* name of variable to retrieve */
100 /******************************************************************************/
101 /* Function: Retrieve a variable's value WITHOUT returning the default */
102 /* variable name if it doesn't exist. */
103 /******************************************************************************/
104 {
105  RexxVariable *variable = resolveVariable(name); /* look up the name */
106  if (variable == OREF_NULL) /* not found? */
107  {
108  return OREF_NULL; /* say so */
109  }
110  return variable->getVariableValue(); /* use the variable value */
111 }
112 
113 
120 {
121  // if the variable exists, drop the value
122  RexxVariable *variable = resolveVariable(name);
123  if (variable != OREF_NULL)
124  {
125  variable->drop();
126  }
127 }
128 
129 
136 {
137  // if the variable exists, drop the value
138  RexxVariable *variable = resolveVariable(name);
139  if (variable != OREF_NULL)
140  {
141  variable->drop();
142  /* create a new stem element and set this */
143  variable->set(new RexxStem(name));
144  }
145 }
146 
147 
149  RexxString *stemName, /* name of stem for compound */
150  RexxObject **tail, /* tail of the compound element */
151  size_t tailCount) /* number of tail pieces */
152 /******************************************************************************/
153 /* Function: Retrieve a compound variable, returning OREF_NULL if the */
154 /* variable does not exist. */
155 /******************************************************************************/
156 {
157  /* new tail for compound */
158  RexxCompoundTail resolved_tail(this, tail, tailCount);
159 
160  RexxStem *stem_table = getStem(stemName); /* get the stem entry from this dictionary */
161  /* get the compound variable */
162  return stem_table->getCompoundVariable(&resolved_tail);
163 }
164 
165 
167  RexxString *stemName, /* name of stem for compound */
168  RexxObject **tail, /* tail of the compound element */
169  size_t tailCount) /* number of tail pieces */
170 /******************************************************************************/
171 /* Function: Retrieve a compound variable, returning default value if the */
172 /* variable does not exist. This does not raise NOVALUE. */
173 /******************************************************************************/
174 {
175  /* new tail for compound */
176  RexxCompoundTail resolved_tail(this, tail, tailCount);
177 
178  RexxStem *stem_table = getStem(stemName); /* get the stem entry from this dictionary */
179  /* get the value from the stem...we pass OREF_NULL */
180  /* for the dictionary to bypass NOVALUE handling */
181  return stem_table->evaluateCompoundVariableValue(OREF_NULL, stemName, &resolved_tail);
182 }
183 
184 
198  RexxObject **tail, size_t tailCount)
199 {
200  /* new tail for compound */
201  RexxCompoundTail resolved_tail(this, tail, tailCount);
202 
203  RexxStem *stem_table = getStem(stem); /* get the stem entry from this dictionary */
204  /* get the value from the stem...we pass OREF_NULL */
205  /* for the dictionary to bypass NOVALUE handling */
206  return stem_table->getCompoundVariableRealValue(&resolved_tail);
207 }
208 
209 
211  RexxString *stemName) /* name of stem for compound */
212 /******************************************************************************/
213 /* Function: Retrieve the "real" value of a stem variable. OREF_NULL is */
214 /* returned if the stem does not exist. */
215 /******************************************************************************/
216 {
217  /* look up the name */
218  return this->getStem(stemName); /* find and return the stem directly */
219 }
220 
221 
223  RexxVariable *variable, /* new variable entry */
224  RexxString *name) /* variable name */
225 /******************************************************************************/
226 /* Function: Insert an item into the variable dictionary hash table, */
227 /* updating the lookaside array if the index is available. */
228 /******************************************************************************/
229 {
230  /* try to place in existing hashtab */
231  RexxHashTable *new_hash = this->contents->stringAdd((RexxObject *)variable, name);
232  if (new_hash != OREF_NULL) /* have a reallocation occur? */
233  {
234  /* hook on the new hash table */
235  OrefSet(this, this->contents, new_hash);
236  }
237 }
238 
240  RexxVariable *variable, /* new variable entry */
241  RexxString *name) /* variable name */
242 /******************************************************************************/
243 /* Function: Insert an item into the variable dictionary hash table, */
244 /* updating the lookaside array if the index is available. */
245 /******************************************************************************/
246 {
247  /* try to place in existing hashtab */
248  RexxHashTable *new_hash = this->contents->stringPut((RexxObject *)variable, name);
249  if (new_hash != OREF_NULL) /* have a reallocation occur? */
250  {
251  /* hook on the new hash table */
252  OrefSet(this, this->contents, new_hash);
253  }
254 }
255 
256 
258  RexxString *stemName) /* name of target stem */
259 /******************************************************************************/
260 /* Function: Lookup and retrieve a STEM variable item (not the stem table) */
261 /* level) */
262 /******************************************************************************/
263 {
264  RexxVariable *variable = new_variable(stemName); /* make a new variable entry */
265  RexxStem *stemtable = new RexxStem (stemName); /* create a stem object as value */
266  /* the stem object is the value of */
267  /* stem variable */
268  variable->set((RexxObject *)stemtable);
269  /* try to place in existing hashtab */
270  RexxHashTable *new_hash = this->contents->stringAdd((RexxObject *)variable, stemName);
271  if (new_hash != OREF_NULL) /* have a reallocation occur? */
272  {
273  /* hook on the new hash table */
274  OrefSet(this, this->contents, new_hash);
275  }
276  return variable; /* return the stem */
277 }
278 
279 
281  RexxString *name) /* name of target variable */
282 /******************************************************************************/
283 /* Function: Create a new variable item and add it to the dictionary. */
284 /******************************************************************************/
285 {
286  RexxVariable *variable = new_variable(name); /* make a new variable entry */
287  /* try to place in existing hashtab */
288  RexxHashTable *new_hash = this->contents->stringAdd((RexxObject *)variable, name);
289  if (new_hash != OREF_NULL) /* have a reallocation occur? */
290  {
291  /* hook on the new hash table */
292  OrefSet(this, this->contents, new_hash);
293  }
294  return variable; /* return the stem */
295 }
296 
298  RexxNativeActivation *activation) /* Hosting Native Act. */
299 /******************************************************************************/
300 /* Function: Return the "next" variable of a variable traversal */
301 /******************************************************************************/
302 {
303  if (activation->nextVariable() == SIZE_MAX)/* first time through? */
304  {
305  /* get the first item */
306  activation->setNextVariable(this->contents->first());
307  }
308  else /* step to the next index item */
309  {
310  activation->setNextVariable(this->contents->next(activation->nextVariable()));
311  }
312  /* while more directory entries */
313  while (this->contents->index(activation->nextVariable()) != OREF_NULL)
314  {
315  /* get the variable object */
316  RexxVariable *variable = (RexxVariable *)this->contents->value(activation->nextVariable());
317  /* get the value */
318  RexxObject *value = variable->getVariableValue();
319  if (value != OREF_NULL)
320  { /* not a dropped variable? */
321  return variable; /* got what we need */
322  }
323  /* step to the next index item */
324  activation->setNextVariable(this->contents->next(activation->nextVariable()));
325  }
326  activation->setNextVariable(-1); /* reset the index for the end */
327  return OREF_NULL;
328 }
329 
331  RexxString *name, /* name to set */
332  RexxObject *value) /* value to assign to variable name */
333 /******************************************************************************/
334 /* Function: Set a new variable value */
335 /******************************************************************************/
336 {
337  RexxVariable *variable; /* retrieved variable item */
338 
339  variable = getVariable(name); /* look up the name */
340  variable->set(value); /* and perform the set */
341 }
342 
344  RexxActivity *activity) /* reserving activity */
345 /******************************************************************************/
346 /* Function: Reserve a scope on an object, waiting for completion if this */
347 /* is already reserved by another activity */
348 /******************************************************************************/
349 {
350  /* currently unlocked? */
351  if (this->reservingActivity == OREF_NULL)
352  {
353  /* set the locker */
354  OrefSet(this, this->reservingActivity, activity);
355  this->reserveCount = 1; /* we're reserved once */
356  }
357  /* doing again on the same stack? */
358  else if (this->reservingActivity == activity)
359  {
360  this->reserveCount++; /* bump the nesting count */
361  }
362  else
363  { /* need to wait on this */
364  /* go perform dead lock checks */
365  this->reservingActivity->checkDeadLock(activity);
366  /* no list here? */
367  if (this->waitingActivities == OREF_NULL)
368  {
369  /* get a waiting queue */
370  OrefSet(this, this->waitingActivities, new_list());
371  }
372  /* add to the wait queue */
373  this->waitingActivities->addLast((RexxObject *)activity);
374  /* ok, now we wait */
375  activity->waitReserve((RexxObject *)this);
376  }
377 }
378 
380  RexxActivity *activity) /* reserving activity */
381 /******************************************************************************/
382 /* Function: Release the lock on an object's ovd */
383 /******************************************************************************/
384 {
385  this->reserveCount--; /* decrement the reserving count */
386  if (this->reserveCount == 0)
387  { /* last one for this activity? */
388  /* remove the current reserver */
389  OrefSet(this, this->reservingActivity, OREF_NULL);
390  /* have things waiting? */
391  if (this->waitingActivities != OREF_NULL)
392  {
393  /* get the next one */
394  RexxActivity *newActivity = (RexxActivity *)this->waitingActivities->removeFirst();
395  /* have a real one here? */
396  if (newActivity != (RexxActivity *)TheNilObject)
397  {
398  /* this is the new owner */
399  OrefSet(this, this->reservingActivity, newActivity);
400  this->reserveCount = 1; /* back to one lock again */
401  /* wake up the waiting activity */
402  newActivity->postDispatch();
403  }
404  }
405  }
406 }
407 
408 
410  RexxActivity *activity) /* new reserving activity */
411 /******************************************************************************/
412 /* Function: Transfer a vdict lock to another activity */
413 /******************************************************************************/
414 {
415  if (this->reserveCount == 1)
416  { /* only one level of nesting? */
417  /* easy, just switch the owner */
418  OrefSet(this, this->reservingActivity, activity);
419  return true; /* say this worked */
420  }
421  else
422  { /* multiple nesting levels */
423  this->release(activity); /* release this lock */
424  return false; /* can't do this */
425  }
426 }
427 
428 
430 /******************************************************************************/
431 /* Function: Chain up a dictionary associated with an object */
432 /******************************************************************************/
433 {
434  OrefSet(this, this->next, _next);
435 }
436 
437 void RexxVariableDictionary::live(size_t liveMark)
438 /******************************************************************************/
439 /* Function: Normal garbage collection live marking */
440 /******************************************************************************/
441 {
442  memory_mark(this->contents);
445  memory_mark(this->next);
446  memory_mark(this->scope);
447 }
448 
450 /******************************************************************************/
451 /* Function: Generalized object marking */
452 /******************************************************************************/
453 {
457  memory_mark_general(this->next);
458  memory_mark_general(this->scope);
459 }
460 
461 
469 {
470  HashLink i;
471  RexxDirectory *result = new_directory();
472  ProtectedObject p1(result);
473  /* loop through the hash table */
474  for (i = this->contents->first();
475  i < this->contents->totalSlotsSize();
476  i = this->contents->next(i))
477  {
478  // get the next variable from the dictionary
479  RexxVariable *variable = (RexxVariable *)this->contents->value(i);
480  // if this variable has a value, bump the count
481  if (variable->getVariableValue() != OREF_NULL)
482  {
483  result->put(variable->getVariableValue(), variable->getName());
484  }
485  }
486 
487  return result;
488 }
489 
490 
492 /******************************************************************************/
493 /* Function: Flatten an object */
494 /******************************************************************************/
495 {
497 
498  flatten_reference(newThis->contents, envelope);
499  flatten_reference(newThis->reservingActivity, envelope);
500  flatten_reference(newThis->waitingActivities, envelope);
501  flatten_reference(newThis->next, envelope);
502  flatten_reference(newThis->scope, envelope);
504 }
505 
506 
508  size_t looksize) /* expected size of the vdict */
509 /******************************************************************************/
510 /* Function: Create a new translator object */
511 /******************************************************************************/
512 {
513  /* Get new object */
514  /* NOTE: there is one extra */
515  /* lookaside element allocated, */
516  /* which is used for non-lookaside */
517  /* lookups. Using this extra element*/
518  /* (which is always NULL), allows */
519  /* some special optimization of the */
520  /* look ups */
521  /* get a new object and hash */
523 }
524 
525 
527  RexxObject *scope) /* expected size of the vdict */
528 /******************************************************************************/
529 /* Function: Create a new translator object */
530 /******************************************************************************/
531 {
532  /* create entries for twice size */
533  size_t hashTabSize = DEFAULT_OBJECT_DICTIONARY_SIZE * 2;
534  /* Get new object */
535  /* NOTE: there is one extra */
536  /* lookaside element allocated, */
537  /* which is used for non-lookaside */
538  /* lookups. Using this extra element*/
539  /* (which is always NULL), allows */
540  /* some special optimization of the */
541  /* look ups */
542  /* get a new object and hash */
544  newObj->scope = scope; /* fill in the scope */
545  return newObj; /* return the new vdict */
546 }
547 
548 
557 void RexxVariableDictionary::setCompoundVariable(RexxString *stemName, RexxObject **tail, size_t tailCount, RexxObject *value)
558 {
559  /* new tail for compound */
560  RexxCompoundTail resolved_tail(this, tail, tailCount);
561 
562  RexxStem *stem_table = getStem(stemName); /* get the stem entry from this dictionary */
563  /* and set the value */
564  stem_table->setCompoundVariable(&resolved_tail, value);
565 }
566 
567 
576 void RexxVariableDictionary::dropCompoundVariable(RexxString *stemName, RexxObject **tail, size_t tailCount)
577 {
578  /* new tail for compound */
579  RexxCompoundTail resolved_tail(this, tail, tailCount);
580 
581  RexxStem *stem_table = getStem(stemName); /* get the stem entry from this dictionary */
582  /* and set the value */
583  stem_table->dropCompoundVariable(&resolved_tail);
584 }
585 
586 
588  RexxString *variable ) /* name of the variable */
589 /******************************************************************************/
590 /* Arguments: Name of variable to generate retriever */
591 /* */
592 /* Returned: Retriever for variable (returns OREF_NULL for invalids) */
593 /******************************************************************************/
594 {
595  variable = variable->upper(); /* upper case the variable */
596  int type = variable->isSymbol(); /* validate the symbol */
597  /* create a retriever object */
598  switch (type)
599  {
600  case STRING_BAD_VARIABLE: /* if it didn't validate */
601  return OREF_NULL; /* don't return a retriever object */
602 
603  case STRING_LITERAL_DOT: /* if is is a literal */
604  case STRING_NUMERIC:
605  /* these are literals */
606  return(RexxVariableBase *)variable;
607 
608  // Dot variables retrieve from the environment
609  case STRING_LITERAL:
610  // this is only a dot variable if it begins with a period
611  if (variable->getChar(0) == '.')
612  {
613  return (RexxVariableBase *)new RexxDotVariable(variable->extract(1, variable->getLength() - 1));
614  }
615  // this is a literal symbol not beginning with a period
616  return (RexxVariableBase *)variable;
617 
618  /* if it is a stem */
619  case STRING_STEM:
620  /* create a new stem retriever */
621  return(RexxVariableBase *)new RexxStemVariable(variable, 0);
622  /* if it is a compound */
624  /* create a new compound retriever */
625  return(RexxVariableBase *)buildCompoundVariable(variable, false);
626  /* if it is a simple */
627  case STRING_NAME:
628  /* create a new variable retriever */
629  return(RexxVariableBase *)new RexxParseVariable(variable, 0);
630  /* if we don't know what it is */
631  default:
632  return OREF_NULL; /* don't return a retriever object */
633  }
634 }
635 
636 
638  RexxString *variable ) /* name of the variable */
639 /******************************************************************************/
640 /* Function: Return a retriever for a variable using direct access (i.e. */
641 /* no substitution in compound variable tails) */
642 /******************************************************************************/
643 {
644  size_t length = variable->getLength(); /* get the name length */
645  /* get the first character */
646  char character = variable->getChar(0);
647  bool literal = false; /* literal indicator */
648  /* constant symbol? */
649  if (character == '.' || (character >= '0' && character <= '9'))
650  {
651  literal = true; /* this is a literal value */
652  }
653  /* have a valid length? */
654  if (length <= (size_t)MAX_SYMBOL_LENGTH && length > 0)
655  {
656  size_t compound = 0; /* no periods yet */
657  size_t scan = 0; /* start at string beginning */
658  size_t nonnumeric = 0; /* count of non-numeric characters */
659  char last = 0; /* no last character */
660  while (scan < length)
661  {
662  /* get the next character */
663  character = variable->getChar(scan);
664  /* have a period? */
665  if (character == '.')
666  {
667  if (!literal) /* not a literal value? */
668  {
669  /* don't process past here */
670  return(RexxVariableBase *)buildCompoundVariable(variable, true);
671  }
672  else
673  {
674  compound++; /* count the character */
675  }
676  }
677  /* may have a special character */
678  else if (!RexxSource::isSymbolCharacter(character))
679  {
680  /* maybe exponential form? */
681  if (character == '+' || character == '-')
682  {
683  /* front part not valid? */
684  if (compound > 1 || nonnumeric > 1 || last != 'E')
685  {
686  return OREF_NULL; /* got a bad symbol */
687  }
688  scan++; /* step over the sign */
689  if (scan >= length) /* sign as last character? */
690  {
691  return OREF_NULL; /* this is bad also */
692  }
693  /* scan remainder */
694  while (scan < length)
695  {
696  /* get the next character */
697  character = variable->getChar(scan);
698  /* outside numeric range? */
699  if (character < '0' || character > '9')
700  {
701  return OREF_NULL; /* not valid either */
702  }
703  scan++; /* step scan position */
704  }
705  break; /* done with scanning */
706  }
707  else
708  {
709  // invalid character in a symbol
710  return OREF_NULL;
711  }
712  }
713  /* non-numeric character? */
714  else if (character < '0' || character > '9')
715  {
716  nonnumeric++; /* count the non-numeric */
717  }
718  /* lower case character? */
719  else if (RexxSource::translateChar(character) != character)
720  {
721  return OREF_NULL; /* this is bad, return */
722  }
723  last = character; /* remember last one */
724  scan++; /* step the pointer */
725  }
726  }
727  if (literal) /* was this a literal? */
728  {
729  /* these are both just literals */
730  return(RexxVariableBase *)variable;
731  }
732  else /* simple variable */
733  {
734  /* create a new variable retriever */
735  return(RexxVariableBase *)new RexxParseVariable(variable, 0);
736  }
737 }
738 
739 
741  RexxString *variable_name, /* full variable name of compound */
742  bool direct) /* this is direct access */
743 /******************************************************************************/
744 /* Function: Build a dynamically created compound variable */
745 /******************************************************************************/
746 {
747  size_t length = variable_name->getLength(); /* get the string length */
748  size_t position = 0; /* start scanning at first character */
749  /* scan to the first period */
750  while (variable_name->getChar(position) != '.')
751  {
752  position++; /* step to the next character */
753  length--; /* reduce the length also */
754  }
755  /* extract the stem part */
756  RexxString *stem = variable_name->extract(0, position + 1);
757  ProtectedObject p(stem);
758  /* processing to decompose the name */
759  /* into its component parts */
760 
761  RexxQueue *tails = new_queue(); /* get a new list for the tails */
762  ProtectedObject p1(tails);
763  position++; /* step past previous period */
764  length--; /* adjust the length */
765  /* direct access? */
766  if (direct == true)
767  {
768  /* extract the tail part */
769  RexxString *tail = variable_name->extract(position, length);
770  tails->push(tail); /* add to the tail piece list */
771  }
772  else
773  {
774  size_t endPosition = position + length;
775 
776  while (position < endPosition) /* process rest of the variable */
777  {
778  size_t start = position; /* save the start position */
779  /* scan for the next period */
780  while (position < endPosition && variable_name->getChar(position) != '.')
781  {
782  position++; /* step to the next character */
783  }
784  /* extract the tail part */
785  RexxString *tail = variable_name->extract(start, position - start);
786  /* have a null tail piece or */
787  /* section begin with a digit? */
788  /* ASCII '0' to '9' to recognize a digit */
789 
790  RexxObject *tailPart;
791  if (tail->getLength() == 0 || (tail->getChar(0) >= '0' && tail->getChar(0) <= '9'))
792  {
793  tailPart = (RexxObject *)tail; /* this is a literal piece */
794  }
795  else
796  {
797  /* create a new variable retriever */
798  tailPart = (RexxObject *)new RexxParseVariable(tail, 0);
799  }
800  tails->push(tailPart); /* add to the tail piece list */
801  position++; /* step past previous period */
802  }
803  /* have a trailing period? */
804  if (variable_name->getChar(position - 1) == '.')
805  {
806  tails->push(OREF_NULLSTRING); /* add to the tail piece list */
807  }
808  }
809  /* create and return a new compound */
810  return(RexxObject *)new (tails->getSize()) RexxCompoundVariable(stem, 0, tails, tails->getSize());
811 }
RexxVariableDictionary::copyValues
void copyValues()
Definition: RexxVariableDictionary.cpp:82
RexxObject::copy
RexxObject * copy()
Definition: ObjectClass.cpp:518
RexxHashTable::value
RexxObject * value(HashLink position)
Definition: RexxHashTable.cpp:1447
RexxCompoundElement
Definition: RexxCompoundElement.hpp:50
RexxVariableDictionary::reserveCount
unsigned short reserveCount
Definition: RexxVariableDictionary.hpp:145
RexxVariableDictionary::scope
RexxObject * scope
Definition: RexxVariableDictionary.hpp:147
RexxVariableDictionary::resolveVariable
RexxVariable * resolveVariable(RexxString *name)
Definition: RexxVariableDictionary.hpp:76
RexxList::removeFirst
RexxObject * removeFirst()
Definition: ListClass.hpp:109
STRING_NAME
#define STRING_NAME
Definition: StringClass.hpp:59
RexxVariableDictionary::flatten
void flatten(RexxEnvelope *envelope)
Definition: RexxVariableDictionary.cpp:491
RexxVariableDictionary::getStem
RexxStem * getStem(RexxString *stemName)
Definition: RexxVariableDictionary.hpp:72
RexxVariableDictionary::liveGeneral
void liveGeneral(int reason)
Definition: RexxVariableDictionary.cpp:449
memory_mark_general
#define memory_mark_general(oref)
Definition: RexxMemory.hpp:437
RexxQueue
Definition: QueueClass.hpp:49
RexxInternalObject::behaviour
RexxBehaviour * behaviour
Definition: ObjectClass.hpp:306
type
int type
Definition: cmdparse.cpp:1965
OrefSet
#define OrefSet(o, r, v)
Definition: RexxCore.h:94
RexxVariableDictionary::release
void release(RexxActivity *)
Definition: RexxVariableDictionary.cpp:379
RexxVariableDictionary::createStemVariable
RexxVariable * createStemVariable(RexxString *stemName)
Definition: RexxVariableDictionary.cpp:257
ExpressionCompoundVariable.hpp
RexxString::isSymbol
int isSymbol()
Definition: StringClassMisc.cpp:55
RexxInternalObject::copy
virtual RexxObject * copy()
Definition: ObjectClass.cpp:478
RexxVariableDictionary::waitingActivities
RexxList * waitingActivities
Definition: RexxVariableDictionary.hpp:143
RexxHashTable::stringPut
RexxHashTable * stringPut(RexxObject *value, RexxString *key)
Definition: RexxHashTable.cpp:1300
RexxStem::dropCompoundVariable
void dropCompoundVariable(RexxCompoundTail *name)
Definition: StemClass.cpp:600
RexxVariableDictionary::createVariable
RexxVariable * createVariable(RexxString *stemName)
Definition: RexxVariableDictionary.cpp:280
RexxNativeActivation::nextVariable
size_t nextVariable()
Definition: RexxNativeActivation.hpp:122
SupplierClass.hpp
ListClass.hpp
RexxHashTable::stringAdd
RexxHashTable * stringAdd(RexxObject *value, RexxString *key)
Definition: RexxHashTable.cpp:1248
RexxNativeActivation.hpp
STRING_COMPOUND_NAME
#define STRING_COMPOUND_NAME
Definition: StringClass.hpp:55
RexxActivity::postDispatch
void postDispatch()
Definition: RexxActivity.cpp:1834
RexxString::getLength
size_t getLength()
Definition: StringClass.hpp:330
RexxStem::setCompoundVariable
void setCompoundVariable(RexxCompoundTail *name, RexxObject *value)
Definition: StemClass.cpp:640
RexxVariableDictionary::getVariable
RexxVariable * getVariable(RexxString *name)
Definition: RexxVariableDictionary.hpp:81
RexxVariableDictionary::getDirectVariableRetriever
static RexxVariableBase * getDirectVariableRetriever(RexxString *variable)
Definition: RexxVariableDictionary.cpp:637
RexxVariableDictionary::reserve
void reserve(RexxActivity *)
Definition: RexxVariableDictionary.cpp:343
new_hashCollection
RexxTable * new_hashCollection(size_t s, size_t s2, size_t t)
Definition: RexxHashTable.hpp:156
RexxVariableDictionary::getCompoundVariableValue
RexxObject * getCompoundVariableValue(RexxString *stemName, RexxObject **tail, size_t tailCount)
Definition: RexxVariableDictionary.cpp:166
RexxVariableDictionary::reservingActivity
RexxActivity * reservingActivity
Definition: RexxVariableDictionary.hpp:141
RexxVariableDictionary
Definition: RexxVariableDictionary.hpp:55
RexxVariable::getName
RexxString * getName()
Definition: RexxVariable.hpp:74
RexxStem::getCompoundVariable
RexxCompoundElement * getCompoundVariable(RexxCompoundTail *name)
Definition: StemClass.cpp:540
RexxVariableBase
Definition: ExpressionBaseVariable.hpp:47
RexxSource::translateChar
static int translateChar(char ch)
Definition: SourceFile.hpp:381
DEFAULT_OBJECT_DICTIONARY_SIZE
#define DEFAULT_OBJECT_DICTIONARY_SIZE
Definition: RexxVariableDictionary.hpp:53
RexxVariableDictionary::getAllVariables
RexxDirectory * getAllVariables()
Definition: RexxVariableDictionary.cpp:468
RexxString::getChar
char getChar(size_t p)
Definition: StringClass.hpp:338
RexxEnvelope
Definition: RexxEnvelope.hpp:53
RexxVariableDictionary::transfer
bool transfer(RexxActivity *)
Definition: RexxVariableDictionary.cpp:409
new_queue
RexxQueue * new_queue()
Definition: QueueClass.hpp:89
RexxParseVariable
Definition: ExpressionVariable.hpp:49
ExpressionStem.hpp
RexxCompoundTail.hpp
RexxHashTable::replace
RexxObject * replace(RexxObject *value, HashLink position)
Definition: RexxHashTable.cpp:1597
RexxStem
Definition: StemClass.hpp:70
RexxNativeActivation::setNextVariable
void setNextVariable(size_t value)
Definition: RexxNativeActivation.hpp:138
RexxDotVariable
Definition: ExpressionDotVariable.hpp:49
OREF_NULL
#define OREF_NULL
Definition: RexxCore.h:60
RexxVariableDictionary::realValue
RexxObject * realValue(RexxString *name)
Definition: RexxVariableDictionary.cpp:98
RexxVariableDictionary::nextVariable
RexxVariable * nextVariable(RexxNativeActivation *)
Definition: RexxVariableDictionary.cpp:297
ArrayClass.hpp
RexxActivity
Definition: RexxActivity.hpp:127
ExpressionBaseVariable.hpp
STRING_BAD_VARIABLE
#define STRING_BAD_VARIABLE
Definition: StringClass.hpp:53
RexxDirectory
Definition: DirectoryClass.hpp:49
RexxSource::isSymbolCharacter
static bool isSymbolCharacter(char ch)
Definition: SourceFile.hpp:374
ProtectedObject.hpp
RexxVariableDictionary::setCompoundVariable
void setCompoundVariable(RexxString *stemName, RexxObject **tail, size_t tailCount, RexxObject *value)
Definition: RexxVariableDictionary.cpp:557
RexxHashTable::totalSlotsSize
size_t totalSlotsSize()
Definition: RexxHashTable.hpp:134
flatten_reference
#define flatten_reference(oref, envel)
Definition: RexxMemory.hpp:440
cleanUpFlatten
#define cleanUpFlatten
Definition: RexxMemory.hpp:432
ExpressionVariable.hpp
RexxHashTable::mainSlotsSize
size_t mainSlotsSize()
Definition: RexxHashTable.hpp:133
RexxActivity::checkDeadLock
void checkDeadLock(RexxActivity *)
Definition: RexxActivity.cpp:1768
ProtectedObject
Definition: ProtectedObject.hpp:46
RexxVariableDictionary::realStemValue
RexxObject * realStemValue(RexxString *stemName)
Definition: RexxVariableDictionary.cpp:210
StringClass.hpp
RexxHashTable::index
RexxObject * index(HashLink position)
Definition: RexxHashTable.cpp:1801
RexxVariableDictionary::copy
RexxObject * copy()
Definition: RexxVariableDictionary.cpp:64
RexxVariable::set
void set(RexxObject *value)
Definition: RexxVariable.hpp:67
RexxHashTable
Definition: RexxHashTable.hpp:60
STRING_LITERAL_DOT
#define STRING_LITERAL_DOT
Definition: StringClass.hpp:57
RexxDirectory::put
RexxObject * put(RexxObject *, RexxString *)
Definition: DirectoryClass.cpp:636
RexxString::extract
RexxString * extract(size_t offset, size_t sublength)
Definition: StringClass.hpp:229
STRING_STEM
#define STRING_STEM
Definition: StringClass.hpp:54
RexxQueue::push
void push(RexxObject *obj)
Definition: QueueClass.hpp:81
memory_mark
#define memory_mark(oref)
Definition: RexxMemory.hpp:436
new_variableDictionary
RexxVariableDictionary * new_variableDictionary(size_t s)
Definition: RexxVariableDictionary.hpp:151
HashLink
size_t HashLink
Definition: RexxHashTable.hpp:49
RexxVariableDictionary::set
void set(RexxString *, RexxObject *)
Definition: RexxVariableDictionary.cpp:330
RexxVariableDictionary::dropStemVariable
void dropStemVariable(RexxString *)
Definition: RexxVariableDictionary.cpp:135
STRING_LITERAL
#define STRING_LITERAL
Definition: StringClass.hpp:56
new_directory
RexxDirectory * new_directory()
Definition: DirectoryClass.hpp:101
RexxVariableDictionary::put
void put(RexxVariable *, RexxString *)
Definition: RexxVariableDictionary.cpp:239
StemClass.hpp
RexxVariableDictionary::next
RexxVariableDictionary * next
Definition: RexxVariableDictionary.hpp:146
T_VariableDictionary
Definition: ClassTypeCodes.h:127
RexxVariableDictionary::getCompoundVariable
RexxCompoundElement * getCompoundVariable(RexxString *stemName, RexxObject **tail, size_t tailCount)
Definition: RexxVariableDictionary.cpp:148
STRING_NUMERIC
#define STRING_NUMERIC
Definition: StringClass.hpp:58
new_list
RexxList * new_list()
Definition: ListClass.hpp:147
RexxStem::getCompoundVariableRealValue
RexxObject * getCompoundVariableRealValue(RexxCompoundTail *resolved_tail)
Definition: StemClass.cpp:780
RexxHashTable::next
HashLink next(HashLink position)
Definition: RexxHashTable.cpp:1573
RexxNativeActivation
Definition: RexxNativeActivation.hpp:62
setUpFlatten
#define setUpFlatten(type)
Definition: RexxMemory.hpp:427
RexxCompoundVariable
Definition: ExpressionCompoundVariable.hpp:53
TheNilObject
#define TheNilObject
Definition: RexxCore.h:180
RexxVariableDictionary::live
void live(size_t)
Definition: RexxVariableDictionary.cpp:437
RexxVariableDictionary::dropCompoundVariable
void dropCompoundVariable(RexxString *stemName, RexxObject **tail, size_t tailCount)
Definition: RexxVariableDictionary.cpp:576
RexxList::getSize
size_t getSize()
Definition: ListClass.hpp:126
RexxActivity.hpp
RexxVariableDictionary::drop
void drop(RexxString *)
Definition: RexxVariableDictionary.cpp:119
RexxVariableDictionary::getCompoundVariableRealValue
RexxObject * getCompoundVariableRealValue(RexxString *stem, RexxObject **tail, size_t tailCount)
Definition: RexxVariableDictionary.cpp:197
RexxCore.h
new_variable
RexxVariable * new_variable(RexxString *n)
Definition: RexxVariable.hpp:104
DirectoryClass.hpp
RexxCompoundTail
Definition: RexxCompoundTail.hpp:52
RexxVariableDictionary::getVariableRetriever
static RexxVariableBase * getVariableRetriever(RexxString *variable)
Definition: RexxVariableDictionary.cpp:587
MAX_SYMBOL_LENGTH
const int MAX_SYMBOL_LENGTH
Definition: RexxCore.h:74
RexxVariableDictionary::newInstance
static RexxVariableDictionary * newInstance(size_t)
Definition: RexxVariableDictionary.cpp:507
RexxVariableDictionary::setNextDictionary
void setNextDictionary(RexxVariableDictionary *next)
Definition: RexxVariableDictionary.cpp:429
RexxString::upper
RexxString * upper()
Definition: StringClass.cpp:1442
RexxStemVariable
Definition: ExpressionStem.hpp:49
RexxVariableDictionary::buildCompoundVariable
static RexxObject * buildCompoundVariable(RexxString *variable_name, bool direct)
Definition: RexxVariableDictionary.cpp:740
RexxVariableDictionary.hpp
RexxVariable::getVariableValue
RexxObject * getVariableValue()
Definition: RexxVariable.hpp:72
RexxList::addLast
void addLast(RexxObject *value)
Definition: ListClass.cpp:454
RexxVariableDictionary::add
void add(RexxVariable *, RexxString *)
Definition: RexxVariableDictionary.cpp:222
RexxStem::evaluateCompoundVariableValue
RexxObject * evaluateCompoundVariableValue(RexxActivation *context, RexxString *stemVariableName, RexxCompoundTail *resolved_tail)
Definition: StemClass.cpp:678
SourceFile.hpp
RexxObject
Definition: ObjectClass.hpp:311
RexxHashTable::first
HashLink first()
Definition: RexxHashTable.cpp:1561
RexxVariable::drop
void drop()
Definition: RexxVariable.cpp:113
RexxVariableDictionary::contents
RexxHashTable * contents
Definition: RexxVariableDictionary.hpp:142
RexxString
Definition: StringClass.hpp:119
RexxVariable
Definition: RexxVariable.hpp:49
ExpressionDotVariable.hpp