本文整理汇总了C++中parseType函数的典型用法代码示例。如果您正苦于以下问题:C++ parseType函数的具体用法?C++ parseType怎么用?C++ parseType使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了parseType函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseMangledName
/*
<mangled_name> ::= _Z <name> [<type> (if template params > 0)] <type>+
*/
static int parseMangledName(LargeStaticString &src, LargeStaticString &dest, demangle_t &data)
{
START("MangledName");
// Does the string begin with _Z?
if (src[0] != '_' || src[1] != 'Z')
END_FAIL("MangledName");
src.stripFirst(2);
if (parseName(src, dest, data) == FAIL)
END_FAIL("MangledName");
// HACK:: Bit of a hack here - we add the entire function name (foo::bar) to the substitution index,
// when it shouldn't be. Here we decrement the number of substitutions so it is wiped.
if (data.nSubstitutions)
data.nSubstitutions --;
// HACK:: OK here we go, hack again. We manually increase the data.nNameParseLevel member so
// that our template parameters don't get accidentally overwritten.
data.nNameParseLevel = 5;
// If we have some template params we should expect a type next (for return type).
LargeStaticString tmp; // Just completely ignore the return type.
if (data.nTemplateParams > 0)
if (parseType(src, tmp, data) == FAIL)
END_FAIL("MangledName");
data.nParams = 0;
do
{
if (parseType(src, data.params[data.nParams], data) == FAIL)
END_FAIL("MangledName");
data.nParams++;
} while (src.length() > 0);
END_SUCCESS("MangledName");
}
示例2: parseFunctionType
TestFunctionType parseFunctionType() {
const auto returnType = parseType();
assert(stream_.peek() == '(');
stream_.consume();
llvm::SmallVector<Type, 8> argumentTypes;
while (stream_.peek() != ')' && stream_.peek() != '.') {
argumentTypes.push_back(parseType());
assert(stream_.peek() == ',' || stream_.peek() == ')');
if (stream_.peek() == ',') {
stream_.consume();
}
}
llvm::SmallVector<Type, 8> varArgsTypes;
const bool isVarArg = (stream_.peek() == '.');
if (isVarArg) {
varArgsTypes = parseVarArgsTypes();
}
assert(stream_.peek() == ')');
stream_.consume();
return TestFunctionType(FunctionType(returnType,
argumentTypes,
isVarArg),
varArgsTypes);
}
示例3: parseFunctionType
/*
<function_type> ::= F [Y] <type> <type>+ E
*/
static int parseFunctionType(LargeStaticString &src, LargeStaticString &dest, demangle_t &data)
{
START("FunctionType");
// Should start with an 'F'.
if (src[0] != 'F')
END_FAIL("FunctionType");
src.stripFirst(1);
// Do we have a 'Y'?
if (src[0] == 'Y')
src.stripFirst(1); // Ignore it.
// Return type.
if (parseType(src, dest, data) == FAIL)
END_FAIL("FunctionType");
dest += " ()(";
bool bIsFirst = true;
do
{
if (bIsFirst)
bIsFirst = false;
else
dest += ", ";
if (parseType(src, dest, data) == FAIL)
END_FAIL("FunctionType");
} while (src[0] != 'E');
dest += ")";
src.stripFirst(1);
END_SUCCESS("FunctionType");
}
示例4: parseType
// like parseFunction, but never aborts with an error
bool Moc::parseMaybeFunction(FunctionDef *def)
{
def->type = parseType();
if (def->type.name.isEmpty())
return false;
bool scopedFunctionName = false;
if (test(LPAREN)) {
def->name = def->type.name;
scopedFunctionName = def->type.isScoped;
def->type = Type("int");
} else {
Type tempType = parseType();;
while (!tempType.name.isEmpty() && lookup() != LPAREN) {
if (def->type.name == "QT_MOC_COMPAT" || def->type.name == "QT3_SUPPORT")
def->isCompat = true;
else if (def->type.name == "Q_INVOKABLE")
def->isInvokable = true;
else if (def->type.name == "Q_SCRIPTABLE")
def->isInvokable = def->isScriptable = true;
else if (def->type.name == "Q_SIGNAL")
def->isSignal = true;
else if (def->type.name == "Q_SLOT")
def->isSlot = true;
else {
if (!def->tag.isEmpty())
def->tag += ' ';
def->tag += def->type.name;
}
def->type = tempType;
tempType = parseType();
}
if (!test(LPAREN))
return false;
def->name = tempType.name;
scopedFunctionName = tempType.isScoped;
}
// we don't support references as return types, it's too dangerous
if (def->type.referenceType == Type::Reference)
def->type = Type("void");
def->normalizedType = normalizeType(def->type.name);
if (!test(RPAREN)) {
parseFunctionArguments(def);
if (!test(RPAREN))
return false;
}
def->isConst = test(CONST);
if (scopedFunctionName
&& (def->isSignal || def->isSlot || def->isInvokable)) {
QByteArray msg("parsemaybe: Function declaration ");
msg += def->name;
msg += " contains extra qualification. Ignoring as signal or slot.";
warning(msg.constData());
return false;
}
return true;
}
示例5: parseFuncParams
static PSmmAstNode parseFuncParams(PSmmParser parser, PSmmAstParamNode firstParam) {
assert(firstParam != NULL);
assert(parser->curToken->kind == ':');
getNextToken(parser); //skip ':'
PSmmTypeInfo typeInfo = parseType(parser);
if (typeInfo->kind == tiSmmUnknown && !findEitherToken(parser, ',', ')')) return &errorNode;
int paramCount = 1;
firstParam->kind = nkSmmParamDefinition;
firstParam->type = typeInfo;
firstParam->isIdent = true;
firstParam->level = parser->curScope->level + 1;
ibsDictPush(parser->idents, firstParam->token->repr, firstParam);
PSmmAstParamNode param = firstParam;
while (parser->curToken->kind == ',') {
getNextToken(parser);
PSmmToken paramName = expect(parser, tkSmmIdent);
if (!paramName) {
findEitherToken(parser, ',', ')');
continue;
}
if (!expect(parser, ':')) {
findEitherToken(parser, ',', ')');
continue;
}
PSmmTypeInfo paramTypeInfo = parseType(parser);
if (paramTypeInfo->kind == tiSmmUnknown) {
findEitherToken(parser, ',', ')');
}
PSmmAstParamNode newParam = ibsDictGet(parser->idents, paramName->repr);
if (newParam) {
if (newParam->level == parser->curScope->level + 1) {
smmPostMessage(parser->msgs, errSmmRedefinition, paramName->filePos, paramName->repr);
continue;
} else if (!newParam->isIdent) {
const char* tokenStr = nodeKindToString[newParam->kind];
smmPostMessage(parser->msgs, errSmmIdentTaken, paramName->filePos, paramName->repr, tokenStr);
continue;
}
}
paramCount++;
newParam = smmNewAstNode(nkSmmParam, parser->a);
newParam->isIdent = true;
newParam->level = parser->curScope->level + 1;
newParam->token = paramName;
newParam->type = paramTypeInfo;
ibsDictPush(parser->idents, paramName->repr, newParam);
param->next = newParam;
param = newParam;
}
firstParam->count = paramCount;
return (PSmmAstNode)firstParam;
}
示例6: parseInherit
static void parseInherit (tokenInfo *const token)
{
Assert (isKeyword (token, KEYWORD_inherit));
#ifdef TYPE_REFERENCE_TOOL
readToken (token);
while (isType (token, TOKEN_IDENTIFIER))
{
parseType (token);
if (isType (token, TOKEN_KEYWORD))
{
switch (token->keyword) /* check for feature adaptation */
{
case KEYWORD_rename:
case KEYWORD_export:
case KEYWORD_undefine:
case KEYWORD_redefine:
case KEYWORD_select:
findKeyword (token, KEYWORD_end);
readToken (token);
default:
break;
}
}
}
#else
readToken (token);
while (isType (token, TOKEN_IDENTIFIER))
{
parseType (token);
switch (token->keyword) /* check for feature adaptation */
{
case KEYWORD_rename:
parseRename (token);
if (isKeyword (token, KEYWORD_end))
readToken (token);
break;
case KEYWORD_export:
case KEYWORD_undefine:
case KEYWORD_redefine:
case KEYWORD_select:
findKeyword (token, KEYWORD_end);
readToken (token);
break;
case KEYWORD_end:
readToken (token);
break;
default:
break;
}
}
#endif
}
示例7: parseType
void esvg::Dimension::set(std::string _configX, std::string _configY) {
m_data.setValue(0,0);
m_type = esvg::distance_pixel;
enum distance type = esvg::distance_pixel;
// First Parse X
enum distance typeX = parseType(_configX);
float valueX = etk::string_to_float(_configX);
// Second Parse Y
enum distance typeY = parseType(_configY);
float valueY = etk::string_to_float(_configY);
// TODO : Check difference ...
set(vec2(valueX, valueY), typeX);
ESVG_VERBOSE(" config dimention : '" << _configX << "' '" << _configY << "' == > " << *this );
}
示例8: parseGeneric
static void parseGeneric (tokenInfo *const token, boolean declaration __unused__)
{
unsigned int depth = 0;
#ifdef TYPE_REFERENCE_TOOL
boolean constraint = FALSE;
#endif
Assert (isType (token, TOKEN_OPEN_BRACKET));
do
{
if (isType (token, TOKEN_OPEN_BRACKET))
{
++depth;
readToken (token);
}
else if (isType (token, TOKEN_CLOSE_BRACKET))
{
--depth;
readToken (token);
}
#ifdef TYPE_REFERENCE_TOOL
else if (declaration)
{
boolean advanced = FALSE;
if (depth == 1)
{
if (isType (token, TOKEN_CONSTRAINT))
constraint = TRUE;
else if (isKeyword (token, KEYWORD_create))
findKeyword (token, KEYWORD_end);
else if (isType (token, TOKEN_IDENTIFIER))
{
if (constraint)
advanced = parseType (token);
else
addGenericName (token);
constraint = FALSE;
}
}
else if (isType (token, TOKEN_IDENTIFIER))
advanced = parseType (token);
if (! advanced)
readToken (token);
}
#endif
else
parseType (token);
} while (depth > 0 && ! isType (token, TOKEN_EOF));
}
示例9: syntaxError
PARSENODE_PTR SQLParser::parseCreate() {
if (!startsCreate(nowReading)) {
syntaxError(nowReading, "expect create!");
return nullptr;
}
//LOG_TRACE(logger, "parse create statement.");
PARSENODE_PTR createNode = PARSENODE_PTR(new ParseNode(CREATE));
readToken();
if (nowReading == TABLE) {
createNode->children.emplace_back(new ParseNode(TABLE));
readToken();
createNode->children.push_back(parseIdentifier());
expect(LEFT_BRACE);
while (startsIdentifier(nowReading)) {
PARSENODE_PTR id = parseIdentifier();
//LOG_TRACE(logger, "parse id %s.", ((IdentifierNode*)id.get())->id_.c_str());
PARSENODE_PTR type = parseType();
if (nowReading == UNIQUE) {
readToken();
id->children.emplace_back(new ParseNode(UNIQUE));
}
expect(SLICE);
id->children.push_back(type);
createNode->children.push_back(id);
}
expect(PRIMARY);
expect(KEY);
expect(LEFT_BRACE);
createNode->children.push_back(parseIdentifier());
expect(RIGHT_BRACE);
expect(RIGHT_BRACE);
}
else if (nowReading == INDEX) {
createNode->children.emplace_back(new ParseNode(INDEX));
readToken();
PARSENODE_PTR indexNode = parseIdentifier();
createNode->children.push_back(indexNode);
expect(ON);
PARSENODE_PTR tableNode = parseIdentifier();
createNode->children.push_back(tableNode);
expect(LEFT_BRACE);
PARSENODE_PTR columnNode = parseIdentifier();
createNode->children.push_back(columnNode);
expect(RIGHT_BRACE);
}
else {
syntaxError(nowReading, "expect table or index!");
return nullptr;
}
expect(TERMINATOR);
return createNode;
}
示例10: parseElementDescr
/* parses a PLY element description */
void parseElementDescr(std::stringstream& cin, std::list<std::string>& header)
{
Element elt;
std::string name; cin >> name;
size_t num; cin >> num;
mesh.order.push_back(name);
elt.name = name;
elt.size = num;
/* parse all properties */
while (!header.empty())
{
std::stringstream line(header.front());
std::string tag; line >> tag;
if (tag != "property") break;
header.pop_front();
Type ty = parseType(line);
std::string name; line >> name;
elt.type[name] = ty;
elt.properties.push_back(name);
}
mesh.elements[name] = elt;
}
示例11: getHLSL
void VertexShader::parseAttributes()
{
const char *hlsl = getHLSL();
if (hlsl)
{
const char *input = strstr(hlsl, "// Attributes") + 14;
while(true)
{
char attributeType[256];
char attributeName[256];
int matches = sscanf(input, "static %255s _%255s", attributeType, attributeName);
if (matches != 2)
{
break;
}
mAttributes.push_back(Attribute(parseType(attributeType), attributeName));
input = strstr(input, ";") + 2;
}
}
}
示例12: parseGenericParameters
void parseGenericParameters(Generic<T> *generic, const TypeContext &typeContext) {
while (stream_.consumeTokenIf(E_SPIRAL_SHELL)) {
auto &variable = stream_.consumeToken(TokenType::Variable);
auto constraint = parseType(typeContext, TypeDynamism::GenericTypeVariables);
generic->addGenericArgument(variable.value(), constraint, variable.position());
}
}
示例13: parseInherit
static void parseInherit (tokenInfo *const token)
{
Assert (isKeyword (token, KEYWORD_inherit));
readToken (token);
while (isType (token, TOKEN_IDENTIFIER))
{
parseType (token);
if (isType (token, TOKEN_KEYWORD))
{
switch (token->keyword) /* check for feature adaptation */
{
case KEYWORD_rename:
parseRename (token);
case KEYWORD_export:
case KEYWORD_undefine:
case KEYWORD_redefine:
case KEYWORD_select:
if (findKeyword (token, KEYWORD_end))
readToken (token);
break;
case KEYWORD_end:
readToken (token);
break;
default: break;
}
}
if (isType (token, TOKEN_SEMICOLON))
readToken (token);
}
}
示例14: parseVarArgsTypes
llvm::SmallVector<Type, 8> parseVarArgsTypes() {
assert(stream_.peek() == '.');
stream_.consume();
assert(stream_.peek() == '.');
stream_.consume();
assert(stream_.peek() == '.');
stream_.consume();
assert(stream_.peek() == '(');
stream_.consume();
llvm::SmallVector<Type, 8> varArgsTypes;
while (stream_.peek() != ')') {
varArgsTypes.push_back(parseType());
assert(stream_.peek() == ',' || stream_.peek() == ')');
if (stream_.peek() == ',') {
stream_.consume();
}
}
assert(stream_.peek() == ')');
stream_.consume();
return varArgsTypes;
}
示例15: parseIdentifierList
DeclarationsPtr Parser::parseArgumentList()
{
IdentifiersPtr identifiers = parseIdentifierList();
if (m_errorCode > ErrorCodes::NoError) {
return DeclarationsPtr();
}
if (!match(TokenType::Colon)) {
reportError(ErrorCodes::ExpectedColon);
return DeclarationsPtr();
}
TypePtr type = parseType();
if (m_errorCode > ErrorCodes::NoError) {
return DeclarationsPtr();
}
DeclarationsPtr declarations(new Declarations);
for (std::vector<IdentifierPtr>::const_iterator i = identifiers->list.begin(); i != identifiers->list.end(); ++i) {
DeclarationPtr declaration(new Declaration);
declaration->id = *i;
declaration->type = type;
declarations->list.push_back(declaration);
}
DeclarationsPtr rest = parseArgumentList_r();
if (rest) {
declarations->list.insert(declarations->list.end(), rest->list.begin(), rest->list.end());
}
return declarations;
}