Commit beea3ed5 authored by Roberto Raggi's avatar Roberto Raggi
Browse files

Check for undefined types.

parent 6cb72f06
......@@ -514,7 +514,7 @@ bool Semantic::visit(BasicTypeAST *ast)
break;
default:
qDebug() << "unknown type:" << GLSLParserTable::spell[ast->token];
_engine->error(ast->lineno, QString("Unknown type `%1'").arg(QLatin1String(GLSLParserTable::spell[ast->token])));
}
return false;
......@@ -522,7 +522,17 @@ bool Semantic::visit(BasicTypeAST *ast)
bool Semantic::visit(NamedTypeAST *ast)
{
Q_UNUSED(ast);
if (ast->name) {
if (Symbol *s = _scope->lookup(*ast->name)) {
if (Struct *ty = s->asStruct()) {
_expr.type = ty;
_expr.isConstant = false;
return false;
}
}
_engine->error(ast->lineno, QString("Undefined type `%1'").arg(*ast->name));
}
return false;
}
......@@ -539,6 +549,8 @@ bool Semantic::visit(StructTypeAST *ast)
Struct *s = _engine->newStruct(_scope);
if (ast->name)
s->setName(*ast->name);
if (Scope *e = s->scope())
e->add(s);
Scope *previousScope = switchScope(s);
for (List<StructTypeAST::Field *> *it = ast->fields; it; it = it->next) {
StructTypeAST::Field *f = it->value;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment