当前位置: 首页>>代码示例>>C++>>正文


C++ Expressions类代码示例

本文整理汇总了C++中Expressions的典型用法代码示例。如果您正苦于以下问题:C++ Expressions类的具体用法?C++ Expressions怎么用?C++ Expressions使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Expressions类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Expressions

Expression *ArrayInitializer::toExpression()
{   Expressions *elements;
    Expression *e;

    //printf("ArrayInitializer::toExpression()\n");
    //static int i; if (++i == 2) halt();
    elements = new Expressions();
    for (size_t i = 0; i < value.dim; i++)
    {
	if (index.data[i])
	    goto Lno;
	Initializer *iz = (Initializer *)value.data[i];
	if (!iz)
	    goto Lno;
	Expression *ex = iz->toExpression();
	if (!ex)
	    goto Lno;
	elements->push(ex);
    }
    e = new ArrayLiteralExp(loc, elements);
    e->type = type;
    return e;

Lno:
    delete elements;
    //error(loc, "array initializers as expressions are not allowed");
    return NULL;
}
开发者ID:apriori,项目名称:dsss,代码行数:28,代码来源:init.c

示例2: Expressions

Expression *ArrayInitializer::toAssocArrayLiteral()
{
    Expression *e;

    //printf("ArrayInitializer::toAssocArrayInitializer()\n");
    //static int i; if (++i == 2) halt();
    Expressions *keys = new Expressions();
    keys->setDim(value.dim);
    Expressions *values = new Expressions();
    values->setDim(value.dim);

    for (size_t i = 0; i < value.dim; i++)
    {
        e = index[i];
        if (!e)
            goto Lno;
        (*keys)[i] = e;

        Initializer *iz = value[i];
        if (!iz)
            goto Lno;
        e = iz->toExpression();
        if (!e)
            goto Lno;
        (*values)[i] = e;
    }
    e = new AssocArrayLiteralExp(loc, keys, values);
    return e;

Lno:
    delete keys;
    delete values;
    error(loc, "not an associative array initializer");
    return new ErrorExp();
}
开发者ID:dansanduleac,项目名称:ldc,代码行数:35,代码来源:init.c

示例3: after

void TypeChecker::after(block_class *node) {
    Expressions body = node->get_body();
    Symbol last_body_type = body->nth(body->len() - 1)->get_type();
    if (!last_body_type) {
        return;
    }
    node->set_type(last_body_type);
}
开发者ID:tanhevg,项目名称:cool-compiler,代码行数:8,代码来源:type_checker.cpp

示例4: visit

 void visit(SliceExp *e)
 {
     Identifier *id = Identifier::generateId("p", fparams->dim);
     Parameter *param = new Parameter(STCconst, e->type, id, NULL);
     fparams->shift(param);
     Expression *ie = new IdentifierExp(Loc(), id);
     Expressions *arguments = new Expressions();
     Expression *index = new IdentifierExp(Loc(), Id::p);
     arguments->push(index);
     result = new ArrayExp(Loc(), ie, arguments);
 }
开发者ID:hariomrana,项目名称:dmd,代码行数:11,代码来源:arrayop.c

示例5: Parameter

Expression *SliceExp::buildArrayLoop(Parameters *fparams)
{
    Identifier *id = Identifier::generateId("p", fparams->dim);
    Parameter *param = new Parameter(STCconst, type, id, NULL);
    fparams->shift(param);
    Expression *e = new IdentifierExp(0, id);
    Expressions *arguments = new Expressions();
    Expression *index = new IdentifierExp(0, Id::p);
    arguments->push(index);
    e = new ArrayExp(0, e, arguments);
    return e;
}
开发者ID:OlioEngr,项目名称:dmd,代码行数:12,代码来源:arrayop.c

示例6: ProblemDomain

ProblemDomain mtac::global_cse::Boundary(mtac::Function& function){
    this->function = &function;
    
    pointer_escaped = mtac::escape_analysis(function);

    typename ProblemDomain::Values values;
    
    //Compute Eval(i)

    for(auto& block : function){
        for(auto& q : block->statements){
            if(mtac::is_expression(q.op) && mtac::is_valid(q, pointer_escaped) && mtac::is_interesting(q)){
                Eval[block].insert({0, *q.arg1, *q.arg2, q.op, nullptr, q.result->type()});
            }

            mtac::kill_expressions(q, Eval[block]);
        }
    }

    //Compute Kill(i)
    
    for(auto& block : function){
        for(auto& q : block->statements){
            auto op = q.op;
            if(mtac::erase_result(op) || op == mtac::Operator::DOT_ASSIGN || op == mtac::Operator::DOT_FASSIGN || op == mtac::Operator::DOT_PASSIGN){
                for(auto& b : function){
                    if(b != block){
                        for(auto& expression : Eval[b]){
                            if(mtac::is_killing(q, expression)){
                                Kill[block].insert(expression);
                            }
                        }
                    }
                }
            }
        }
    }

    Expressions expressions;

    //Compute Uexp

    for(auto& block : function){
        for(auto& expression : Eval[block]){
            expressions.insert(expression);
        }
    }

    init = std::move(expressions);

    return ProblemDomain(ProblemDomain::Values());
}
开发者ID:ssarangi,项目名称:eddic,代码行数:52,代码来源:global_cse.cpp

