本文整理汇总了C++中FormatToken::SizeOf方法的典型用法代码示例。如果您正苦于以下问题:C++ FormatToken::SizeOf方法的具体用法?C++ FormatToken::SizeOf怎么用?C++ FormatToken::SizeOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormatToken
的用法示例。
在下文中一共展示了FormatToken::SizeOf方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Build
DebugCommand* PrintCommand::Build(std::vector<Token*> args) {
if (args.size() < 2) {
return new InvalidCommand(args, -1, "too few arguments");
}
Token* target = args[1];
if (!target->IsRegister() &&
!target->IsFPRegister() &&
!target->IsIdentifier()) {
return new InvalidCommand(args, 1, "expects reg or identifier");
}
FormatToken* format = NULL;
int target_size = 0;
if (target->IsRegister()) {
Register reg = RegisterToken::Cast(target)->value();
target_size = reg.SizeInBytes();
} else if (target->IsFPRegister()) {
FPRegister fpreg = FPRegisterToken::Cast(target)->value();
target_size = fpreg.SizeInBytes();
}
// If the target is an identifier there must be no format. This is checked
// in the switch statement below.
switch (args.size()) {
case 2: {
if (target->IsRegister()) {
switch (target_size) {
case 4: format = new Format<uint32_t>("%08" PRIx32, 'x'); break;
case 8: format = new Format<uint64_t>("%016" PRIx64, 'x'); break;
default: VIXL_UNREACHABLE();
}
} else if (target->IsFPRegister()) {
switch (target_size) {
case 4: format = new Format<float>("%8g", 'f'); break;
case 8: format = new Format<double>("%8g", 'f'); break;
default: VIXL_UNREACHABLE();
}
}
break;
}
case 3: {
if (target->IsIdentifier()) {
return new InvalidCommand(args, 2,
"format is only allowed with registers");
}
Token* second = args[2];
if (!second->IsFormat()) {
return new InvalidCommand(args, 2, "expects format");
}
format = FormatToken::Cast(second);
if (format->SizeOf() > target_size) {
return new InvalidCommand(args, 2, "format too wide");
}
break;
}
default:
return new InvalidCommand(args, -1, "too many arguments");
}
return new PrintCommand(args[0], target, format);
}