Quick Search:

Mode

Context

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

Other Diffs

Ignore

Blank Lines Whitespace: Expand:

Diff

1.351
 
1.352
 
MAIN:plunky:20120810071248
 
pftn.c
_>19011901         union dimfun df;
 19021902 };
 19031903 
<>1904 -static void tyreduce(NODE *p, struct tylnk **, int *);
 1905 -
 1906 -static void
 1907 -tylkadd(union dimfun dim, struct tylnk **tylkp, int *ntdim)
 1908 -{
 1909 -        (*tylkp)->next = tmpalloc(sizeof(struct tylnk));
 1910 -        *tylkp = (*tylkp)->next;
 1911 -        (*tylkp)->next = NULL;
 1912 -        (*tylkp)->df = dim;
 1913 -        (*ntdim)++;
 1914 -}
 1915 -
19161904 /*
<>1917 - * merge type typ with identifier idp.
 1918 - * idp is returned as a NAME node with correct types,
 1919 - * typ is untouched since multiple declarations uses it.
 1920 - * typ has type attributes, idp can never carry such attributes
 1921 - * so on return just a pointer to the typ attributes is returned.
 1922 - */
 1923 -NODE *
 1924 -tymerge(NODE *typ, NODE *idp)
 1925 -{
 1926 -        TWORD t;
 1927 -        NODE *p;
 1928 -        union dimfun *j;
 1929 -        struct tylnk *base, tylnk, *tylkp;
 1930 -        struct attr *bap;
 1931 -        int ntdim, i;
 1932 -
 1933 -#ifdef PCC_DEBUG
 1934 -        if (ddebug > 2) {
 1935 -                printf("tymerge(%p,%p)\n", typ, idp);
 1936 -                fwalk(typ, eprint, 0);
 1937 -                fwalk(idp, eprint, 0);
 1938 -        }
 1939 -#endif
 1940 -
 1941 -        if (typ->n_op != TYPE)
 1942 -                cerror("tymerge: arg 1");
 1943 -
 1944 -        bap = typ->n_ap;
 1945 -
 1946 -        idp->n_type = typ->n_type;
 1947 -        idp->n_qual |= typ->n_qual;
 1948 -
 1949 -        tylkp = &tylnk;
 1950 -        tylkp->next = NULL;
 1951 -        ntdim = 0;
 1952 -
 1953 -        tyreduce(idp, &tylkp, &ntdim);
 1954 -
 1955 -        for (t = typ->n_type, j = typ->n_df; t&TMASK; t = DECREF(t))
 1956 -                if (ISARY(t) || ISFTN(t))
 1957 -                        tylkadd(*j++, &tylkp, &ntdim);
 1958 -
 1959 -        if (ntdim) {
 1960 -                union dimfun *a = permalloc(sizeof(union dimfun) * ntdim);
 1961 -                dimfuncnt += ntdim;
 1962 -                for (i = 0, base = tylnk.next; base; base = base->next, i++)
 1963 -                        a[i] = base->df;
 1964 -                idp->n_df = a;
 1965 -        } else
 1966 -                idp->n_df = NULL;
 1967 -
 1968 -        /* now idp is a single node: fix up type */
 1969 -        if ((t = ctype(idp->n_type)) != idp->n_type)
 1970 -                idp->n_type = t;
 1971 -        
 1972 -        if (idp->n_op != NAME) {
 1973 -                for (p = idp->n_left; p->n_op != NAME; p = p->n_left)
 1974 -                        nfree(p);
 1975 -                nfree(p);
 1976 -                idp->n_op = NAME;
 1977 -        }
 1978 -        idp->n_ap = bap;
 1979 -
 1980 -        return(idp);
 1981 -}
 1982 -
 1983 -/*
19841905  * Retrieve all CM-separated argument types, sizes and dimensions and
 19851906  * put them in an array.
 19861907  * XXX - can only check first type level, side effects?
     
 !
20862007         return al;
 20872008 }
 20882009 
<> 2010+static void
  2011+tylkadd(union dimfun dim, struct tylnk **tylkp, int *ntdim)
  2012+{
  2013+        (*tylkp)->next = tmpalloc(sizeof(struct tylnk));
  2014+        *tylkp = (*tylkp)->next;
  2015+        (*tylkp)->next = NULL;
  2016+        (*tylkp)->df = dim;
  2017+        (*ntdim)++;
  2018+}
  2019+
20892020 /*
 20902021  * build a type, and stash away dimensions,
 20912022  * from a parse tree of the declaration
 20922023  * the type is build top down, the dimensions bottom up
 20932024  */
