Doxygen Source Code Documentation
p1output.c File Reference
#include "defs.h"#include "p1defs.h"#include "output.h"#include "names.h"Go to the source code of this file.
| Data Structures | |
| union | dL | 
| Functions | |
| void p1_addr | Argdcl ((Addrp)) | 
| void p1_binary | Argdcl ((Exprp)) | 
| void p1_const | Argdcl ((Constp)) | 
| void p1_list | Argdcl ((struct Listblock *)) | 
| void p1_literal | Argdcl ((long int)) | 
| void p1_name | Argdcl ((Namep)) | 
| void p1putd | Argdcl ((int, long int)) | 
| void p1putdd | Argdcl ((int, int, int)) | 
| void p1putddd | Argdcl ((int, int, int, int)) | 
| void p1putdds | Argdcl ((int, int, int, char *)) | 
| void p1putds | Argdcl ((int, int, char *)) | 
| void | p1_comment (char *str) | 
| void | p1_name (Namep namep) | 
| void | p1_expr (expptr expr) | 
| void | p1_const (register Constp cp) | 
| void | p1_asgoto (Addrp addrp) | 
| void | p1_goto (ftnint stateno) | 
| void | p1_addr (register struct Addrblock *addrp) | 
| void | p1_list (struct Listblock *listp) | 
| void | p1_label (long lab) | 
| void | p1_literal (long memno) | 
| void | p1_if (expptr expr) | 
| void | p1_elif (expptr expr) | 
| void | p1_else (Void) | 
| void | p1_endif (Void) | 
| void | p1else_end (Void) | 
| void | p1_big_addr (Addrp addrp) | 
| void | p1_unary (struct Exprblock *e) | 
| void | p1_binary (struct Exprblock *e) | 
| void | p1_head (int classKRH, char *name) | 
| void | p1_subr_ret (expptr retexp) | 
| void | p1comp_goto (expptr index, int count, struct Labelblock **labels) | 
| void | p1_for (expptr init, expptr test, expptr inc) | 
| void | p1for_end (Void) | 
| void | p1puts (int type, char *str) | 
| void | p1putd (int type, long value) | 
| void | p1putdd (int type, int v1, int v2) | 
| void | p1putddd (int type, int v1, int v2, int v3) | 
| void | p1putn (int type, int count, char *str) | 
| void | p1put (int type) | 
| void | p1putds (int type, int i, char *str) | 
| void | p1putdds (int token, int type, int stg, char *str) | 
Function Documentation
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 | 
| 
 Definition at line 244 of file p1output.c. References BAD_MEMNO, Constant::ci, CLPROC, Constblock::Const, Expression::constblock, ENULL, erri(), Addrblock::Field, Addrblock::isarray, ISICON, M, Addrblock::memno, Addrblock::memoffset, Addrblock::name, ONEOF, oneof_stg(), OPWHATSIN, p1_big_addr(), P1_CHARP, p1_const(), p1_expr(), P1_EXPR, P1_EXTERN, P1_IDENT, p1_literal(), p1_name(), p1putd(), p1putdd(), p1putdds(), STGARG, STGAUTO, STGBSS, STGCOMMON, STGEQUIV, STGINIT, STGLENG, STGREG, UNAM_CHARP, UNAM_CONST, UNAM_EXTERN, UNAM_IDENT, UNAM_NAME, UNAM_UNKNOWN, Addrblock::uname_tag, Addrblock::user, Addrblock::vclass, Addrblock::vstg, and Addrblock::vtype. Referenced by p1_asgoto(), and p1_expr(). 
 00246 {
00247     int stg;
00248 
00249     if (addrp == (struct Addrblock *) NULL)
00250         return;
00251 
00252     stg = addrp -> vstg;
00253 
00254     if (ONEOF(stg, M(STGINIT)|M(STGREG))
00255         || ONEOF(stg, M(STGCOMMON)|M(STGEQUIV)) &&
00256                 (!ISICON(addrp->memoffset)
00257                 || (addrp->uname_tag == UNAM_NAME
00258                         ? addrp->memoffset->constblock.Const.ci
00259                                 != addrp->user.name->voffset
00260                         : addrp->memoffset->constblock.Const.ci))
00261         || ONEOF(stg, M(STGBSS)|M(STGINIT)|M(STGAUTO)|M(STGARG)) &&
00262                 (!ISICON(addrp->memoffset)
00263                         || addrp->memoffset->constblock.Const.ci)
00264         || addrp->Field || addrp->isarray || addrp->vstg == STGLENG)
00265         {
00266                 p1_big_addr (addrp);
00267                 return;
00268         }
00269 
00270 /* Write out a level of indirection for non-array arguments, which have
00271    addrp -> memoffset   set and are handled by   p1_big_addr().
00272    Lengths are passed by value, so don't check STGLENG
00273    28-Jun-89 (dmg)  Added the check for != TYCHAR
00274  */
00275 
00276     if (oneof_stg ( addrp -> uname_tag == UNAM_NAME ? addrp -> user.name : NULL,
00277             stg, M(STGARG)|M(STGEQUIV)) && addrp->vtype != TYCHAR) {
00278         p1putdd (P1_EXPR, OPWHATSIN, addrp -> vtype);
00279         p1_expr (ENULL);        /* Put dummy   vleng   */
00280     } /* if stg == STGARG */
00281 
00282     switch (addrp -> uname_tag) {
00283         case UNAM_NAME:
00284             p1_name (addrp -> user.name);
00285             break;
00286         case UNAM_IDENT:
00287             p1putdds(P1_IDENT, addrp->vtype, addrp->vstg,
00288                                 addrp->user.ident);
00289             break;
00290         case UNAM_CHARP:
00291                 p1putdds(P1_CHARP, addrp->vtype, addrp->vstg,
00292                                 addrp->user.Charp);
00293                 break;
00294         case UNAM_EXTERN:
00295             p1putd (P1_EXTERN, (long) addrp -> memno);
00296             if (addrp->vclass == CLPROC)
00297                 extsymtab[addrp->memno].extype = addrp->vtype;
00298             break;
00299         case UNAM_CONST:
00300             if (addrp -> memno != BAD_MEMNO)
00301                 p1_literal (addrp -> memno);
00302             else
00303                 p1_const((struct Constblock *)addrp);
00304             break;
00305         case UNAM_UNKNOWN:
00306         default:
00307             erri ("p1_addr:  unknown uname_tag '%d'", addrp -> uname_tag);
00308             break;
00309     } /* switch */
00310 } /* p1_addr */
 | 
