home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / sa104os2.zip / SATHR104.ZIP / SATHER / SYSTEM / ITERS < prev    next >
Text File  |  1994-10-25  |  2KB  |  54 lines

  1. -- Copyright (C) International Computer Science Institute, 1994.  COPYRIGHT  --
  2. -- NOTICE: This code is provided "AS IS" WITHOUT ANY WARRANTY and is subject --
  3. -- to the terms of the SATHER LIBRARY GENERAL PUBLIC LICENSE contained in    --
  4. -- the file "Doc/License" of the Sather distribution.  The license is also   --
  5. -- available from ICSI, 1947 Center St., Suite 600, Berkeley CA 94704, USA.  --
  6. --------> Please email comments to "sather-bugs@icsi.berkeley.edu". <----------
  7.  
  8. -- Macros for inlining iters. ## is a per iter unique string, and
  9. -- @ indicates to exit the current loop.  # followed by a number
  10. -- indicates the corresponding arg as in the MACROS file.
  11.  
  12. -- The strings correspond to the following:
  13.  
  14. -- A string placed at the routine head to declare variables
  15. -- A string placed before entry to the loop.
  16. -- A string just before the use of the expression for the iter.
  17. -- Whatever value ## has is the return value and used at the iter expression.
  18. -- A string that occurs just after. 
  19.  
  20. "INT::times!"            "INT ##;"
  21.                 "## = #1;"
  22.                 "if (##<=0) @;"
  23.                 "##--;"
  24.  
  25. "INT::times!:INT"        ""
  26.                 "## = 0;"
  27.                 "if (##>=#1) @;"
  28.                 "##++;"
  29.  
  30. "INT::for!(INT):INT"        "INT ##e;"
  31.                 "## = #1; ##e = #1+#2;"
  32.                 "if (##>=##e) @;"
  33.                 "##++;"
  34.  
  35. "INT::upto!(INT):INT"        ""
  36.                 "## = #1;"
  37.                 "if (##>#2) @;"
  38.                 "##++;"
  39.  
  40. "STR::aelt!:CHAR"        "CHAR *##p; INT ##n;"
  41.                 "##p = #1->arr_part; ##n = #1->asize;"
  42.                 "if (##n<=0) @; ## = *##p;"
  43.                 "##p++; ##n--;"
  44.  
  45. "STR::elt!:CHAR"        "CHAR *##p; INT ##n;"
  46.                 "##p = #1->arr_part; ##n = #1->asize;"
  47.                 "if (##n<=0) @; ## = *##p;"
  48.                 "##p++; ##n--;"
  49.  
  50. "STR::aset!(CHAR!)"        "CHAR *##p; INT ##n;"
  51.                 "##p = #1->arr_part; ##n = #1->asize;"
  52.                 "if (##n<=0) @; *##p = #2;"
  53.                 "##p++; ##n--;"
  54.