home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / src / runtime / data.r < prev    next >
Text File  |  2002-01-18  |  10KB  |  413 lines

  1. /*
  2.  * data.r -- Various interpreter data tables.
  3.  */
  4.  
  5. #if !COMPILER
  6.  
  7. struct b_proc Bnoproc;
  8.  
  9. #ifdef EventMon
  10. struct b_iproc mt_llist = {
  11.    6, (sizeof(struct b_proc) - sizeof(struct descrip)), Ollist,
  12.    0, -1,  0, 0, {sizeof( "[...]")-1, "[...]"}};
  13. #endif                    /* EventMon */
  14.  
  15.  
  16. /*
  17.  * External declarations for function blocks.
  18.  */
  19.  
  20. #define FncDef(p,n) extern struct b_proc Cat(B,p);
  21. #define FncDefV(p) extern struct b_proc Cat(B,p);
  22. #passthru #undef exit
  23. #undef exit
  24. #include "../h/fdefs.h"
  25. #undef FncDef
  26. #undef FncDefV
  27.  
  28. #define OpDef(p,n,s,u) extern struct b_proc Cat(B,p);
  29. #include "../h/odefs.h"
  30. #undef OpDef
  31.  
  32. extern struct b_proc Bbscan;
  33. extern struct b_proc Bescan;
  34. extern struct b_proc Bfield;
  35. extern struct b_proc Blimit;
  36. extern struct b_proc Bllist;
  37.  
  38.  
  39.  
  40.  
  41. struct b_proc *opblks[] = {
  42.     NULL,
  43. #define OpDef(p,n,s,u) Cat(&B,p),
  44. #include "../h/odefs.h"
  45. #undef OpDef
  46.    &Bbscan,
  47.    NULL,
  48.    NULL,
  49.    NULL,
  50.    NULL,
  51.    NULL,
  52.    NULL,
  53.    NULL,
  54.    NULL,
  55.    NULL,
  56.    NULL,
  57.    &Bescan,
  58.    NULL,
  59.    &Bfield,
  60.    NULL,
  61.    NULL,
  62.    NULL,
  63.    NULL,
  64.    NULL,
  65.    &Blimit,
  66.    &Bllist,
  67.    NULL,
  68.    NULL,
  69.    NULL
  70.    };
  71.  
  72. /*
  73.  * Array of names and corresponding functions.
  74.  *  Operators are kept in a similar table, op_tbl.
  75.  */
  76.  
  77. struct pstrnm pntab[] = {
  78.  
  79. #define FncDef(p,n) Lit(p), Cat(&B,p),
  80. #define FncDefV(p) Lit(p), Cat(&B,p),
  81. #include "../h/fdefs.h"
  82. #undef FncDef
  83. #undef FncDefV
  84.  
  85.     0,         0
  86.     };
  87.  
  88. int pnsize = (sizeof(pntab) / sizeof(struct pstrnm)) - 1;
  89.  
  90. #endif                    /* COMPILER */
  91.  
  92. /*
  93.  * Structures for built-in values.  Parts of some of these structures are
  94.  *  initialized later. Since some C compilers cannot handle any partial
  95.  *  initializations, all parts are initialized later if any have to be.
  96.  */
  97.  
  98. /*
  99.  * blankcs; a cset consisting solely of ' '.
  100.  */
  101. struct b_cset  blankcs = {
  102.    T_Cset,
  103.    1,
  104.    cset_display(0, 0, 01, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
  105.    };
  106.  
  107. /*
  108.  * lparcs; a cset consisting solely of '('.
  109.  */
  110. struct b_cset  lparcs = {
  111.    T_Cset,
  112.    1,
  113.    cset_display(0, 0, 0400, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
  114.    };
  115.  
  116. /*
  117.  * rparcs; a cset consisting solely of ')'.
  118.  */
  119. struct b_cset  rparcs = {
  120.    T_Cset,
  121.    1,
  122.    cset_display(0, 0, 01000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
  123.    };
  124.  
  125. /*
  126.  * fullcs - all 256 bits on.
  127.  */
  128. struct b_cset  fullcs = {
  129.    T_Cset,
  130.    256,
  131.    cset_display(~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0,
  132.         ~0, ~0, ~0, ~0, ~0, ~0, ~0, ~0)
  133.    };
  134.  
  135. #if !COMPILER
  136.  
  137. /*
  138.  * Built-in csets
  139.  */
  140.  
  141. /*
  142.  * &digits; bits corresponding to 0-9 are on.
  143.  */
  144. struct b_cset  k_digits = {
  145.    T_Cset,
  146.    10,
  147.  
  148.    cset_display(0,  0,    0,  0x3ff, 0,  0, 0,  0,
  149.         0,  0,    0,  0,     0,  0,     0,  0)
  150.    };
  151.  
  152. /*
  153.  * Cset for &lcase; bits corresponding to lowercase letters are on.
  154.  */
  155. struct b_cset  k_lcase = {
  156.    T_Cset,
  157.    26,
  158.  
  159.    cset_display(0,  0,    0,  0,    0,  0,    ~01,  03777,
  160.         0,  0,    0,  0,    0,  0,    0,  0)
  161.    };
  162.  
  163. /*
  164.  * &ucase; bits corresponding to uppercase characters are on.
  165.  */
  166. struct b_cset  k_ucase = {
  167.    T_Cset,
  168.    26,
  169.  
  170.    cset_display(0,  0,    0,  0,    ~01,  03777, 0, 0,
  171.         0,  0,    0,  0,    0,  0,    0,  0)
  172.    };
  173.  
  174. /*
  175.  * &letters; bits corresponding to letters are on.
  176.  */
  177. struct b_cset  k_letters = {
  178.    T_Cset,
  179.    52,
  180.  
  181.    cset_display(0,  0,    0,  0,    ~01,  03777, ~01, 03777,
  182.         0,  0,    0,  0,    0,  0,    0,  0)
  183.    };
  184. #endif                    /* COMPILER */
  185.  
  186. /*
  187.  * Built-in files.
  188.  */
  189.  
  190. #ifndef MultiThread
  191. struct b_file  k_errout = {T_File, NULL, Fs_Write};    /* &errout */
  192. struct b_file  k_input = {T_File, NULL, Fs_Read};    /* &input */
  193. struct b_file  k_output = {T_File, NULL, Fs_Write};    /* &output */
  194. #endif                    /* MultiThread */
  195.  
  196. #ifdef EventMon
  197. /*
  198.  *  Real block needed for event monitoring.
  199.  */
  200. struct b_real realzero = {T_Real, 0.0};
  201. #endif                    /* EventMon */
  202.  
  203. /*
  204.  * Keyword variables.
  205.  */
  206. #ifndef MultiThread
  207. struct descrip kywd_err = {D_Integer};  /* &error */
  208. struct descrip kywd_pos = {D_Integer};    /* &pos */
  209. struct descrip kywd_prog;        /* &progname */
  210. struct descrip k_subject;        /* &subject */
  211. struct descrip kywd_ran = {D_Integer};    /* &random */
  212. struct descrip kywd_trc = {D_Integer};    /* &trace */
  213. struct descrip k_eventcode = {D_Null};    /* &eventcode */
  214. struct descrip k_eventsource = {D_Null};/* &eventsource */
  215. struct descrip k_eventvalue = {D_Null};    /* &eventvalue */
  216.  
  217. #endif                    /* MultiThread */
  218.  
  219. #ifdef FncTrace
  220. struct descrip kywd_ftrc = {D_Integer};    /* &ftrace */
  221. #endif                    /* FncTrace */
  222.  
  223. struct descrip kywd_dmp = {D_Integer};    /* &dump */
  224.  
  225. struct descrip nullptr =
  226.    {F_Ptr | F_Nqual};                    /* descriptor with null block pointer */
  227. struct descrip trashcan;        /* descriptor that is never read */
  228.  
  229. /*
  230.  * Various constant descriptors.
  231.  */
  232.  
  233. struct descrip blank;            /* one-character blank string */
  234. struct descrip emptystr;        /* zero-length empty string */
  235. struct descrip lcase;            /* string of lowercase letters */
  236. struct descrip letr;            /* "r" */
  237. struct descrip nulldesc = {D_Null};    /* null value */
  238. struct descrip onedesc = {D_Integer};    /* integer 1 */
  239. struct descrip ucase;            /* string of uppercase letters */
  240. struct descrip zerodesc = {D_Integer};    /* integer 0 */
  241.  
  242. #ifdef EventMon
  243. /*
  244.  * Descriptors used by event monitoring.
  245.  */
  246. struct descrip csetdesc = {D_Cset};
  247. struct descrip eventdesc;
  248. struct descrip rzerodesc = {D_Real};
  249. #endif                    /* EventMon */
  250.  
  251. /*
  252.  * An array of all characters for use in making one-character strings.
  253.  */
  254.  
  255. unsigned char allchars[256] = {
  256.      0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
  257.     16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  258.     32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
  259.     48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
  260.     64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
  261.     80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
  262.     96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
  263.    112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
  264.    128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
  265.    144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
  266.    160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
  267.    176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
  268.    192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
  269.    208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
  270.    224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
  271.    240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,
  272. };
  273.  
  274. /*
  275.  * Run-time error numbers and text.
  276.  */
  277. struct errtab errtab[] = {
  278.    101, "integer expected or out of range",
  279.    102, "numeric expected",
  280.    103, "string expected",
  281.    104, "cset expected",
  282.    105, "file expected",
  283.    106, "procedure or integer expected",
  284.    107, "record expected",
  285.    108, "list expected",
  286.    109, "string or file expected",
  287.    110, "string or list expected",
  288.    111, "variable expected",
  289.    112, "invalid type to size operation",
  290.    113, "invalid type to random operation",
  291.    114, "invalid type to subscript operation",
  292.    115, "structure expected",
  293.    116, "invalid type to element generator",
  294.    117, "missing main procedure",
  295.    118, "co-expression expected",
  296.    119, "set expected",
  297.    120, "two csets or two sets expected",
  298.    121, "function not supported",
  299.    122, "set or table expected",
  300.    123, "invalid type",
  301.    124, "table expected",
  302.    125, "list, record, or set expected",
  303.    126, "list or record expected",
  304.  
  305. #ifdef Graphics
  306.    140, "window expected",
  307.    141, "program terminated by window manager",
  308.    142, "attempt to read/write on closed window",
  309.    143, "malformed event queue",
  310.    144, "window system error",
  311.    145, "bad window attribute",
  312.    146, "incorrect number of arguments to drawing function",
  313.    147, "window attribute cannot be read or written as requested",
  314. #endif                    /* Graphics */
  315.  
  316. #ifdef MSWindows
  317. #ifdef FAttrib
  318.    160, "bad file attribute",
  319. #endif                    /* FAttrib */
  320. #endif                    /* MSWindows */
  321.  
  322.    201, "division by zero",
  323.    202, "remaindering by zero",
  324.    203, "integer overflow",
  325.    204, "real overflow, underflow, or division by zero",
  326.    205, "invalid value",
  327.    206, "negative first argument to real exponentiation",
  328.    207, "invalid field name",
  329.    208, "second and third arguments to map of unequal length",
  330.    209, "invalid second argument to open",
  331.    210, "non-ascending arguments to detab/entab",
  332.    211, "by value equal to zero",
  333.    212, "attempt to read file not open for reading",
  334.    213, "attempt to write file not open for writing",
  335.    214, "input/output error",
  336.    215, "attempt to refresh &main",
  337.    216, "external function not found",
  338.  
  339.  
  340.    301, "evaluation stack overflow",
  341.    302, "memory violation",
  342.    303, "inadequate space for evaluation stack",
  343.    304, "inadequate space in qualifier list",
  344.    305, "inadequate space for static allocation",
  345.    306, "inadequate space in string region",
  346.    307, "inadequate space in block region",
  347.    308, "system stack overflow in co-expression",
  348.  
  349. #if IntBits == 16
  350.    316, "interpreter stack too large",
  351.    318, "co-expression stack too large",
  352. #endif                    /* IntBits == 16 */
  353.  
  354. #ifndef Coexpr
  355.    401, "co-expressions not implemented",
  356. #endif                    /* Coexpr */
  357.    402, "program not compiled with debugging option",
  358.  
  359.    500, "program malfunction",        /* for use by runerr() */
  360.    600, "vidget usage error",        /* yeah! */
  361.  
  362. /*
  363.  * End of operating-system specific code.
  364.  */
  365.  
  366.    0,    ""
  367.    };
  368.  
  369. #if !COMPILER
  370. #define OpDef(p,n,s,u) int Cat(O,p) (dptr cargp);
  371. #include "../h/odefs.h"
  372. #undef OpDef
  373.  
  374. /*
  375.  * When an opcode n has a subroutine call associated with it, the
  376.  *  nth word here is the routine to call.
  377.  */
  378.  
  379. int (*optab[])() = {
  380.     err,
  381. #define OpDef(p,n,s,u) Cat(O,p),
  382. #include "../h/odefs.h"
  383. #undef OpDef
  384.    Obscan,
  385.    err,
  386.    err,
  387.    err,
  388.    err,
  389.    err,
  390.    Ocreate,
  391.    err,
  392.    err,
  393.    err,
  394.    err,
  395.    Oescan,
  396.    err,
  397.    Ofield
  398.    };
  399.  
  400. /*
  401.  *  Keyword function look-up table.
  402.  */
  403. #define KDef(p,n) int Cat(K,p) (dptr cargp);
  404. #include "../h/kdefs.h"
  405. #undef KDef
  406.  
  407. int (*keytab[])() = {
  408.    err,
  409. #define KDef(p,n) Cat(K,p),
  410. #include "../h/kdefs.h"
  411.    };
  412. #endif                    /* !COMPILER */
  413.