示例7: search_function

FuncDeclaration *hasIdentityOpAssign(AggregateDeclaration *ad, Scope *sc)
{
    Dsymbol *assign = search_function(ad, Id::assign);
    if (assign)
    {
        /* check identity opAssign exists
         */
        Expression *er = new NullExp(ad->loc, ad->type);    // dummy rvalue
        Expression *el = new IdentifierExp(ad->loc, Id::p); // dummy lvalue
        el->type = ad->type;
        Expressions *a = new Expressions();
        a->setDim(1);
        FuncDeclaration *f = NULL;

        unsigned errors = global.startGagging();    // Do not report errors, even if the
        unsigned oldspec = global.speculativeGag;   // template opAssign fbody makes it.
        global.speculativeGag = global.gag;
        sc = sc->push();
        sc->speculative = true;

        for (size_t i = 0; i < 2; i++)
        {
            (*a)[0] = (i == 0 ? er : el);
            f = resolveFuncCall(ad->loc, sc, assign, NULL, ad->type, a, 1);
            if (f)
                break;
        }

        sc = sc->pop();
        global.speculativeGag = oldspec;
        global.endGagging(errors);

        if (f)
        {
            if (f->errors)
                return NULL;
            int varargs;
            Parameters *fparams = f->getParameters(&varargs);
            if (fparams->dim >= 1)
            {
                Parameter *arg0 = Parameter::getNth(fparams, 0);
                if (arg0->type->toDsymbol(NULL) != ad)
                    f = NULL;
            }
        }
        // BUGS: This detection mechanism cannot find some opAssign-s like follows:
        // struct S { void opAssign(ref immutable S) const; }
        return f;
    }
    return NULL;
}
开发者ID:Zshazz,项目名称:dmd,代码行数:51,代码来源:clone.c

示例8: arrayExpressionSemantic

Expressions *UserAttributeDeclaration::getAttributes()
{
    if (scope)
    {
        Scope *sc = scope;
        scope = NULL;
        arrayExpressionSemantic(atts, sc);
    }

    Expressions *exps = new Expressions();
    if (userAttribDecl)
        exps->push(new TupleExp(Loc(), userAttribDecl->getAttributes()));
    if (atts && atts->dim)
        exps->push(new TupleExp(Loc(), atts));

    return exps;
}
开发者ID:doniexun,项目名称:ldc,代码行数:17,代码来源:attrib.c

示例9: if

Expressions *UserAttributeDeclaration::concat(Expressions *udas1, Expressions *udas2)
{
    Expressions *udas;
    if (!udas1 || udas1->dim == 0)
        udas = udas2;
    else if (!udas2 || udas2->dim == 0)
        udas = udas1;
    else
    {
        /* Create a new tuple that combines them
         * (do not append to left operand, as this is a copy-on-write operation)
         */
        udas = new Expressions();
        udas->push(new TupleExp(Loc(), udas1));
        udas->push(new TupleExp(Loc(), udas2));
    }
    return udas;
}
开发者ID:doniexun,项目名称:ldc,代码行数:18,代码来源:attrib.c

示例10: Expressions

Expressions *arrayExpressiondoInline(Expressions *a, InlineDoState *ids)
{   Expressions *newa = NULL;

    if (a)
    {
        newa = new Expressions();
        newa->setDim(a->dim);

        for (size_t i = 0; i < a->dim; i++)
        {   Expression *e = (*a)[i];

            if (e)
                e = e->doInline(ids);
            (*newa)[i] = e;
        }
    }
    return newa;
}
开发者ID:D-Programming-microD,项目名称:GDC,代码行数:18,代码来源:inline.c

示例11: NullExp

FuncDeclaration *AggregateDeclaration::hasIdentityOpAssign(Scope *sc, Dsymbol *assign)
{
    if (assign)
    {
        /* check identity opAssign exists
         */
        Expression *er = new NullExp(loc, type);        // dummy rvalue
        Expression *el = new IdentifierExp(loc, Id::p); // dummy lvalue
        el->type = type;
        Expressions ar;  ar.push(er);
        Expressions al;  al.push(el);
        FuncDeclaration *f = NULL;

        unsigned errors = global.startGagging();    // Do not report errors, even if the
        unsigned oldspec = global.speculativeGag;   // template opAssign fbody makes it.
        global.speculativeGag = global.gag;
        sc = sc->push();
        sc->speculative = true;

                 f = resolveFuncCall(loc, sc, assign, NULL, er, &ar, 1);
        if (!f)  f = resolveFuncCall(loc, sc, assign, NULL, er, &al, 1);

        sc = sc->pop();
        global.speculativeGag = oldspec;
        global.endGagging(errors);

        if (f)
        {
            int varargs;
            Parameters *fparams = f->getParameters(&varargs);
            if (fparams->dim >= 1)
            {
                Parameter *arg0 = Parameter::getNth(fparams, 0);
                if (arg0->type->toDsymbol(NULL) != this)
                    f = NULL;
            }
        }
        // BUGS: This detection mechanism cannot find some opAssign-s like follows:
        // struct S { void opAssign(ref immutable S) const; }
        return f;
    }
    return NULL;
}
开发者ID:Ingrater,项目名称:dmd,代码行数:43,代码来源:clone.c

