* Copyright (c) 1982 Regents of the University of California
static char sccsid
[] = "@(#)asscan1.c 4.6 %G%";
bufstart
->tok_next
= buftail
;
tokbuf
[0].tok_count
= -1;
tokbuf
[1].tok_count
= -1;
emptybuf
= &tokbuf
[bufno
];
emptybuf
->toks
[emptybuf
->tok_count
++] = PARSEEOF
;
* Clean up the buffers that haven't been
if (tokbuf
[bufno
^ 1].tok_count
>= 0){
if (writeTEST((char *)&tokbuf
[bufno
^ 1], sizeof *emptybuf
, 1, tokfile
)){
yyerror("Unexpected end of file writing the interpass tmp file");
* Ensure that we will read an End of file,
* if there are more than one file names
tokbuf
[bufno
].toks
[tokbuf
[bufno
].tok_count
++] = PARSEEOF
;
if (writeTEST((char *)&tokbuf
[bufno
], sizeof *emptybuf
, 1, tokfile
))
} /*end of being pass 1*/
register struct exp
*locxp
;
* No local variables to be allocated; this saves
* one piddling instruction..
bufptr
= tokptr
; /*copy in the global value*/
if (xp
>= &explist
[NEXP
])
yyerror("Too many expressions; try simplyfing");
locxp
->e_number
= Znumber
;
locxp
->e_number
.num_tag
= TYPL
;
glong(locxp
->e_xvalue
, bufptr
);
if (xp
>= &explist
[NEXP
])
yyerror("Too many expressions; try simplyfing");
gnumber(locxp
->e_number
, bufptr
);
lastnam
= (struct symtab
*)yylval
;
gopcode(yyopcode
, bufptr
);
gopcode(yyopcode
, bufptr
);
/* We can't cast Lastjxxx into (int *) here.. */
lastjxxx
= (struct symtab
*)Lastjxxx
;
printf("P: %d T#: %4d, %s ",
passno
, bufptr
- firsttoken
, tok_to_name(val
));
case INT
: printf("val %d",
((struct exp
*)yylval
)->e_xvalue
);
case BFINT
: printf("val %d",
((struct exp
*)yylval
)->e_xvalue
);
case BIGNUM
: bignumprint(((struct exp
*)yylval
)->e_number
);
case NAME
: printf("\"%.8s\"",
FETCHNAME((struct symtab
*)yylval
));
case INSTn
: if (ITABCHECK(yyopcode
))
FETCHNAME(ITABFETCH(yyopcode
)));
printf("IJXXX or INST0 or INSTn can't get into the itab\n");
printf("length %d, seekoffset %d, place 0%o ",
((struct strdesc
*)yylval
)->sd_strlen
,
((struct strdesc
*)yylval
)->sd_stroff
,
((struct strdesc
*)yylval
)->sd_place
if (((struct strdesc
*)yylval
)->sd_place
& STR_CORE
)
((struct strdesc
*)yylval
)->sd_strlen
,
((struct strdesc
*)yylval
)->sd_string
);
} /*end of the debug switch*/
} else { /* start a new buffer */
tok_temp
= emptybuf
->tok_next
;
emptybuf
->tok_next
= tok_free
;
emptybuf
= emptybuf
->tok_next
;
struct tokbufdesc
*newdallop
;
emptybuf
= newdallop
= (struct tokbufdesc
*)
Calloc(TOKDALLOP
, sizeof (struct tokbufdesc
));
for (i
=0; i
< TOKDALLOP
; i
++){
buftail
->tok_next
= newdallop
;
} /*end of need to get more buffers*/
(bytetoktype
*)bufptr
= &(emptybuf
->toks
[0]);
} else { /*don't use VM*/
emptybuf
= &tokbuf
[bufno
];
((bytetoktype
*)bufptr
) = &(emptybuf
->toks
[0]);
* First check if there are things to write
if (emptybuf
->tok_count
>= 0){
if (writeTEST((char *)emptybuf
, sizeof *emptybuf
, 1, tokfile
)){
yyerror("Unexpected end of file writing the interpass tmp file");
if (readTEST((char *)emptybuf
, sizeof *emptybuf
, 1, tokfile
)){
yyerror("Unexpected end of file while reading the interpass tmp file");
} /*end of using a real live file*/
(char *)tokub
= (char *)bufptr
+ emptybuf
->tok_count
;
printf("created buffernumber %d with %d tokens\n",
bufno
, emptybuf
->tok_count
);
} /*end of reading/creating a new buffer*/
tokptr
= bufptr
; /*copy back the global value*/
register ptrall from
, to
;
register struct tokbufdesc
*middlebuf
;
* check if from and to are in the same buffer
* from and to DIFFER BY AT MOST 1 buffer and to is
* always ahead of from, with to being in the buffer emptybuf
* The hard part here is accounting for the case where the
* skip is to cross a buffer boundary; we must construct
* Figure out where the buffer boundary between from and to is
* It's easy in VM, as buffers increase to high memory, but
* w/o VM, we alternate between two buffers, and want
* to look at the exact middle of the contiguous buffer region.
middlebuf
= useVM
? emptybuf
: &tokbuf
[1];
if ( ( (bytetoktype
*)from
> (bytetoktype
*)middlebuf
)
^ ( (bytetoktype
*)to
> (bytetoktype
*)middlebuf
)
){ /*split across a buffer boundary*/
* Set the skip so it lands someplace beyond
* the end of this buffer.
* When we pull this skip out in the second pass,
* we will temporarily move the current pointer
* out beyond the end of the buffer, but immediately
* do a compare and fail the compare, and then reset
* all the pointers correctly to point into the next buffer.
bskiplg(from
, TOKBUFLG
+ 1);
* Now, force from to be in the same buffer as to
(bytetoktype
*)from
= (bytetoktype
*)&(emptybuf
->toks
[0]);
* Now, to and from are in the same buffer
yyerror("Internal error: bad skip construction");
if ( (diff
= (bytetoktype
*)to
- (bytetoktype
*)from
) >=
(sizeof(bytetoktype
) + sizeof(lgtype
) + 1)) {
for ( ; diff
> 0; --diff
)
asm("movc3 12(ap),*8(ap),*4(ap)");