Updated schema

This commit is contained in:
Borna Rajkovic committed 2022-04-18 11:41:02 +02:00
1 parent bf029929a7
commit 9f1714d844
7 files changed
+38 -35

No files matched your search

+12 -12
View File
@@ -728,28 +728,28 @@ std::optional<Condition> SchemaCreator::loadCondition(ConditionNode node)
}
std::optional<Schema> SchemaCreator::loadSchema(SchemaNode node, Library &library)
Schema* SchemaCreator::loadSchema(SchemaNode node, Library &library)
{
Schema schema;
Schema *schema = new Schema();
for(auto &instance: node.instances) {
if(library.hasComponent(instance.component.value)) {
schema.instances.push_back(loadComponentInstance(instance, library));
schema->instances.push_back(loadComponentInstance(instance, library));
}
if(library.hasBus(instance.component.value)) {
schema.instances.push_back(loadBusInstance(instance, library));
schema->instances.push_back(loadBusInstance(instance, library));
}
}
for(auto &wire: node.wires) {
auto w = loadWireInstance(wire);
if(w) {
schema.wires.push_back(*w);
schema->wires.push_back(*w);
}
}
for(auto &conn: node.connections) {
auto firstComponent = dynamic_cast<ComponentInstance*>(schema.getInstance(conn.first.instance.value));
auto firstComponent = dynamic_cast<ComponentInstance*>(schema->getInstance(conn.first.instance.value));
if(firstComponent == NULL) {
errors.push_back(SourceError{conn.first.instance.span, "unknown component"});
continue;
@@ -762,7 +762,7 @@ std::optional<Schema> SchemaCreator::loadSchema(SchemaNode node, Library &librar
ComponentInstance *secondComponent = NULL;
if(conn.second.has_value()) {
secondComponent = dynamic_cast<ComponentInstance*>(schema.getInstance(conn.second->instance.value));
secondComponent = dynamic_cast<ComponentInstance*>(schema->getInstance(conn.second->instance.value));
if(secondComponent == NULL) {
errors.push_back(SourceError{conn.second->instance.span, "unknown component"});
continue;
@@ -773,7 +773,7 @@ std::optional<Schema> SchemaCreator::loadSchema(SchemaNode node, Library &librar
}
}
auto bus = dynamic_cast<BusInstance*>(schema.getInstance(conn.bus.value));
auto bus = dynamic_cast<BusInstance*>(schema->getInstance(conn.bus.value));
if(bus == NULL) {
errors.push_back(SourceError{conn.bus.span, "unknown bus"});
continue;
@@ -808,12 +808,12 @@ std::optional<Schema> SchemaCreator::loadSchema(SchemaNode node, Library &librar
errors.push_back(SourceError{conn.span, "missing @wire"});
continue;
}
if(!schema.hasWire(conn.wire->value)) {
if(!schema->hasWire(conn.wire->value)) {
errors.push_back(SourceError{conn.wire->span, "unknown wire"});
continue;
}
auto wire = schema.getWire(conn.wire->value);
auto wire = schema->getWire(conn.wire->value);
std::vector<InstanceAttribute*> attributes;
for(auto& attr: conn.attributes) {
@@ -837,9 +837,9 @@ std::optional<Schema> SchemaCreator::loadSchema(SchemaNode node, Library &librar
}
if(secondComponent == NULL) {
schema.connections.push_back(new BusConnectionInstance(firstComponent, attributes, bus, wire, *connection));
schema->connections.push_back(new BusConnectionInstance(firstComponent, attributes, bus, wire, *connection));
} else {
schema.connections.push_back(new DirectConnectionInstance(firstComponent, secondComponent, attributes, bus, wire, *connection));
schema->connections.push_back(new DirectConnectionInstance(firstComponent, secondComponent, attributes, bus, wire, *connection));
}
}
+1 -1
View File
@@ -138,7 +138,7 @@ public:
std::optional<Library> loadLibrary(LibraryNode node);
std::optional<Schema> loadSchema(SchemaNode node, Library &library);
Schema* loadSchema(SchemaNode node, Library &library);
};
} // namespace domain