Esempio n. 1
0
int main()
{
    dynamic test;
//    dynamic accept = (dynamic) test_function(test);
    void (*accept2)(dynamic *);
    accept2 = &test_function;
    accept2(&test);

//    test_function(&test);

    printf("\n Entered : %s", &test);

    return 0;
}
TEST_F(HeaderTableTests, evict) {
  HPACKHeader accept("accept-encoding", "gzip");
  HPACKHeader accept2("accept-encoding", "----"); // same size, different header
  HPACKHeader accept3("accept-encoding", "third"); // size is larger with 1 byte
  uint32_t max = 10;
  uint32_t capacity = accept.bytes() * max;
  HeaderTable table(capacity);
  // fill the table
  for (size_t i = 0; i < max; i++) {
    EXPECT_EQ(table.add(accept), true);
  }
  EXPECT_EQ(table.size(), max);
  EXPECT_EQ(table.add(accept2), true);
  // evict the first one
  EXPECT_EQ(table[1], accept2);
  auto ilist = table.names().find("accept-encoding")->second;
  EXPECT_EQ(ilist.size(), max);
  // evict all the 'accept' headers
  for (size_t i = 0; i < max - 1; i++) {
    EXPECT_EQ(table.add(accept2), true);
  }
  EXPECT_EQ(table.size(), max);
  EXPECT_EQ(table[max], accept2);
  EXPECT_EQ(table.names().size(), 1);
  // add an entry that will cause 2 evictions
  EXPECT_EQ(table.add(accept3), true);
  EXPECT_EQ(table[1], accept3);
  EXPECT_EQ(table.size(), max - 1);

  // add a super huge header
  string bigvalue;
  bigvalue.append(capacity, 'x');
  HPACKHeader bigheader("user-agent", bigvalue);
  EXPECT_EQ(table.add(bigheader), false);
  EXPECT_EQ(table.size(), 0);
  EXPECT_EQ(table.names().size(), 0);
}
Esempio n. 3
0
void ForLoop::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitForLoop);
}
Esempio n. 4
0
void Closure::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitClosure);
}
Esempio n. 5
0
void Import::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitImport);
}
Esempio n. 6
0
void UnaryOperator::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitUnaryOperator);
}
Esempio n. 7
0
void StructDef::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitStruct);
}
Esempio n. 8
0
void Tuple::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitTuple);
}
Esempio n. 9
0
static void
genextend(graph *g, int n2, int *deg, int ne, boolean rigid, int xlb, int xub)
/* extend from n2 to n2+1 */
{
    int x,y,d;
    int *xorb,xc;
    int nx,i,j,imin,imax,dmax;
    int xlbx,xubx,n;
    graph gx[MAXN];
    int degx[MAXN];
    boolean rigidx;
    int dneed,need,nfeet,hideg,deg1,ft[MAXN],nfrag,frag[MAXN];

#ifdef INSTRUMENT
    boolean haschild;

    haschild = FALSE;
    ++nodes[n2];
    if (rigid) ++rigidnodes[n2];
#endif

    n = n1 + n2;
    nx = n2 + 1;
    dmax = deg[n-1];

    d = 0;
    dneed = mindeg1 - maxn2 + n2;
    need = 0;
    hideg = 0;
    deg1 = 0;
    for (i = 0; i < n1; ++i)
    {
        if (deg[i] == maxdeg1) d |= xbit[i];
        if (deg[i] <= dneed) need |= xbit[i];
        if (deg[i] >= 2) hideg |= xbit[i];
        if (deg[i] == 1) deg1 |= xbit[i];
    }

    if (xlb < XPOPCOUNT(need)) xlb = XPOPCOUNT(need);
    if (xlb > xub) return;

    imin = xstart[xlb];
    imax = xstart[xub+1];
    xorb = data[n2].xorb;

    if (nx == maxn2)
    {
        if (footfree)
        {
            nfeet = 0;
            for (j = 0; j < n2; ++j)
            {
                x = xval[j] & hideg;
                IFLE1BITS(x) ft[nfeet++] = xval[j] & deg1;
            }
        }
        if (cutfree) fragments(xval,n2,frag,&nfrag);

        for (i = imin; i < imax; ++i)
        {
            if (!rigid && xorb[i] != i) continue;
            x = xset[i];
            xc = xcard[i];
            if ((x & d) != 0) continue;
            if ((need & ~x) != 0) continue;

            if (simple)
            {
                for (j = n2; --j >= 0;)
                    if (x == xval[j]) break;
                if (j >= 0) continue;
            }
            if (maxcommon >= 0)
            {
                for (j = n2; --j >= 0;)
                {
                    y = x & xval[j];
                    if (XPOPCOUNT(y) > maxcommon) break;
                }
                if (j >= 0) continue;
            }
	    if (antichain)
	    {
		for (j = 0; j < n2; ++j)
		    if ((xval[j] & ~x) == 0) break;
		if (j < n2) continue;
	    }
            if (footfree)
            {
                y = x & (hideg | deg1);
                IFLE1BITS(y) continue;
                for (j = 0; j < nfeet; ++j)
                    if ((x & ft[j]) == 0) break;
                if (j < nfeet) continue;
            }
            if (cutfree)
            {
                y = x & (hideg | deg1);
                IFLE1BITS(y) continue;
                for (j = 0; j < nfrag; ++j)
                    if ((x & frag[j]) == 0) break;
                if (j < nfrag) continue;
            }

            xval[n2] = x;

            if (nx == nprune)
            {
                if (curres == 0) curres = mod;
#ifdef SPLITTEST
                --curres;
                ++splitcases;
                continue;
#else
                if (--curres != 0) continue;
#endif
            }
            if (accept2(g,n2,x,gx,deg,xc > dmax))
                if (!connec || isconnected(gx,n+1))
                {
                    ADDBIG(ecount[ne+xc],1);
#ifdef INSTRUMENT
                    haschild = TRUE;
#endif
                    (*outproc)(outfile,canonise ? gcan : gx,n1,n2+1);
                }
        }
    }
    else
    {
        for (i = imin; i < imax; ++i)
Esempio n. 10
0
void ConditionalOperator::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitConditionalOperator);
}
Esempio n. 11
0
void DictionaryLiteral::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitDictionaryLiteral);
}
Esempio n. 12
0
void BreakStatement::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitBreak);
}
Esempio n. 13
0
void CaseStatement::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitCase);
}
Esempio n. 14
0
void ValueBindings::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitValueBindings);
}
Esempio n. 15
0
static void
genextend(graph *g, int n, int *deg, boolean rigid)
/* extend from n to n+1 -- version for general graphs */
{
        xword x,dlow,dhigh,dcrit;
        xword *xset,*xcard,*xorb;
	xword i,imin,imax;
        int nx,xc,j,dmax;
        int xlb,xub,xlbx,xubx;
        graph gx[MAXN];
        int degx[MAXN];
        boolean rigidx;
	boolean subconnec;

#ifdef INSTRUMENT
        boolean haschild;

        haschild = FALSE;
        if (rigid) ++rigidnodes[n];
#endif
        nx = n + 1;
        ADDBIG(nodes[n],1);

	if (regular && nx == maxn)
	{
	    x = 0;
	    for (i = 0; i < n; ++i)
		if (deg[i] == maxdeg) x |= xbit[i];

            if (accept2(g,n,x,gx,deg,FALSE))
            {
#ifdef PRUNE
                if (!PRUNE(gx,nx,maxn))
#endif
		{
#ifdef INSTRUMENT
                    haschild = TRUE;
#endif
		    ADDBIG(nout,1);
                    (*outproc)(outfile,canonise ? gcan : gx,nx);
		}
            }
#ifdef INSTRUMENT
            if (haschild) ++fertilenodes[n];
#endif
	    return;
	}

        dmax = deg[n-1];

	xlb = mindeg + n + 1 - maxn;
	if (0 > xlb) xlb = 0;
	xub = dmax+1;
	if (n/2 < xub) xub = n/2;
	if (maxdeg < xub) xub = maxdeg;

	if (xlb > xub) return;

        dlow = dcrit = dhigh = 0;
        for (i = 0; i < n; ++i)
	{
            if (deg[i] == dmax) dlow |= xbit[i];
	    if (deg[i] == maxdeg) dhigh |= xbit[i];
	    if (deg[i] == mindeg + n - maxn) dcrit |= xbit[i];
	}

        if (XPOPCOUNT(dhigh) > xlb) xlb = XPOPCOUNT(dhigh);
	if (n-XPOPCOUNT(dcrit) < xub) xub = n - XPOPCOUNT(dcrit);
	if (xub == dmax+1 && XPOPCOUNT(dlow)+dmax >= n) --xub;
        if (xlb > xub) return;

#ifdef PRUNE 
        if (PRUNE(g,n,maxn)) return; 
#endif 

        imin = data[n].xstart[xlb];
        imax = data[n].xstart[xub+1];
        xset = data[n].xset;
        xcard = data[n].xcard;
        xorb = data[n].xorb;

        if (nx == maxn)
	{
	    subconnec = connec && isstrong(g,n);
            for (i = imin; i < imax; ++i)
            {
                if (!rigid && xorb[i] != i) continue;
                x = xset[i];
                xc = xcard[i];
                if (xc == dmax+1 && (x & dlow) != 0) continue;
 		if ((dhigh & ~x) != 0) continue;
		if ((dcrit & x) != 0) continue;

                if (accept2(g,n,x,gx,deg,
                            xc < dmax || (xc == dmax && (x & dlow) == 0)))
                    if (!connec || (subconnec && x != 0) || isstrong(gx,nx))
                    {
#ifdef PRUNE
                        if (!PRUNE(gx,nx,maxn))
#endif
			{
#ifdef INSTRUMENT
                            haschild = TRUE;
#endif
			    ADDBIG(nout,1);
                            (*outproc)(outfile,canonise ? gcan : gx,nx);
			}
                    }
            }
	}
        else
	{
            for (i = imin; i < imax; ++i)
            {
                if (!rigid && xorb[i] != i) continue;
                x = xset[i];
                xc = xcard[i];
                if (xc == dmax+1 && (x & dlow) != 0) continue;
 		if ((dhigh & ~x) != 0) continue;
		if ((dcrit & x) != 0) continue;
                if (nx == splitlevel)
                {
                    if (odometer-- != 0) continue;
                    odometer = mod - 1;
                }

                for (j = 0; j < n; ++j) degx[j] = deg[j];
                xlbx = mindeg+nx+1-maxn;
		if (xlbx < 0) xlbx = 0;
		xubx = xc + 1;
		if (maxdeg < xubx) xubx = maxdeg;
		if (nx/2 < xubx) xubx = nx/2;
                if (xlbx > xubx) continue;

                data[nx].lo = data[nx].xstart[xlbx];
                data[nx].hi = data[nx].xstart[xubx+1];
                if (accept1(g,n,x,gx,degx,&rigidx))
                {
#ifdef INSTRUMENT
                    haschild = TRUE;
#endif
                    genextend(gx,nx,degx,rigidx);
                }
            }
	}

        if (n == splitlevel-1 && n >= min_splitlevel
                && ISASBIG(nodes[n],multiplicity))
            --splitlevel;
#ifdef INSTRUMENT
        if (haschild) ++fertilenodes[n];
#endif
}
Esempio n. 16
0
void DefaultValue::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitDefaultValue);
}
Esempio n. 17
0
void ParameterNode::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitParameter);

}
Esempio n. 18
0
void IntegerLiteral::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitInteger);
}
Esempio n. 19
0
void InitializerDef::accept(NodeVisitor* visitor)
{
    accept2(visitor, &NodeVisitor::visitInit);
}