| 
 | 
| 
 Definition at line 219 of file p1output.c. References p1_addr(), P1_ASGOTO, and p1put(). Referenced by exasgoto(). 
 | 
| 
 | 
| 
 Definition at line 428 of file p1output.c. References P1_ADDR, p1_expr(), p1putn(), UNAM_NAME, Addrblock::uname_tag, and Addrblock::user. Referenced by p1_addr(). 
 00430 {
00431     if (addrp == (Addrp) NULL)
00432         return;
00433 
00434     p1putn (P1_ADDR, (int)sizeof(struct Addrblock), (char *) addrp);
00435     p1_expr (addrp -> vleng);
00436     p1_expr (addrp -> memoffset);
00437     if (addrp->uname_tag == UNAM_NAME)
00438         addrp->user.name->visused = 1;
00439 } /* p1_big_addr */
 | 
| 
 | 
| 
 Definition at line 484 of file p1output.c. References p1_expr(), P1_EXPR, and p1putdd(). Referenced by p1_expr(). 
 | 
| 
 | 
| 
 Definition at line 56 of file p1output.c. References P1_COMMENT, and p1puts(). Referenced by flush_comments(), putcat(), putmnmx(), putpower(), and store_comment(). 
 00058 {
00059     register unsigned char *pointer, *ustr;
00060 
00061     if (!str)
00062         return;
00063 
00064 /* Get rid of any open or close comment combinations that may be in the
00065    Fortran input */
00066 
00067         ustr = (unsigned char *)str;
00068         for(pointer = ustr; *pointer; pointer++)
00069                 if (*pointer == '*' && (pointer[1] == '/'
00070                                         || pointer > ustr && pointer[-1] == '/'))
00071                         *pointer = '+';
00072         /* trim trailing white space */
00073 #ifdef isascii
00074         while(--pointer >= ustr && (!isascii(*pointer) || isspace(*pointer)));
00075 #else
00076         while(--pointer >= ustr && isspace(*pointer));
00077 #endif
00078         pointer[1] = 0;
00079         p1puts (P1_COMMENT, str);
00080 } /* p1_comment */
 | 
