本文整理汇总了C++中AType::isScalar方法的典型用法代码示例。如果您正苦于以下问题:C++ AType::isScalar方法的具体用法?C++ AType::isScalar怎么用?C++ AType::isScalar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AType
的用法示例。
在下文中一共展示了AType::isScalar方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: genericRelational
void TypeAnalysis::genericRelational(CallInst * ci) {
AType * lhs = state.get(ci->getOperand(0));
AType * rhs = state.get(ci->getOperand(1));
if (lhs->isScalar() and rhs->isScalar()) {
state.update(ci,
new AType(AType::Kind::R,
AType::Kind::DV,
AType::Kind::D));
} else {
state.update(ci, new AType(AType::Kind::R, AType::Kind::DV));
}
}
示例2: genericGetElement
void TypeAnalysis::genericGetElement(CallInst * ci) {
AType * from = state.get(ci->getOperand(0));
AType * index = state.get(ci->getOperand(1));
if (from->isDouble()) {
if (index->isScalar()) {
state.update(ci,
new AType(AType::Kind::R,
AType::Kind::DV,
AType::Kind::D));
} else {
state.update(ci, new AType(AType::Kind::R, AType::Kind::DV));
}
} else if (from->isCharacter()) {
state.update(ci, new AType(AType::Kind::R, AType::Kind::CV));
} else {
state.update(ci, new AType(AType::Kind::T));
}
}
示例3: Environment
/** Checks that a dot operator result type is correctly set to be double scalar by the type analysis. */
void project4() {
char const * source = "function(a, b) { a %*% b }";
try {
Environment * env = new Environment(nullptr);
RVal * actual = eval(env, source);
llvm::Function * f = actual->f->bitcode;
// run type analysis on the function
//auto pm = llvm::legacy::FunctionPassManager(f->getParent());
TypeAnalysis ta;
ta.runOnFunction(*f);
// check the type of the genericDot intrinsic call
for (auto & b : *f) {
for (auto & i : b) {
if (llvm::CallInst * ci = llvm::dyn_cast<llvm::CallInst>(&i)) {
llvm::StringRef s = ci->getCalledFunction()->getName();
if (s == "genericDot") {
AType * t = ta.state.get(ci);
if (t->kind != AType::Kind::R or not t->isScalar())
throw "Generic dot does not have correct type";
if (ta.state.getLocation(t) != ci)
throw "Location attached to the generic dot type is invalid";
t = t->payload;
if (ta.state.getLocation(t) != nullptr)
throw "Generic dot payload cannot have location";
t = t->payload;
if (ta.state.getLocation(t) != nullptr)
throw "Generic dot payload cannot have location";
return;
}
}
}
}
throw "Generic dot not found";
} catch (char const * e) {
cout << "ERROR at line " << __LINE__ << " : " << e << endl;
cout << source << endl << endl;
} catch (...) {
cout << "ERROR at line " << __LINE__ << " : " << endl;
cout << source << endl << endl;
}
}