Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * fhead - beginning of function body
- */
- void fhead(struct id_entry *p) {
- printf("func %s\n", p->i_name);
- unsigned int i;
- for (i = 0; i < formalnum; i++) {
- if (formaltypes[i] == 'f') {
- printf("formal 8\n");
- } else if (formaltypes[i] == 'i') {
- printf("formal 4\n");
- } else {
- yyerror("formal type somehow stored incorrectly");
- }
- }
- for (i = 0; i < localnum; i++) {
- if (localtypes[i] == 'f') {
- printf("localloc %d\n", 8 * localwidths[i]);
- } else if (localtypes[i] == 'i') {
- printf("localloc %d\n", 4 * localwidths[i]);
- } else {
- yyerror("formal type somehow stored incorrectly");
- }
- }
- }
- /*
- * fname - function declaration
- */
- struct id_entry *fname(int t, char *id) {
- struct id_entry *p;
- if ((p = lookup(id, 0)) == NULL) {
- p = install(id, 0);
- } else if (p->i_defined) {
- yyerror("procedure previously declared");
- } else if (p->i_type != t) {
- yyerror("function declaration types do not match");
- }
- p->i_type = t;
- p->i_scope = GLOBAL;
- p->i_defined = 1;
- enterblock();
- formalnum = 0;
- localnum = 0;
- return p;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement