void init_vc( int argc, char *argv[] ) /* The first part of initialisation involves sorting out the arguments, and assigning standard input and standard output files as explained in decode_args and setup_files below. The rest involves setting various system wide variables to sensible values and clearing down the symbol table. Small constants are so common we put them in the symbol table first and record their addresses in a table. We do this for the integers 0 to COUNT_MAX - 1. This will permit us efficient access to them throughout the compiler. We record the entry labels for the library routines. We happen to know from inspection of the library code that the entry point to PRINTN is L2 and to PRINTS is L4. If we rewrite the library then we may have to change these. This is really rather clumsy, and at the very least ought to be put in a single table somewhere. Note that earlier we set the first label to be used to L10, permitting the use of labels up to L9 for library use. */ { int i ; /* General counter */ char *ifile ; /* Input file */ char *ofile ; /* Output file */ /* Decode the arguments, and setup stdin and stdout accordingly */ ofile = decode_args( argc, argv ) ; ifile = argv[1] ; /* Do after decode has checked argument is OK */ setup_files( ifile, ofile ) ; /* Give values to global variables */ symb_list = NULL ; /* Freelists */ enode_list = NULL ; errors_found = FALSE ; /* No errors found yet */ next_tmp = 0 ; /* No temporaries used */ next_label = LAB_MIN ; /* 10 labels reserved */ for( i = 0 ; i < HASHSIZE ; i++ ) /* Clear symbol table */ symbtab[i] = NULL ; for( i = 0 ; i < CONST_MAX ; i++ ) /* Make constants */ { SYMB *c = get_symb() ; /* Node for the constant */ c->type = T_INT ; c->VAL1 = i ; const_tab[i] = c ; } library[LIB_PRINTN] = mktac( TAC_LABEL, mklabel( 2 ), NULL, NULL ) ; library[LIB_PRINTS] = mktac( TAC_LABEL, mklabel( 4 ), NULL, NULL ) ; } /* void init_vc( void ) */
static void drawlabel(Memimage *m, Point p, int n) { char buf[30]; Point w; mklabel(buf, n); w = memsubfontwidth(smallfont, buf); memimagestring(m, Pt(p.x-5-w.x, p.y), memblack, ZP, smallfont, buf); }
void use_label(const char *name, u16 pc) { struct label *l = mklabel(name, 0, 0); if (l->defined) { image[pc] = l->pc; } else { struct fixup *f = malloc(sizeof(*f)); f->next = fixups; f->pc = pc; f->label = l; fixups = f; } }
execlab(ftnint stateno) #endif { register struct Labelblock *lp; if(lp = mklabel(stateno)) { if(lp->labinacc) warn1("illegal branch to inner block, statement label %s", convic(stateno) ); else if(lp->labdefined == NO) lp->blklevel = blklevel; if(lp->labtype == LABFORMAT) err("may not branch to a format"); else lp->labtype = LABEXEC; } else execerr("illegal label %s", convic(stateno)); return(lp); }
void set_label(const char *name, u16 pc) { mklabel(name, pc, 1); }