示例12: Expressions

Expression *ExpInitializer::toExpression(Type *t)
{
    if (t)
    {
        Type *tb = t->toBasetype();
        if (tb->ty == Tsarray && exp->implicitConvTo(tb->nextOf()))
        {
            TypeSArray *tsa = (TypeSArray *)tb;
            size_t d = tsa->dim->toInteger();
            Expressions *elements = new Expressions();
            elements->setDim(d);
            for (size_t i = 0; i < d; i++)
                (*elements)[i] = exp;
            ArrayLiteralExp *ae = new ArrayLiteralExp(exp->loc, elements);
            ae->type = t;
            exp = ae;
        }
    }
    return exp;
}
开发者ID:develop32,项目名称:dmd,代码行数:20,代码来源:init.c

示例13: while

/***********************************
 * Parse list of extended asm clobbers.
 * Grammar:
 *      | Clobbers:
 *      |     StringLiteral
 *      |     StringLiteral , Clobbers
 * Params:
 *      p = parser state
 * Returns:
 *      array of parsed clobber expressions
 */
static Expressions *parseExtAsmClobbers(Parser *p)
{
    Expressions *clobbers = NULL;

    while (1)
    {
        Expression *clobber;

        switch (p->token.value)
        {
            case TOKsemicolon:
            case TOKcolon:
            case TOKeof:
                return clobbers;

            case TOKstring:
                clobber = p->parsePrimaryExp();
                if (!clobbers)
                    clobbers = new Expressions();
                clobbers->push(clobber);

                if (p->token.value == TOKcomma)
                    p->nextToken();
                break;

            default:
                p->error("expected constant string constraint for clobber name, not `%s`",
                        p->token.toChars());
                goto Lerror;
        }
    }
Lerror:
    while (p->token.value != TOKrcurly &&
           p->token.value != TOKsemicolon &&
           p->token.value != TOKeof)
        p->nextToken();

    return clobbers;
}
开发者ID:Lucretia,项目名称:gcc,代码行数:50,代码来源:iasmgcc.c

示例14: Expressions

Expression *ExpInitializer::toExpression(Type *t)
{
    if (t)
    {
        //printf("ExpInitializer::toExpression(t = %s) exp = %s\n", t->toChars(), exp->toChars());
        Type *tb = t->toBasetype();
        Expression *e = (exp->op == TOKconstruct || exp->op == TOKblit) ? ((AssignExp *)exp)->e2 : exp;
        if (tb->ty == Tsarray && e->implicitConvTo(tb->nextOf()))
        {
            TypeSArray *tsa = (TypeSArray *)tb;
            size_t d = (size_t)tsa->dim->toInteger();
            Expressions *elements = new Expressions();
            elements->setDim(d);
            for (size_t i = 0; i < d; i++)
                (*elements)[i] = e;
            ArrayLiteralExp *ae = new ArrayLiteralExp(e->loc, elements);
            ae->type = t;
            return ae;
        }
    }
    return exp;
}
开发者ID:NativeAPI,项目名称:dmd,代码行数:22,代码来源:init.c

示例15: Scope

void UserAttributeDeclaration::setScope(Scope *sc)
{
    //printf("UserAttributeDeclaration::setScope() %p\n", this);
    if (decl)
    {
        Scope *newsc = sc;
#if 1
        if (atts && atts->dim)
        {
            // create new one for changes
            newsc = new Scope(*sc);
            newsc->flags &= ~SCOPEfree;

            // Append new atts to old one
            if (!newsc->userAttributes || newsc->userAttributes->dim == 0)
                newsc->userAttributes = atts;
            else
            {
                // Create a tuple that combines them
                Expressions *exps = new Expressions();
                exps->push(new TupleExp(Loc(), newsc->userAttributes));
                exps->push(new TupleExp(Loc(), atts));
                newsc->userAttributes = exps;
            }
        }
#endif
        for (size_t i = 0; i < decl->dim; i++)
        {   Dsymbol *s = (*decl)[i];

            s->setScope(newsc); // yes, the only difference from semantic()
        }
        if (newsc != sc)
        {
            sc->offset = newsc->offset;
            newsc->pop();
        }
    }
}
开发者ID:Safety0ff,项目名称:dmd,代码行数:38,代码来源:attrib.c


注:本文中的Expressions类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。