| 
 | 
| 
 Definition at line 161 of file p1output.c. References Constant::cd, cds(), Constant::cds, Constant::ci, cpexpr(), dtos(), erri(), ISICON, P1_CONST, and TYQUAD. Referenced by p1_addr(), p1_expr(), and p1comp_goto(). 
 00163 {
00164         int type = cp->vtype;
00165         expptr vleng = cp->vleng;
00166         union Constant *c = &cp->Const;
00167         char cdsbuf0[64], cdsbuf1[64];
00168         char *cds0, *cds1;
00169 
00170     switch (type) {
00171         case TYINT1:
00172         case TYSHORT:
00173         case TYLONG:
00174 #ifdef TYQUAD
00175         case TYQUAD:
00176 #endif
00177         case TYLOGICAL:
00178         case TYLOGICAL1:
00179         case TYLOGICAL2:
00180             fprintf(pass1_file, "%d: %d %ld\n", P1_CONST, type, c->ci);
00181             break;
00182         case TYREAL:
00183         case TYDREAL:
00184                 fprintf(pass1_file, "%d: %d %s\n", P1_CONST, type,
00185                         cp->vstg ? c->cds[0] : cds(dtos(c->cd[0]), cdsbuf0));
00186             break;
00187         case TYCOMPLEX:
00188         case TYDCOMPLEX:
00189                 if (cp->vstg) {
00190                         cds0 = c->cds[0];
00191                         cds1 = c->cds[1];
00192                         }
00193                 else {
00194                         cds0 = cds(dtos(c->cd[0]), cdsbuf0);
00195                         cds1 = cds(dtos(c->cd[1]), cdsbuf1);
00196                         }
00197                 fprintf(pass1_file, "%d: %d %s %s\n", P1_CONST, type,
00198                         cds0, cds1);
00199             break;
00200         case TYCHAR:
00201             if (vleng && !ISICON (vleng))
00202                 erri("p1_const:  bad vleng '%d'\n", (int) vleng);
00203             else
00204                 fprintf(pass1_file, "%d: %d %lx\n", P1_CONST, type,
00205                         cpexpr((expptr)cp));
00206             break;
00207         default:
00208             erri ("p1_const:  bad constant type '%d'", type);
00209             break;
00210     } /* switch */
00211 } /* p1_const */
 | 
| 
 | 
| 
 Definition at line 388 of file p1output.c. References P1_ELIF, p1_expr(), and p1put(). Referenced by exarif(), and putif(). 
 | 
| 
 | 
| 
 Definition at line 399 of file p1output.c. References P1_ELSE, and p1put(). Referenced by exar2(), exarif(), and exelse(). 
 | 
| 
 | 
| 
 Definition at line 408 of file p1output.c. References P1_ENDIF, and p1put(). Referenced by exendif(). 
 | 
| 
 | 
| 
 Definition at line 104 of file p1output.c. References ENULL, erri(), frchain(), free, is_binary_op, is_unary_op, p1_addr(), p1_binary(), p1_const(), P1_EXPR, p1_list(), p1_name(), p1_unary(), p1putdd(), TADDR, TCONST, TERROR, TEXPR, TLIST, TNAME, TPRIM, and warn(). Referenced by p1_addr(), p1_big_addr(), p1_binary(), p1_elif(), p1_for(), p1_if(), p1_list(), p1_subr_ret(), p1_unary(), p1comp_goto(), putexpr(), putout(), and putwhile(). 
 00106 {
00107 /* An opcode of 0 means a null entry */
00108 
00109     if (expr == ENULL) {
00110         p1putdd (P1_EXPR, 0, TYUNKNOWN);        /* Should this be TYERROR? */
00111         return;
00112     } /* if (expr == ENULL) */
00113 
00114     switch (expr -> tag) {
00115         case TNAME:
00116                 p1_name ((Namep) expr);
00117                 return;
00118         case TCONST:
00119                 p1_const(&expr->constblock);
00120                 return;
00121         case TEXPR:
00122                 /* Fall through the switch */
00123                 break;
00124         case TADDR:
00125                 p1_addr (&(expr -> addrblock));
00126                 goto freeup;
00127         case TPRIM:
00128                 warn ("p1_expr:  got TPRIM");
00129                 return;
00130         case TLIST:
00131                 p1_list (&(expr->listblock));
00132                 frchain( &(expr->listblock.listp) );
00133                 return;
00134         case TERROR:
00135                 return;
00136         default:
00137                 erri ("p1_expr: bad tag '%d'", (int) (expr -> tag));
00138                 return;
00139         }
00140 
00141 /* Now we know that the tag is TEXPR */
00142 
00143     if (is_unary_op (expr -> exprblock.opcode))
00144         p1_unary (&(expr -> exprblock));
00145     else if (is_binary_op (expr -> exprblock.opcode))
00146         p1_binary (&(expr -> exprblock));
00147     else
00148         erri ("p1_expr:  bad opcode '%d'", (int) expr -> exprblock.opcode);
00149  freeup:
00150     free((char *)expr);
00151 
00152 } /* p1_expr */
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 566 of file p1output.c. References p1_expr(), P1_FOR, and p1put(). Referenced by exdo(). 
 | 
