39 using namespace analysis;
42 Program& program = translationUnit.getProgram();
43 ComponentLookupAnalysis& componentLookup = *translationUnit.getAnalysis<ComponentLookupAnalysis>();
44 ErrorReport& report = translationUnit.getErrorReport();
45 checkComponents(report, program, componentLookup);
46 checkComponentNamespaces(report, program);
54 if (!forwarded.
empty()) {
62 report.
addError(
"Referencing undefined component " + name, loc);
71 const SrcLocation& loc,
const TypeBinding& binding) {
73 const Component* c = checkComponentNameReference(
74 report, enclosingComponent, componentLookup,
type.getName(), loc, binding);
80 if (c->getComponentType()->getTypeParameters().size() !=
type.getTypeParameters().size()) {
81 report.
addError(
"Invalid number of type parameters for component " +
type.getName(), loc);
86 const ComponentLookupAnalysis& componentLookup,
const ComponentInit& init,
87 const TypeBinding& binding) {
88 checkComponentReference(
89 report, enclosingComponent, componentLookup, *init.getComponentType(), init.getSrcLoc(), binding);
114 std::vector<QualifiedName> actualParams(parentTypeParameters.size(),
"<type parameter>");
119 checkComponentReference(
120 report, enclosingComponent, componentLookup, *cur, component.
getSrcLoc(), activeBinding);
133 std::set<const Component*> parents;
135 for (
const auto&
base : cur.getBaseComponents()) {
136 auto c = componentLookup.
getComponent(enclosingComponent,
base->getName(), binding);
140 if (parents.insert(c).second) {
145 collectParents(component);
150 report.
addError(
"Override of non-inherited relation " +
151 relation->getQualifiedName().getQualifiers()[0] +
" in component " +
156 for (
const Component* parent : parents) {
157 for (
const Relation*
relation : parent->getRelations()) {
160 report.
addError(
"Override of non-overridable relation " +
161 relation->getQualifiedName().getQualifiers()[0] +
" in component " +
169 if (parents.find(&component) != parents.end()) {
179 checkComponent(report, &component, componentLookup, *cur, activeBinding);
184 checkComponentInit(report, &component, componentLookup, *cur, activeBinding);
189 ErrorReport& report,
const Program& program,
const ComponentLookupAnalysis& componentLookup) {
190 for (Component* cur : program.getComponents()) {
191 checkComponent(report,
nullptr, componentLookup, *cur, TypeBinding());
195 checkComponentInit(report,
nullptr, componentLookup, *cur,
TypeBinding());
201 std::map<std::string, SrcLocation> names;
207 const std::string name =
toString(
type->getQualifiedName());
208 if (names.count(name) == 0u) {
209 names[name] =
type->getSrcLoc();
214 const std::string name =
toString(
rel->getQualifiedName());
215 if (names.count(name) == 0u) {
216 names[name] =
rel->getSrcLoc();
222 const std::string name =
toString(comp->getComponentType()->getName());
223 if (names.count(name) != 0u) {
224 report.
addError(
"Name clash on component " + name, comp->getSrcLoc());
226 names[name] = comp->getSrcLoc();
231 const std::string name =
toString(inst->getInstanceName());
232 if (names.count(name) != 0u) {
233 report.
addError(
"Name clash on instantiation " + name, inst->getSrcLoc());
235 names[name] = inst->getSrcLoc();