misc.c 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. * See the copyright notice in the ACK home directory, in the file "Copyright".
  4. *
  5. * Author: Ceriel J.H. Jacobs
  6. */
  7. /* M I S C E L L A N E O U S R O U T I N E S */
  8. /* $Id$ */
  9. #include <stdlib.h>
  10. #include <stdio.h>
  11. #include <string.h>
  12. #include "alloc.h"
  13. #include "em_arith.h"
  14. #include "em_label.h"
  15. #include "f_info.h"
  16. #include "misc.h"
  17. #include "LLlex.h"
  18. #include "idf.h"
  19. #include "node.h"
  20. match_id(id1, id2)
  21. register t_idf *id1, *id2;
  22. {
  23. /* Check that identifiers id1 and id2 are equal. If they
  24. are not, check that we did'nt generate them in the
  25. first place, and if not, give an error message
  26. */
  27. if (id1 != id2 && !is_anon_idf(id1) && !is_anon_idf(id2)) {
  28. error("name \"%s\" does not match block name \"%s\"",
  29. id1->id_text,
  30. id2->id_text
  31. );
  32. }
  33. }
  34. t_idf *
  35. gen_anon_idf()
  36. {
  37. /* A new idf is created out of nowhere, to serve as an
  38. anonymous name.
  39. */
  40. static int name_cnt;
  41. char *s = Malloc(strlen(FileName)+50);
  42. char *sprint();
  43. sprint(s, "#%d in %s, line %u",
  44. ++name_cnt, FileName, LineNumber);
  45. s = Realloc(s, strlen(s)+1);
  46. return str2idf(s, 0);
  47. }
  48. not_declared(what, id, where)
  49. char *what, *where;
  50. register t_node *id;
  51. {
  52. /* The identifier "id" is not declared. If it is not generated,
  53. give an error message
  54. */
  55. if (!is_anon_idf(id->nd_IDF)) {
  56. node_error(id,
  57. "%s \"%s\" not declared%s",
  58. what,
  59. id->nd_IDF->id_text,
  60. where);
  61. }
  62. }