本文整理汇总了C++中Argument::type方法的典型用法代码示例。如果您正苦于以下问题:C++ Argument::type方法的具体用法?C++ Argument::type怎么用?C++ Argument::type使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Argument
的用法示例。
在下文中一共展示了Argument::type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
Match
Argument::
isConvertibleTo(const Argument& target) const
{
static const Type* valueType = reflect::type<Value>();
if (*this == target) return Match::Exact;
if ((type() == valueType) ^ (target.type() == valueType))
return Match::Exact;
bool isExact = false;
if (type()->hasConverter(target.type())) {
if (target.refType() != RefType::LValue) return Match::Partial;
return Match::None;
}
if (target.refType() != RefType::Copy) {
if (!testConstConversion(isConst(), target.isConst()))
return Match::None;
}
else isExact = refType() == RefType::RValue;
if (target.refType() == RefType::LValue) {
if (target.isConst()) {}
else if (isConst()) return Match::None;
else if (refType() != RefType::LValue) return Match::None;
}
else if (target.refType() == RefType::RValue) {
if (refType() != RefType::RValue) return Match::None;
}
if (!target.type()->isParentOf(type())) return Match::None;
if (isExact) return Match::Exact;
if (isConst() == target.isConst() && refType() == target.refType())
return Match::Exact;
return Match::Partial;
}
示例2: ArgIndex
int tesla::ArgIndex(const Argument& A) {
switch (A.type()) {
case Argument::Any:
case Argument::Constant:
return -1;
case Argument::Variable:
case Argument::Field:
case Argument::Indirect:
return A.index();
}
}
示例3: BaseName
std::string tesla::BaseName(const Argument& A) {
switch (A.type()) {
case Argument::Any:
case Argument::Constant:
assert(false && "called BaseName() on a non-variable Argument");
case Argument::Variable:
return A.name();
case Argument::Indirect:
return BaseName(A.indirection());
case Argument::Field:
return BaseName(A.field().base());
}
}
示例4: validate_argument
void ArgumentGroup::validate_argument(const Argument & new_argument) const
{
const Option & new_option = new_argument.option();
for(argument_vector_type::const_iterator i = this->_arguments.begin(); i != this->_arguments.end(); ++i)
{
const Argument & old_argument = *i;
const Option & old_option = old_argument.option();
if(new_option.conflicts(old_option))
{
std::ostringstream os;
os << "conflicting options <" << new_option.option_string() << "> and <" << old_option.option_string() << '>';
throw ArgParserError(DEBUG_INFO, os.str());
}
if(new_option.same_dest(old_option))
{
if(new_argument.type() != old_argument.type())
{
std::ostringstream os;
os << "conflicting options <" << new_option.option_string() << "> with type " << Type::label(new_argument.type())
<< " and <" << old_option.option_string() << "> with type " << Type::label(new_argument.type());
throw ArgParserError(DEBUG_INFO, os.str());
}
if(new_argument.multiplicity() != old_argument.multiplicity())
{
std::ostringstream os;
os << "conflicting options <" << new_option.option_string() << "> with multiplicity " << new_argument.multiplicity()
<< " and <" << old_option.option_string() << "> with multiplicity " << old_argument.multiplicity();
throw ArgParserError(DEBUG_INFO, os.str());
}
if(new_argument.default_value() != old_argument.default_value())
{
std::ostringstream os;
os << "conflicting options <" << new_option.option_string() << "> with default_value " << new_argument.default_value()
<< " and <" << old_option.option_string() << "> with default_value " << old_argument.default_value();
throw ArgParserError(DEBUG_INFO, os.str());
}
}
}
}
示例5: iface_impl_scoping
void tst_Lookup::iface_impl_scoping()
{
const QByteArray source = "\n"
"@interface Scooping{}-(int)method1:(int)arg;-(void)method2;@end\n"
"@implementation Scooping-(int)method1:(int)arg{return arg;}@end\n";
Document::Ptr doc = Document::create("class_with_protocol_with_protocol");
doc->setUtf8Source(source);
doc->parse();
doc->check();
QVERIFY(doc->diagnosticMessages().isEmpty());
QCOMPARE(doc->globalSymbolCount(), 2U);
Snapshot snapshot;
snapshot.insert(doc);
ObjCClass *iface = doc->globalSymbolAt(0)->asObjCClass();
QVERIFY(iface);
QVERIFY(iface->isInterface());
ObjCClass *impl = doc->globalSymbolAt(1)->asObjCClass();
QVERIFY(impl);
QVERIFY(!impl->isInterface());
QCOMPARE(iface->memberCount(), 2U);
QCOMPARE(impl->memberCount(), 1U);
ObjCMethod *method1Impl = impl->memberAt(0)->asObjCMethod();
QVERIFY(method1Impl);
QCOMPARE(method1Impl->identifier()->chars(), "method1");
// get the body of method1
QCOMPARE(method1Impl->memberCount(), 2U);
Argument *method1Arg = method1Impl->memberAt(0)->asArgument();
QVERIFY(method1Arg);
QCOMPARE(method1Arg->identifier()->chars(), "arg");
QVERIFY(method1Arg->type()->isIntegerType());
Block *method1Body = method1Impl->memberAt(1)->asBlock();
QVERIFY(method1Body);
const LookupContext context(doc, snapshot);
{ // verify if we can resolve "arg" in the body
QCOMPARE(method1Impl->argumentCount(), 1U);
Argument *arg = method1Impl->argumentAt(0)->asArgument();
QVERIFY(arg);
QVERIFY(arg->name());
QVERIFY(arg->name()->identifier());
QCOMPARE(arg->name()->identifier()->chars(), "arg");
QVERIFY(arg->type()->isIntegerType());
const QList<LookupItem> candidates = context.lookup(arg->name(), method1Body->enclosingScope());
QCOMPARE(candidates.size(), 1);
QVERIFY(candidates.at(0).declaration()->type()->asIntegerType());
}
Declaration *method2 = iface->memberAt(1)->asDeclaration();
QVERIFY(method2);
QCOMPARE(method2->identifier()->chars(), "method2");
{ // verify if we can resolve "method2" in the body
const QList<LookupItem> candidates = context.lookup(method2->name(), method1Body->enclosingScope());
QCOMPARE(candidates.size(), 1);
QCOMPARE(candidates.at(0).declaration(), method2);
}
}