expr.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* $Header$ */
  2. /*
  3. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  4. * See the copyright notice in the ACK home directory, in the file "Copyright".
  5. */
  6. #define E_NODE 0
  7. #define E_VAR 1 /* Variable *or* channel */
  8. #define E_CONST 2
  9. #define E_TABLE 3
  10. #define E_BTAB 4
  11. #define E_NOW 5
  12. #define E_IO 6
  13. #define E_CALL 7
  14. struct table {
  15. long val;
  16. struct table *next;
  17. };
  18. struct expr;
  19. struct expr_list {
  20. struct expr *arg;
  21. struct expr_list *next;
  22. };
  23. struct expr {
  24. short kind;
  25. short type;
  26. int arr_siz;
  27. union {
  28. struct {
  29. int op;
  30. struct expr *left, *right;
  31. } node;
  32. struct symbol *var;
  33. long const;
  34. int tab;
  35. struct {
  36. int out;
  37. struct expr *chan;
  38. struct expr_list *args;
  39. } io;
  40. struct {
  41. struct expr *proc;
  42. struct expr_list *args;
  43. } call;
  44. } u;
  45. };
  46. struct expr *new_node(), *new_var(), *new_const(), *new_table(), *new_now();
  47. struct expr *new_io(), *new_call(), *copy_const();
  48. void table_add(), expr_list_add();
  49. void check_param(), check_io(), check_wait();
  50. void destroy(), used();
  51. #define valueless(e) (((e)->type&T_TYPE)==T_VOID)
  52. #define valued(e) (((e)->type&T_TYPE)==T_VALUE)
  53. #define input_process(e) ((e)->kind==E_IO && !(e)->u.io.out)
  54. #define constant(e) ((e)->kind==E_CONST)
  55. #define arr_constant(e) ((e)->kind==E_TABLE || (e)->kind==E_BTAB)