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


C++ Expression::Accept方法代码示例

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


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

示例1: Visit

void TypeDeduction::Visit(ConditionalExpression* node)
{
    std::map<Expression *, Expression *> *condBranches = node->GetConditionalBranches();
    for (std::map<Expression *, Expression *>::iterator it = condBranches->begin(); it != condBranches->end(); ++it)
    {
        Expression *condition = it->first;
        Expression *condExpr = it->second;
        condition->Accept(this);
        condExpr->Accept(this);
        Type *conditionType = condition->GetTag<Type>("Type");
        if (!conditionType->CanImplicitlyConvertTo(new BooleanType()))
        {
            CompilationContext::GetInstance()->ReportError(node->SourceLocation, false, "Boolean expression expected.");
        }
    }
    node->GetDefaultBranch()->Accept(this);

    Type *defType = node->GetDefaultBranch()->GetTag<Type>("Type");
    for (std::map<Expression *, Expression *>::iterator it = condBranches->begin(); it != condBranches->end(); ++it)
    {
        Expression *condition = it->first;
        Expression *condExpr = it->second;
        Type *exprType = condExpr->GetTag<Type>("Type");
        if (!defType->Equals(exprType))
        {
            node->SetTag<Type>("Type", new VoidType());
            return;
        }
    }
    node->SetTag<Type>("Type", defType);
}
开发者ID:layerzero,项目名称:cc0,代码行数:31,代码来源:TypeDeduction.cpp

示例2: Do

    void MacroExpChecker::Do(const Expression& Exp, 
                             const vector<const ESFixedTypeBase*>& DomainTypes,
                             const ESFixedTypeBase* RangeType, 
                             vector<Expression>& FormalParamExps)
    {
        if (Exp->GetType() != RangeType) {
            throw TypeException((string)"Macro Expression has mismatched type");
        }

        MacroExpChecker Checker;
        Exp->Accept(&Checker);
        
        // Check if the formal param expressions obtained have the same type as expected
        // Also, ALL formal params MUST be used
        for (uint32 i = 0; i < DomainTypes.size(); ++i) {
            auto it = Checker.FormalParamExpressions.find(i);
            if (it == Checker.FormalParamExpressions.end()) {
                throw TypeException((string)"Formal parameter " + to_string(i) + " unused in macro. " + 
                                    "Please eliminate unused parameters from macro definitions.");
            }
            if (it->second->GetType() != DomainTypes[i]) {
                throw TypeException((string)"Formal parameter type mismatch at position " + to_string(i) + 
                                    " in macro definition");
            }
            FormalParamExps.push_back(it->second);
        }
    }
开发者ID:CharudattaSChitale,项目名称:sygus-comp14,代码行数:27,代码来源:ExpCheckers.cpp

示例3: Do

    Expression SpecRewriter::Do(ESolver* Solver, const Expression& Exp,
                                vector<EvalRule>& EvalRules,
                                vector<const AuxVarOperator*>& BaseAuxVarsOps,
                                vector<const AuxVarOperator*>& DerivedAuxVarOps)
    {
        SpecRewriter Rewriter(Solver);
        Exp->Accept(&Rewriter);
        EvalRules = Rewriter.EvalRules;
        BaseAuxVarsOps = Rewriter.BaseAuxVarOps;
        DerivedAuxVarOps = Rewriter.DerivedAuxVarOps;

        // Assign positions for base and derived aux vars
        uint32 AuxVarCounter = 0;
        for (auto const& BaseAV : BaseAuxVarsOps) {
            BaseAV->SetPosition(AuxVarCounter++);
        }
        for (auto const& DerivedAV : DerivedAuxVarOps) {
            DerivedAV->SetPosition(AuxVarCounter++);
        }

        // Fixup the param maps in the eval rules
        for (auto const& Rule : EvalRules) {
            ParamMapFixup::Do(Rule.GetRHS());
        }
        
        return Rewriter.RewriteStack.back();
    }
开发者ID:LaserPope,项目名称:sygus-comp14,代码行数:27,代码来源:SpecRewriter.cpp


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