progs.c 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. #include "debug.h"
  2. #include <em.h>
  3. #include <assert.h>
  4. #include "LLlex.h"
  5. #include "def.h"
  6. #include "main.h"
  7. #include "scope.h"
  8. #include "type.h"
  9. static int extflc; /* number of external files */
  10. static int inpflag = 0; /* input mentioned in heading ? */
  11. static int outpflag = 0; /* output mentioned in heading ? */
  12. static label extfl_label; /* label of array of file pointers */
  13. set_inp()
  14. {
  15. inpflag = 1;
  16. }
  17. set_outp()
  18. {
  19. outpflag = 1;
  20. }
  21. make_extfl()
  22. {
  23. if( err_occurred ) return;
  24. extfl_label = ++data_label;
  25. C_df_dlb(extfl_label);
  26. if( inpflag ) {
  27. C_ina_dnam(input);
  28. C_con_dnam(input, (arith) 0);
  29. }
  30. else
  31. C_con_ucon("0", pointer_size);
  32. if( outpflag ) {
  33. C_ina_dnam(output);
  34. C_con_dnam(output, (arith) 0);
  35. }
  36. else
  37. C_con_ucon("0", pointer_size);
  38. extflc = 2;
  39. /* Process the identifiers in the global scope (at this point only
  40. * the program parameters) in order of specification.
  41. */
  42. make_extfl_args( GlobalScope->sc_def );
  43. }
  44. make_extfl_args(df)
  45. register struct def *df;
  46. {
  47. if( !df ) return;
  48. make_extfl_args(df->df_nextinscope);
  49. assert(df->df_flags & D_PROGPAR);
  50. if( df->var_name != input && df->var_name != output ) {
  51. C_ina_dnam(df->var_name);
  52. C_con_dnam(df->var_name, (arith) 0);
  53. extflc++;
  54. }
  55. }
  56. call_ini()
  57. {
  58. C_lxl((arith) 0);
  59. if( extflc )
  60. C_lae_dlb(extfl_label, (arith) 0);
  61. else
  62. C_zer(pointer_size);
  63. C_loc((arith) extflc);
  64. C_lxa((arith) 0);
  65. C_cal("_ini");
  66. C_asp(3 * pointer_size + word_size);
  67. }