Quick Search:

View

Revision:
Expand:  
Changeset: MAIN:ragge:20060318153043

Diff

Diff from 1.6 to:

Annotations

Annotate by Age | Author | Mixed | None
/fisheye/browse/pcc/pcc/cc/ccom/gcc_compat.c

Annotated File View

ragge
1.6
1 /*      $Id: gcc_compat.c,v 1.6 2006/03/18 15:30:47 ragge Exp $     */
ragge
1.1
2 /*
3  * Copyright (c) 2004 Anders Magnusson (ragge@ludd.luth.se).
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  *    notice, this list of conditions and the following disclaimer in the
13  *    documentation and/or other materials provided with the distribution.
14  * 3. The name of the author may not be used to endorse or promote products
15  *    derived from this software without specific prior written permission
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  */
28
29 /*
30  * Routines to support some of the gcc extensions to C.
31  */
32 #ifdef GCC_COMPAT
33
34 #include "pass1.h"
ragge
1.5
35 #include "cgram.h"
ragge
1.1
36
ragge
1.2
37 #include <string.h>
38
ragge
1.1
39 static struct kw {
40         char *name, *ptr;
41         int rv;
42 kw[] = {
43         { "__asm__"NULLC_ASM },
ragge
1.6
44         { "__asm"NULLC_ASM },
ragge
1.1
45         { "__signed"NULL0 },
46         { "__inline"NULLC_FUNSPEC },
ragge
1.4
47         { "__const"NULL0 },
ragge
1.1
48         { NULLNULL0 },
49 };
50
51 void
52 gcc_init()
53 {
54         struct kw *kwp;
55
56         for (kwp = kwkwp->namekwp++)
57                 kwp->ptr = addname(kwp->name);
58
59 }
60
61 /*
62  * See if a string matches a gcc keyword.
63  */
64 int
ragge
1.5
65 gcc_keyword(char *strNODE **n)
ragge
1.1
66 {
67         struct kw *kwp;
68         int i;
69
70         for (i = 0kwp = kwkwp->namekwp++, i++)
ragge
1.5
71                 if (str == kwp->ptr)
ragge
1.1
72                         break;
73         if (kwp->name == NULL)
74                 return 0;
75         if (kwp->rv)
76                 return kwp->rv;
77         switch (i) {
78         case 1/* __signed */
ragge
1.5
79                 *n = mkty((TWORD)SIGNED0MKSUE(SIGNED));
ragge
1.1
80                 return C_TYPE;
ragge
1.4
81         case 3/* __const */
ragge
1.5
82                 *n = block(QUALIFIERNILNILCON00);
ragge
1.4
83                 return C_QUALIFIER;
ragge
1.1
84         }
85         cerror("gcc_keyword");
86         return 0;
87 }
88
89 static struct ren {
90         struct ren *next;
91         char *old, *new;
92 } *renp;
93 /*
94  * Save a name for later renaming of a variable.
95  */
96 void
97 gcc_rename(struct symtab *spchar *newname)
98 {
99         struct ren *ren = permalloc(sizeof(struct ren));
100
101         sp->sflags |= SRENAME;
102         ren->old = sp->sname;
103         ren->new = newstring(newnamestrlen(newname)+1);
104         ren->next = renp;
105         renp = ren;
106 }
107
108 /*
109  * Get a renamed variable.
110  */
111 char *
ragge
1.3
112 gcc_findname(struct symtab *sp)
ragge
1.1
113 {
114         struct ren *w;
115
ragge
1.3
116         if ((sp->sflags & SRENAME) == 0)
117                 return exname(sp->sname);
118
ragge
1.1
119         for (w = renpww = w->next) {
ragge
1.3
120                 if (w->old == sp->sname)
121                         return exname(w->new);
ragge
1.1
122         }
ragge
1.3
123         cerror("gcc_findname %s"sp->sname);
ragge
1.1
124         return NULL;
125 }
126 #endif
FishEye: Open Source License registered to PCC.
Your maintenance has expired. You can renew your license at http://www.atlassian.com/fisheye/renew
Atlassian FishEye, CVS analysis. (Version:1.6.3 Build:build-336 2008-11-04) - Administration - Page generated 2014-11-01 10:46 +0100