var.type_declaration = i->second;
}
+void TypeResolver::visit(FunctionDeclaration &func)
+{
+ map<string, TypeDeclaration *>::iterator i = stage->types.find(func.return_type);
+ func.return_type_declaration = (i!=stage->types.end() ? i->second : 0);
+ TraversingVisitor::visit(func);
+}
+
VariableResolver::VariableResolver():
stage(0),
virtual void visit(ImageTypeDeclaration &);
virtual void visit(StructDeclaration &);
virtual void visit(VariableDeclaration &);
+ virtual void visit(FunctionDeclaration &);
};
/** Resolves variable references. Variable references which match the name
FunctionDeclaration::FunctionDeclaration():
- definition(0)
+ definition(0),
+ return_type_declaration(0)
{ }
FunctionDeclaration::FunctionDeclaration(const FunctionDeclaration &other):
name(other.name),
parameters(other.parameters),
body(other.body),
- definition(other.definition==&other ? this : 0)
+ definition(other.definition==&other ? this : 0),
+ return_type_declaration(0)
{ }
void FunctionDeclaration::visit(NodeVisitor &visitor)
Block body;
FunctionDeclaration *definition;
+ TypeDeclaration *return_type_declaration;
FunctionDeclaration();
FunctionDeclaration(const FunctionDeclaration &);
TraversingVisitor::visit(var);
}
+void ReferenceValidator::visit(FunctionDeclaration &func)
+{
+ if(!func.return_type_declaration)
+ error(func, format("Use of undeclared type '%s'", func.return_type));
+ TraversingVisitor::visit(func);
+}
+
} // namespace SL
} // namespace GL
} // namespace Msp
virtual void visit(VariableReference &);
virtual void visit(InterfaceBlockReference &);
virtual void visit(VariableDeclaration &);
+ virtual void visit(FunctionDeclaration &);
};
} // namespace SL