本文整理汇总了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);
}
示例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);
}
}
示例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();
}