Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
1.6 KiB

  1. // Copyright (c) 1993-1999 Microsoft Corporation
  2. #include "y4.h"
  3. void
  4. stin( SSIZE_T i)
  5. {
  6. SSIZE_T *r, *s, n, flag, j, *q1, *q2;
  7. greed[i] = 0;
  8. /* enter state i into the a array */
  9. q2 = mem0+yypact[i+1];
  10. q1 = mem0+yypact[i];
  11. /* find an acceptable place */
  12. for( n= -maxoff; n<ACTSIZE; ++n )
  13. {
  14. flag = 0;
  15. for( r = q1; r < q2; r += 2 )
  16. {
  17. if( (s = *r + n + a ) < a ) goto nextn;
  18. if( *s == 0 ) ++flag;
  19. else if( *s != r[1] ) goto nextn;
  20. }
  21. /* check that the position equals another only if the states are identical */
  22. for( j=0; j<nstate; ++j )
  23. {
  24. if( pa[j] == n )
  25. {
  26. if( flag ) goto nextn; /* we have some disagreement */
  27. if( yypact[j+1] + yypact[i] == yypact[j] + yypact[i+1] )
  28. {
  29. /* states are equal */
  30. pa[i] = n;
  31. if( adb>1 ) fprintf( ftable, "State %d: entry at %d equals state %d\n",
  32. i, n, j );
  33. return;
  34. }
  35. goto nextn; /* we have some disagreement */
  36. }
  37. }
  38. for( r = q1; r < q2; r += 2 )
  39. {
  40. if( (s = *r + n + a ) >= &a[ACTSIZE] ) error( "out of space in optimizer a array" );
  41. if( s > maxa ) maxa = s;
  42. if( *s != 0 && *s != r[1] ) error( "clobber of a array, pos'n %d, by %d", s-a, r[1] );
  43. *s = r[1];
  44. }
  45. pa[i] = n;
  46. if( adb>1 ) fprintf( ftable, "State %d: entry at %d\n", i, pa[i] );
  47. return;
  48. nextn:
  49. ;
  50. }
  51. error( "Error; failure to place state %d\n", i );
  52. }