Quick Search:

Mode

Context

Displaying 3 lines of context. None | Less | More | Full

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.4
 
1.5
 
MAIN:plunky:20120810071248
 
pftn.c
_>19241924         union dimfun df;
 19251925 };
 19261926 
<>1927 -static void tyreduce(NODE *p, struct tylnk **, int *);
 1928 -
 1929 -static void
 1930 -tylkadd(union dimfun dim, struct tylnk **tylkp, int *ntdim)
 1931 -{
 1932 -        (*tylkp)->next = tmpalloc(sizeof(struct tylnk));
 1933 -        *tylkp = (*tylkp)->next;
 1934 -        (*tylkp)->next = NULL;
 1935 -        (*tylkp)->df = dim;
 1936 -        (*ntdim)++;
 1937 -}
 1938 -
19391927 /*
<>1940 - * merge type typ with identifier idp.
 1941 - * idp is returned as a NAME node with correct types,
 1942 - * typ is untouched since multiple declarations uses it.
 1943 - * typ has type attributes, idp can never carry such attributes
 1944 - * so on return just a pointer to the typ attributes is returned.
 1945 - */
 1946 -NODE *
 1947 -tymerge(NODE *typ, NODE *idp)
 1948 -{
 1949 -        TWORD t;
 1950 -        NODE *p;
 1951 -        union dimfun *j;
 1952 -        struct tylnk *base, tylnk, *tylkp;
 1953 -        struct attr *bap;
 1954 -        int ntdim, i;
 1955 -
 1956 -#ifdef PCC_DEBUG
 1957 -        if (ddebug > 2) {
 1958 -                printf("tymerge(%p,%p)\n", typ, idp);
 1959 -                fwalk(typ, eprint, 0);
 1960 -                fwalk(idp, eprint, 0);
 1961 -        }
 1962 -#endif
 1963 -
 1964 -        if (typ->n_op != TYPE)
 1965 -                cerror("tymerge: arg 1");
 1966 -
 1967 -        bap = typ->n_ap;
 1968 -
 1969 -        idp->n_type = typ->n_type;
 1970 -        idp->n_qual |= typ->n_qual;
 1971 -
 1972 -        tylkp = &tylnk;
 1973 -        tylkp->next = NULL;
 1974 -        ntdim = 0;
 1975 -
 1976 -        tyreduce(idp, &tylkp, &ntdim);
 1977 -
 1978 -        for (t = typ->n_type, j = typ->n_df; t&TMASK; t = DECREF(t))
 1979 -                if (ISARY(t) || ISFTN(t))
 1980 -                        tylkadd(*j++, &tylkp, &ntdim);
 1981 -
 1982 -        if (ntdim) {
 1983 -                union dimfun *a = permalloc(sizeof(union dimfun) * ntdim);
 1984 -                dimfuncnt += ntdim;
 1985 -                for (i = 0, base = tylnk.next; base; base = base->next, i++)
 1986 -                        a[i] = base->df;
 1987 -                idp->n_df = a;
 1988 -        } else
 1989 -                idp->n_df = NULL;
 1990 -
 1991 -        /* now idp is a single node: fix up type */
 1992 -        if ((t = ctype(idp->n_type)) != idp->n_type)
 1993 -                idp->n_type = t;
 1994 -        
 1995 -        if (idp->n_op != NAME) {
 1996 -                for (p = idp->n_left; p->n_op != NAME; p = p->n_left)
 1997 -                        nfree(p);
 1998 -                nfree(p);
 1999 -                idp->n_op = NAME;
 2000 -        }
 2001 -        idp->n_ap = bap;
 2002 -
 2003 -        return(idp);
 2004 -}
 2005 -
 2006 -/*
20071928  * Retrieve all CM-separated argument types, sizes and dimensions and
 20081929  * put them in an array.
 20091930  * XXX - can only check first type level, side effects?
     
 !
21012022         return al;
 21022023 }
 21032024 
<> 2025+static void
  2026+tylkadd(union dimfun dim, struct tylnk **tylkp, int *ntdim)
  2027+{
  2028+        (*tylkp)->next = tmpalloc(sizeof(struct tylnk));
  2029+        *tylkp = (*tylkp)->next;
  2030+        (*tylkp)->next = NULL;
  2031+        (*tylkp)->df = dim;
  2032+        (*ntdim)++;
  2033+}
  2034+
21042035 /*
 21052036  * build a type, and stash away dimensions,
 21062037  * from a parse tree of the declaration
 21072038  * the type is build top down, the dimensions bottom up
 21082039  */
<>2109 -void
  2040+static void
21102041 tyreduce(NODE *p, struct tylnk **tylkp, int *ntdim)
 21112042 {
 21122043         union dimfun dim;
     
 !
21652096         p->n_qual = p->n_left->n_qual;
 21662097 }
 21672098 
<> 2099+/*
  2100+ * merge type typ with identifier idp.
  2101+ * idp is returned as a NAME node with correct types,
  2102+ * typ is untouched since multiple declarations uses it.
  2103+ * typ has type attributes, idp can never carry such attributes
  2104+ * so on return just a pointer to the typ attributes is returned.
  2105+ */
  2106+NODE *
  2107+tymerge(NODE *typ, NODE *idp)
  2108+{
  2109+        TWORD t;
  2110+        NODE *p;
  2111+        union dimfun *j;
  2112+        struct tylnk *base, tylnk, *tylkp;
  2113+        struct attr *bap;
  2114+        int ntdim, i;
  2115+
  2116+#ifdef PCC_DEBUG
  2117+        if (ddebug > 2) {
  2118+                printf("tymerge(%p,%p)\n", typ, idp);
  2119+                fwalk(typ, eprint, 0);
  2120+                fwalk(idp, eprint, 0);
  2121+        }
  2122+#endif
  2123+
  2124+        if (typ->n_op != TYPE)
  2125+                cerror("tymerge: arg 1");
  2126+
  2127+        bap = typ->n_ap;
  2128+
  2129+        idp->n_type = typ->n_type;
  2130+        idp->n_qual |= typ->n_qual;
  2131+
  2132+        tylkp = &tylnk;
  2133+        tylkp->next = NULL;
  2134+        ntdim = 0;
  2135+
  2136+        tyreduce(idp, &tylkp, &ntdim);
  2137+
  2138+        for (t = typ->n_type, j = typ->n_df; t&TMASK; t = DECREF(t))
  2139+                if (ISARY(t) || ISFTN(t))
  2140+                        tylkadd(*j++, &tylkp, &ntdim);
  2141+
  2142+        if (ntdim) {
  2143+                union dimfun *a = permalloc(sizeof(union dimfun) * ntdim);
  2144+                dimfuncnt += ntdim;
  2145+                for (i = 0, base = tylnk.next; base; base = base->next, i++)
  2146+                        a[i] = base->df;
  2147+                idp->n_df = a;
  2148+        } else
  2149+                idp->n_df = NULL;
  2150+
  2151+        /* now idp is a single node: fix up type */
  2152+        if ((t = ctype(idp->n_type)) != idp->n_type)
  2153+                idp->n_type = t;
  2154+        
  2155+        if (idp->n_op != NAME) {
  2156+                for (p = idp->n_left; p->n_op != NAME; p = p->n_left)
  2157+                        nfree(p);
  2158+                nfree(p);
  2159+                idp->n_op = NAME;
  2160+        }
  2161+        idp->n_ap = bap;
  2162+
  2163+        return(idp);
  2164+}
  2165+
<_21682166 static NODE *
 21692167 argcast(NODE *p, TWORD t, union dimfun *d, struct attr *ap)
 21702168 {
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-09-24 04:27 +0200