| 
 | 
| 
 Definition at line 232 of file p1output.c. References P1_GOTO, and p1putd(). Referenced by exgoto(). 
 | 
| 
 | ||||||||||||
| 
 Definition at line 503 of file p1output.c. References name, P1_HEAD, and p1putds(). Referenced by puthead(). 
 | 
| 
 | 
| 
 Definition at line 373 of file p1output.c. References p1_expr(), P1_IF, and p1put(). Referenced by exar2(), exarif(), and putif(). 
 | 
| 
 | 
| 
 Definition at line 345 of file p1output.c. References INDATA, mkchain(), P1_LABEL, and p1putd(). Referenced by doentry(), enddcl(), endio(), and yyparse(). 
 | 
| 
 | 
| 
 Definition at line 318 of file p1output.c. References p1_expr(), P1_LIST, and p1putddd(). Referenced by p1_expr(). 
 00320 {
00321     chainp lis;
00322     int count = 0;
00323 
00324     if (listp == (struct Listblock *) NULL)
00325         return;
00326 
00327 /* Count the number of parameters in the list */
00328 
00329     for (lis = listp -> listp; lis; lis = lis -> nextp)
00330         count++;
00331 
00332     p1putddd (P1_LIST, listp -> tag, listp -> vtype, count);
00333 
00334     for (lis = listp -> listp; lis; lis = lis -> nextp)
00335         p1_expr ((expptr) lis -> datap);
00336 
00337 } /* p1_list */
 | 
| 
 | 
| 
 Definition at line 361 of file p1output.c. References P1_LITERAL, and p1putd(). Referenced by p1_addr(). 
 00363 {
00364     p1putd (P1_LITERAL, memno);
00365 } /* p1_literal */
 | 
| 
 | 
| 
 Definition at line 90 of file p1output.c. References P1_NAME_POINTER, and p1putd(). Referenced by p1_addr(), and p1_expr(). 
 00092 {
00093         p1putd (P1_NAME_POINTER, (long) namep);
00094         namep->visused = 1;
00095 } /* p1_name */
 | 
| 
 | 
| 
 Definition at line 515 of file p1output.c. References cpexpr(), p1_expr(), P1_SUBR_RET, and p1put(). Referenced by epicode(), exreturn(), and retval(). 
 00517 {
00518 
00519     p1put (P1_SUBR_RET);
00520     p1_expr (cpexpr(retexp));
00521 } /* p1_subr_ret */
 | 
| 
 | 
