state.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #ifndef NORCSID
  2. static char rcsid[] = "$Id$";
  3. #endif
  4. #include <stdlib.h>
  5. #include <stdio.h>
  6. #include "assert.h"
  7. #include "param.h"
  8. #include "tables.h"
  9. #include "types.h"
  10. #include <cgg_cg.h>
  11. #include "data.h"
  12. #include "result.h"
  13. #include "state.h"
  14. #include "extern.h"
  15. /*
  16. * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
  17. * See the copyright notice in the ACK home directory, in the file "Copyright".
  18. *
  19. * Author: Hans van Staveren
  20. */
  21. extern int nstab; /* salloc.c */
  22. savestatus(sp) register state_p sp; {
  23. sp->st_sh = stackheight;
  24. bmove((short *)fakestack,(short *)sp->st_fs,stackheight*sizeof(token_t));
  25. sp->st_na = nallreg;
  26. bmove((short *)allreg,(short *)sp->st_ar,nallreg*sizeof(int));
  27. sp->st_ct = curtoken;
  28. bmove((short *)dollar,(short *)sp->st_do,LONGESTPATTERN*sizeof(result_t));
  29. bmove((short *)machregs,(short *)sp->st_mr,NREGS*sizeof(struct reginfo));
  30. sp->st_ne = nemlines;
  31. bmove((short *)emlines,(short *)sp->st_el,nemlines*sizeof(struct emline));
  32. sp->st_em = emp;
  33. sp->st_se = saveemp;
  34. sp->st_tl = tokpatlen;
  35. sp->st_ns = nstab;
  36. }
  37. restorestatus(sp) register state_p sp; {
  38. stackheight = sp->st_sh;
  39. bmove((short *)sp->st_fs,(short *)fakestack,stackheight*sizeof(token_t));
  40. nallreg = sp->st_na;
  41. bmove((short *)sp->st_ar,(short *)allreg,nallreg*sizeof(int));
  42. curtoken = sp->st_ct;
  43. bmove((short *)sp->st_do,(short *)dollar,LONGESTPATTERN*sizeof(result_t));
  44. bmove((short *)sp->st_mr,(short *)machregs,NREGS*sizeof(struct reginfo));
  45. nemlines = sp->st_ne;
  46. bmove((short *)sp->st_el,(short *)emlines,nemlines*sizeof(struct emline));
  47. emp = sp->st_em;
  48. saveemp = sp->st_se;
  49. tokpatlen = sp->st_tl;
  50. popstr(sp->st_ns);
  51. }
  52. bmove(from,to,nbytes) register short *from,*to; register nbytes; {
  53. if (nbytes<=0)
  54. return;
  55. assert(sizeof(short)==2 && (nbytes&1)==0);
  56. nbytes>>=1;
  57. do
  58. *to++ = *from++;
  59. while (--nbytes);
  60. }