Skip to content

Commit

Permalink
Adapt to the new dump format of redeclares (#11567)
Browse files Browse the repository at this point in the history
Improve the handling of final and each
Removed the flag structuredRedeclare
  • Loading branch information
adeas31 committed Nov 13, 2023
1 parent 6dc855b commit 28b394e
Show file tree
Hide file tree
Showing 15 changed files with 369 additions and 227 deletions.
17 changes: 1 addition & 16 deletions OMCompiler/Compiler/Script/NFApi.mo
Expand Up @@ -2098,22 +2098,7 @@ algorithm
json := JSON.addPair("each", JSON.makeBoolean(true), json);
end if;

if Flags.isSet(Flags.STRUCTURED_REDECLARE) then
json := JSON.addPair("$value", dumpJSONSCodeElement(mod.element, scope), json);
else
json := JSON.addPair("redeclare", JSON.makeBoolean(true), json);

if SCodeUtil.isElementReplaceable(mod.element) then
json := JSON.addPair("replaceable", JSON.makeBoolean(true), json);
end if;

binding_json := JSON.makeString(SCodeDump.unparseElementStr(mod.element));
json := JSON.addPair("$value", binding_json, json);

if isChoices then
json := dumpJSONRedeclareType(mod.element, scope, json);
end if;
end if;
json := JSON.addPair("$value", dumpJSONSCodeElement(mod.element, scope), json);
then
();

Expand Down
2 changes: 0 additions & 2 deletions OMCompiler/Compiler/Util/Flags.mo
Expand Up @@ -559,8 +559,6 @@ constant DebugFlag DUMP_EVENTS = DEBUG_FLAG(193, "dumpEvents", false,
Gettext.gettext("Dumps information about the detected event functions."));
constant DebugFlag DUMP_BINDINGS = DEBUG_FLAG(194, "dumpBindings", false,
Gettext.gettext("Dumps information about the equations created from bindings."));
constant DebugFlag STRUCTURED_REDECLARE = DEBUG_FLAG(195, "structuredRedeclare", false,
Gettext.gettext("Dumps redeclares as structures in getModelInstance."));

public
// CONFIGURATION FLAGS
Expand Down
3 changes: 1 addition & 2 deletions OMCompiler/Compiler/Util/FlagsUtil.mo
Expand Up @@ -250,8 +250,7 @@ constant list<Flags.DebugFlag> allDebugFlags = {
Flags.DUMP_SLICE,
Flags.VECTORIZE_BINDINGS,
Flags.DUMP_EVENTS,
Flags.DUMP_BINDINGS,
Flags.STRUCTURED_REDECLARE
Flags.DUMP_BINDINGS
};

protected
Expand Down
13 changes: 8 additions & 5 deletions OMEdit/OMEditLIB/Element/Element.cpp
Expand Up @@ -1844,7 +1844,9 @@ QString Element::getParameterDisplayString(QString parameterName)
/* case 1 */
if (displayString.isEmpty()) {
if (mpGraphicsView->getModelWidget()->isNewApi()) {
displayString = mpModelComponent->getModifier().getModifierValue(QStringList() << parameterName);
if (mpModelComponent->getModifier()) {
displayString = mpModelComponent->getModifier()->getModifierValue(QStringList() << parameterName);
}
} else {
displayString = mpElementInfo->getModifiersMap(pOMCProxy, className, this).value(parameterName, "");
}
Expand Down Expand Up @@ -3568,8 +3570,10 @@ void Element::duplicate()
ModelInstance::Component *pModelInstanceComponent = GraphicsView::createModelInstanceComponent(mpGraphicsView->getModelWidget()->getModelInstance(), name, getClassName());
mpGraphicsView->addElementToView(pModelInstanceComponent, false, true, false, QPointF(0, 0), getOMCPlacementAnnotation(gridStep), false);
// set modifiers
MainWindow::instance()->getOMCProxy()->setElementModifierValue(mpGraphicsView->getModelWidget()->getLibraryTreeItem()->getNameStructure(), name,
mpModelComponent->getModifier().toString());
if (mpModelComponent->getModifier()) {
MainWindow::instance()->getOMCProxy()->setElementModifierValue(mpGraphicsView->getModelWidget()->getLibraryTreeItem()->getNameStructure(), name,
mpModelComponent->getModifier()->toString());
}
} else {
mpElementInfo->getModifiersMap(MainWindow::instance()->getOMCProxy(), mpGraphicsView->getModelWidget()->getLibraryTreeItem()->getNameStructure(), this);
ElementInfo *pElementInfo = new ElementInfo(mpElementInfo);
Expand Down Expand Up @@ -3835,8 +3839,7 @@ void Element::showParameters()
if (MainWindow::instance()->isNewApi()) {
pMainWindow->getProgressBar()->setRange(0, 0);
pMainWindow->showProgressBar();
ElementParameters *pElementParameters = new ElementParameters(mpModelComponent, mpGraphicsView, isInheritedElement(), false, ModelInstance::Modifier(),
ModelInstance::Modifier(), ModelInstance::Modifier(), pMainWindow);
ElementParameters *pElementParameters = new ElementParameters(mpModelComponent, mpGraphicsView, isInheritedElement(), false, 0, 0, 0, pMainWindow);
pMainWindow->hideProgressBar();
pMainWindow->getStatusBar()->clearMessage();
pElementParameters->exec();
Expand Down
165 changes: 95 additions & 70 deletions OMEdit/OMEditLIB/Element/ElementProperties.cpp

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions OMEdit/OMEditLIB/Element/ElementProperties.h
Expand Up @@ -217,23 +217,23 @@ class ElementParameters : public QDialog
{
Q_OBJECT
public:
ElementParameters(ModelInstance::Element *pElement, GraphicsView *pGraphicsView, bool inherited, bool nested, const ModelInstance::Modifier defaultElementModifier,
const ModelInstance::Modifier replaceableConstrainedByModifier, const ModelInstance::Modifier elementModifier, QWidget *pParent = 0);
ElementParameters(ModelInstance::Element *pElement, GraphicsView *pGraphicsView, bool inherited, bool nested, ModelInstance::Modifier *pDefaultElementModifier,
ModelInstance::Modifier *pReplaceableConstrainedByModifier, ModelInstance::Modifier *pElementModifier, QWidget *pParent = 0);
~ElementParameters();
QString getElementParentClassName() const;
GraphicsView *getGraphicsView() const {return mpGraphicsView;}
bool isInherited() const {return mInherited;}
QString getModification() const {return mModification;}
void applyFinalStartFixedAndDisplayUnitModifiers(Parameter *pParameter, const ModelInstance::Modifier &modifier, bool defaultValue, bool isElementModification, bool checkFinal);
void applyFinalStartFixedAndDisplayUnitModifiers(Parameter *pParameter, ModelInstance::Modifier *pModifier, bool defaultValue, bool isElementModification, bool checkFinal);
void updateParameters();
private:
ModelInstance::Element *mpElement;
GraphicsView *mpGraphicsView;
bool mInherited;
bool mNested;
ModelInstance::Modifier mDefaultElementModifier;
ModelInstance::Modifier mReplaceableConstrainedByModifier;
ModelInstance::Modifier mElementModifier;
ModelInstance::Modifier *mpDefaultElementModifier;
ModelInstance::Modifier *mpReplaceableConstrainedByModifier;
ModelInstance::Modifier *mpElementModifier;
QString mModification;
Label *mpParametersHeading;
QFrame *mHorizontalLine;
Expand Down Expand Up @@ -261,7 +261,7 @@ class ElementParameters : public QDialog
void fetchElementExtendsModifiers(ModelInstance::Model *pModelInstance);
void fetchElementModifiers();
void fetchClassExtendsModifiers(ModelInstance::Element *pModelElement);
void applyModifiers(const ModelInstance::Modifier modifiers, bool defaultValue);
void applyModifier(ModelInstance::Modifier *pModifier, bool defaultValue);
Parameter* findParameter(LibraryTreeItem *pLibraryTreeItem, const QString &parameter, Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive) const;
Parameter* findParameter(const QString &parameter, Qt::CaseSensitivity caseSensitivity = Qt::CaseSensitive) const;
public slots:
Expand Down

0 comments on commit 28b394e

Please sign in to comment.