| 
 Definition at line 448 of file p1output.c. References erri(), OPABS, OPADDR, OPBITNOT, OPCHARCAST, OPDABS, OPIDENTITY, OPNEG, OPNEG1, OPNOT, OPPREDEC, OPPREINC, p1_expr(), P1_EXPR, and p1putdd(). Referenced by p1_expr(). 
 00450 {
00451     if (e == (struct Exprblock *) NULL)
00452         return;
00453 
00454     p1putdd (P1_EXPR, (int) e -> opcode, e -> vtype);
00455     p1_expr (e -> vleng);
00456 
00457     switch (e -> opcode) {
00458         case OPNEG:
00459         case OPNEG1:
00460         case OPNOT:
00461         case OPABS:
00462         case OPBITNOT:
00463         case OPPREINC:
00464         case OPPREDEC:
00465         case OPADDR:
00466         case OPIDENTITY:
00467         case OPCHARCAST:
00468         case OPDABS:
00469             p1_expr(e -> leftp);
00470             break;
00471         default:
00472             erri ("p1_unary: bad opcode '%d'", (int) e -> opcode);
00473             break;
00474     } /* switch */
00475 
00476 } /* p1_unary */
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 532 of file p1output.c. References Constant::ci, Constblock::Const, i, Labelblock::labused, P1_COMP_GOTO, p1_const(), p1_expr(), P1_LIST, p1put(), p1putddd(), Labelblock::stateno, TLIST, Constblock::vleng, and Constblock::vtype. Referenced by putcmgo(). 
 00534 {
00535     struct Constblock c;
00536     int i;
00537     register struct Labelblock *L;
00538 
00539     p1put (P1_COMP_GOTO);
00540     p1_expr (index);
00541 
00542 /* Write out a P1_LIST directly, to avoid the overhead of allocating a
00543    list before it's needed HACK HACK HACK */
00544 
00545     p1putddd (P1_LIST, TLIST, TYUNKNOWN, count);
00546     c.vtype = TYLONG;
00547     c.vleng = 0;
00548 
00549     for (i = 0; i < count; i++) {
00550         L = labels[i];
00551         L->labused = 1;
00552         c.Const.ci = L->stateno;
00553         p1_const(&c);
00554     } /* for i = 0 */
00555 } /* p1comp_goto */
 | 
| 
 | 
| 
 Definition at line 417 of file p1output.c. References P1_ENDELSE, and p1put(). Referenced by exar2(), exarif(), and exendif(). 
 00418 {
00419     p1put (P1_ENDELSE);
00420 } /* p1else_end */
 | 
| 
 | 
| 
 Definition at line 577 of file p1output.c. References P1_ENDFOR, and p1put(). Referenced by enddo(). 
 | 
| 
 | 
| 
 Definition at line 689 of file p1output.c. Referenced by enddcl(), p1_asgoto(), p1_elif(), p1_else(), p1_endif(), p1_for(), p1_if(), p1_subr_ret(), p1comp_goto(), p1else_end(), p1for_end(), putif(), and putwhile(). 
 00691 {
00692     fprintf (pass1_file, "%d:\n", type);
00693 } /* p1put */
 | 
| 
 | ||||||||||||
| 
 Definition at line 616 of file p1output.c. Referenced by p1_addr(), p1_goto(), p1_label(), p1_literal(), and p1_name(). 
 00618 {
00619     fprintf (pass1_file, "%d: %ld\n", type, value);
00620 } /* p1_putd */
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 632 of file p1output.c. References v1. Referenced by p1_addr(), p1_binary(), p1_expr(), and p1_unary(). 
 00634 {
00635     fprintf (pass1_file, "%d: %d %d\n", type, v1, v2);
00636 } /* p1putdd */
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 649 of file p1output.c. References v1. Referenced by p1_list(), and p1comp_goto(). 
 00651 {
00652     fprintf (pass1_file, "%d: %d %d %d\n", type, v1, v2, v3);
00653 } /* p1putddd */
 | 
| 
 | ||||||||||||||||||||
| 
 Definition at line 719 of file p1output.c. Referenced by p1_addr(). 
 00721 {
00722     fprintf (pass1_file, "%d: %d %d %s\n", token, type, stg, str);
00723 } /* p1putdds */
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 704 of file p1output.c. References i. Referenced by p1_head(). 
 00706 {
00707     fprintf (pass1_file, "%d: %d %s\n", type, i, str);
00708 } /* p1putds */
 | 
| 
 | ||||||||||||||||
| 
 Definition at line 667 of file p1output.c. References i. Referenced by p1_big_addr(). 
 | 
| 
 | ||||||||||||
| 
 Definition at line 601 of file p1output.c. Referenced by p1_comment(), p1_line_number(), and putlineno(). 
 00603 {
00604     fprintf (pass1_file, "%d: %s\n", type, str);
00605 } /* p1puts */
 | 
 
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
                             
 
 
 
 
       
	   
	   
	   
	  