<>2094 -void
  2025+static void
20952026 tyreduce(NODE *p, struct tylnk **tylkp, int *ntdim)
 20962027 {
 20972028         union dimfun dim;
     
 !
21502081         p->n_qual = p->n_left->n_qual;
 21512082 }
 21522083 
<> 2084+/*
  2085+ * merge type typ with identifier idp.
  2086+ * idp is returned as a NAME node with correct types,
  2087+ * typ is untouched since multiple declarations uses it.
  2088+ * typ has type attributes, idp can never carry such attributes
  2089+ * so on return just a pointer to the typ attributes is returned.
  2090+ */
  2091+NODE *
  2092+tymerge(NODE *typ, NODE *idp)
  2093+{
  2094+        TWORD t;
  2095+        NODE *p;
  2096+        union dimfun *j;
  2097+        struct tylnk *base, tylnk, *tylkp;
  2098+        struct attr *bap;
  2099+        int ntdim, i;
  2100+
  2101+#ifdef PCC_DEBUG
  2102+        if (ddebug > 2) {
  2103+                printf("tymerge(%p,%p)\n", typ, idp);
  2104+                fwalk(typ, eprint, 0);
  2105+                fwalk(idp, eprint, 0);
  2106+        }
  2107+#endif
  2108+
  2109+        if (typ->n_op != TYPE)
  2110+                cerror("tymerge: arg 1");
  2111+
  2112+        bap = typ->n_ap;
  2113+
  2114+        idp->n_type = typ->n_type;
  2115+        idp->n_qual |= typ->n_qual;
  2116+
  2117+        tylkp = &tylnk;
  2118+        tylkp->next = NULL;
  2119+        ntdim = 0;
  2120+
  2121+        tyreduce(idp, &tylkp, &ntdim);
  2122+
  2123+        for (t = typ->n_type, j = typ->n_df; t&TMASK; t = DECREF(t))
  2124+                if (ISARY(t) || ISFTN(t))
  2125+                        tylkadd(*j++, &tylkp, &ntdim);
  2126+
  2127+        if (ntdim) {
  2128+                union dimfun *a = permalloc(sizeof(union dimfun) * ntdim);
  2129+                dimfuncnt += ntdim;
  2130+                for (i = 0, base = tylnk.next; base; base = base->next, i++)
  2131+                        a[i] = base->df;
  2132+                idp->n_df = a;
  2133+        } else
  2134+                idp->n_df = NULL;
  2135+
  2136+        /* now idp is a single node: fix up type */
  2137+        if ((t = ctype(idp->n_type)) != idp->n_type)
  2138+                idp->n_type = t;
  2139+        
  2140+        if (idp->n_op != NAME) {
  2141+                for (p = idp->n_left; p->n_op != NAME; p = p->n_left)
  2142+                        nfree(p);
  2143+                nfree(p);
  2144+                idp->n_op = NAME;
  2145+        }
  2146+        idp->n_ap = bap;
  2147+
  2148+        return(idp);
  2149+}
  2150+
<_21532151 static NODE *
 21542152 argcast(NODE *p, TWORD t, union dimfun *d, struct attr *ap)
 21552153 {
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-08-30 22:13 +0200