home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Tools / Languages / Harvest C 1.3 / Source Code / genbld.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-15  |  3.0 KB  |  124 lines  |  [TEXT/ALFA]

  1. /*
  2.     Harvest C
  3.     Copyright 1992 Eric W. Sink.  All rights reserved.
  4.     
  5.     This file is part of Harvest C.
  6.     
  7.     Harvest C is free software; you can redistribute it and/or modify
  8.     it under the terms of the GNU Generic Public License as published by
  9.     the Free Software Foundation; either version 2, or (at your option)
  10.     any later version.
  11.     
  12.     Harvest C is distributed in the hope that it will be useful,
  13.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.     GNU General Public License for more details.
  16.     
  17.     You should have received a copy of the GNU General Public License
  18.     along with Harvest C; see the file COPYING.  If not, write to
  19.     the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  20.     
  21.     Harvest C is not in any way a product of the Free Software Foundation.
  22.     Harvest C is not GNU software.
  23.     Harvest C is not public domain.
  24.  
  25.     This file may have other copyrights which are applicable as well.
  26.  
  27. */
  28.  
  29. /*
  30.  * Harvest C
  31.  * 
  32.  * Copyright 1991 Eric W. Sink   All rights reserved.
  33.  * 
  34.  * This file contains utility routines for the 68k code generator
  35.  * 
  36.  * 
  37.  */
  38.  
  39.  
  40. #include "conditcomp.h"
  41. #include <stdio.h>
  42. #include <string.h>
  43. #include "structs.h"
  44.  
  45. #pragma segment GenBLD
  46.  
  47.  
  48. LabSYMVia_t
  49. AddLabel(char *name)
  50. /* Adds the name given to the label list. Returns the label record. */
  51. {
  52.     LabSYMVia_t                     lab = NULL;
  53.     lab = LabTableSearch(Labels, name);
  54. #ifdef Undefined
  55.     assert(!lab);
  56. #endif
  57.     if (!lab) {
  58.     lab = LabTableAdd(Labels, name);
  59.     }
  60.     return lab;
  61. }
  62.  
  63. LabSYMVia_t
  64. MakeSysLabel(char *name)
  65. {
  66.     return AddLabel(name);
  67. }
  68.  
  69. LabSYMVia_t
  70. MakeUserLabel(char *name)
  71. /*
  72.  * Takes a name, prepends an underscore, adds the name to the label list, and
  73.  * returns the label record.
  74.  */
  75. {
  76.     return AddLabel(name);
  77. }
  78.  
  79. LabSYMVia_t
  80. MakeFloatLitLabel(int num)
  81. /*
  82.  * Given a float literal number, generates a string literal label of the form
  83.  * FLOATnum, adds it to the label list, and returns the label record.
  84.  */
  85. {
  86.     char                            lab[25];
  87.     char                            lab2[25];
  88.     strcpy(lab2, "F");
  89.     sprintf(lab, "%d", num);
  90.     strcat(lab2, lab);
  91.     return AddLabel(lab2);
  92. }
  93.  
  94. LabSYMVia_t
  95. MakeLitLabel(int num)
  96. /*
  97.  * Given a string literal number, generates a string literal label of the
  98.  * form LITnum, adds it to the label list, and returns the label record.
  99.  */
  100. {
  101.     char                            lab[25];
  102.     char                            lab2[25];
  103.     strcpy(lab2, "S");
  104.     sprintf(lab, "%d", num);
  105.     strcat(lab2, lab);
  106.     return AddLabel(lab2);
  107. }
  108.  
  109. LabSYMVia_t
  110. MakeEccLabel(int num)
  111. /*
  112.  * Given an ecc label number, generates a label of the form LABnum, adds it
  113.  * to the label list, and returns the label record.  Ecc labels are generated
  114.  * for a number of circumstances including loops, ifthenelse, switch, etc...
  115.  */
  116. {
  117.     char                            lab[25];
  118.     char                            lab2[25];
  119.     strcpy(lab2, "L");
  120.     sprintf(lab, "%d", num);
  121.     strcat(lab2, lab);
  122.     return AddLabel(lab2);
  123. }
  124.