From d1df8b82b84e6e21aa9686435a58de320d53d7d8 Mon Sep 17 00:00:00 2001 From: rschoene <rene.schoene@tu-dresden.de> Date: Thu, 9 Feb 2023 16:38:23 +0100 Subject: [PATCH] Change component resolving for inherited children of type-decls. - use equals to compare entry in RagConnectObserver - use type-components computed by NTA ("as owned by me") consistently --- pages/docs/compiler.md | 5 +++-- ragconnect.base/src/main/jastadd/Intermediate.jadd | 4 ++-- ragconnect.base/src/main/jastadd/NameResolution.jrag | 9 +++++---- .../src/main/resources/RagConnectObserver.mustache | 4 ++-- ragconnect.base/src/main/resources/ragconnect.mustache | 1 + 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/pages/docs/compiler.md b/pages/docs/compiler.md index 130020a..ccff6d6 100644 --- a/pages/docs/compiler.md +++ b/pages/docs/compiler.md @@ -75,8 +75,9 @@ However, depending on the selected protocols and/or used features, additional de - Required runtime dependencies: _none_ - Required options for RelAST compiler: _none_ - Required options for JastAdd: - - `--incremental` - - `--tracing=flush` + - `--incremental=param` (enable incremental evaluation) + - `--tracing=flush` (enable tracing of events) + - `--cache=all` (set all attributes to be cached) - Remarks: - Other (additional) values passed to those two options must be equal (e.g., `--incremental=param` passed to RagConnect must be also passed to JastAdd) - Other values besides `flush` can be added to `--tracing` diff --git a/ragconnect.base/src/main/jastadd/Intermediate.jadd b/ragconnect.base/src/main/jastadd/Intermediate.jadd index 97cc514..b847dc7 100644 --- a/ragconnect.base/src/main/jastadd/Intermediate.jadd +++ b/ragconnect.base/src/main/jastadd/Intermediate.jadd @@ -398,7 +398,7 @@ aspect MustacheReceiveAndSendAndHandleUri { syn String PortDefinition.connectParameterName() = "uriString"; syn String PortDefinition.disconnectMethodName() { - // if both (send and receive) are defined for an port, ensure methods with different names + // if both (send and receive) are defined for a port, ensure methods with different names String extra; if (getPortTarget().isTokenPortTarget()) { extra = lookupTokenPortDefinitions(token()).size() > 1 ? uniqueSuffix() : ""; @@ -681,7 +681,7 @@ aspect MustacheTypeDecl { syn List<TypeComponent> TypeDecl.occurencesInProductionRules() { List<TypeComponent> result = new ArrayList<>(); for (TypeDecl typeDecl : program().typeDecls()) { - for (Component comp : typeDecl.getComponentList()) { + for (Component comp : typeDecl.allComponentsAsOwnedByMe()) { if (comp.isTypeComponent() && comp.asTypeComponent().getTypeDecl().equals(this)) { result.add(comp.asTypeComponent()); } diff --git a/ragconnect.base/src/main/jastadd/NameResolution.jrag b/ragconnect.base/src/main/jastadd/NameResolution.jrag index 6e7c745..eb589e1 100644 --- a/ragconnect.base/src/main/jastadd/NameResolution.jrag +++ b/ragconnect.base/src/main/jastadd/NameResolution.jrag @@ -27,7 +27,7 @@ aspect RagConnectNameResolution { java.util.List<PortDefinition> result = new java.util.ArrayList<>(); for (PortDefinition def : onlyGiven ? givenPortDefinitionList() : allPortDefinitionList()) { PortTarget target = def.getPortTarget(); - if (target.isTypePortTarget() && target.asTypePortTarget().getType().equals(type)) { + if (target.isTypePortTarget() && target.asTypePortTarget().getType().matches(type) && target.asTypePortTarget().getType().containingTypeDecl().equals(type.containingTypeDecl())) { result.add(def); } } @@ -216,9 +216,7 @@ aspect RelastNameResolution { if (!other.isTokenComponent()) { return false; } return getName().equals(other.getName()) && getJavaTypeUse().prettyPrint().equals(other.asTokenComponent().getJavaTypeUse().prettyPrint()); } - eq TypeComponent.matches(Component other) { - return getName().equals(other.getName()) && getTypeDecl().equals(other.asTypeComponent().getTypeDecl()); - } + eq TypeComponent.matches(Component other) = matchesNameAndType(other); eq NormalComponent.matches(Component other) { if (!other.isTypeComponent() || !other.asTypeComponent().isNormalComponent()) { return false; } return super.matches(other); @@ -231,4 +229,7 @@ aspect RelastNameResolution { if (!other.isTypeComponent() || !other.asTypeComponent().isOptComponent()) { return false; } return super.matches(other); } + syn boolean TypeComponent.matchesNameAndType(Component other) { + return getName().equals(other.getName()) && getTypeDecl().equals(other.asTypeComponent().getTypeDecl()); + } } diff --git a/ragconnect.base/src/main/resources/RagConnectObserver.mustache b/ragconnect.base/src/main/resources/RagConnectObserver.mustache index 24ed61c..67ba811 100644 --- a/ragconnect.base/src/main/resources/RagConnectObserver.mustache +++ b/ragconnect.base/src/main/resources/RagConnectObserver.mustache @@ -119,8 +119,8 @@ aspect RagConnectObserver { } RagConnectObserverStartEntry startEntry = startEntries.peekFirst(); if (node == startEntry.node && - attribute == startEntry.attributeString && - value == startEntry.flushIncToken) { + attribute.equals(startEntry.attributeString) && + value.equals(startEntry.flushIncToken)) { // create a copy of the queue to avoid entering this again causing an endless recursion RagConnectObserverEntry[] entriesToProcess = entryQueue.toArray(new RagConnectObserverEntry[entryQueue.size()]); entryQueue.clear(); diff --git a/ragconnect.base/src/main/resources/ragconnect.mustache b/ragconnect.base/src/main/resources/ragconnect.mustache index 5bd0166..a38ac9b 100644 --- a/ragconnect.base/src/main/resources/ragconnect.mustache +++ b/ragconnect.base/src/main/resources/ragconnect.mustache @@ -91,6 +91,7 @@ aspect RagConnect { mayHaveRewrite(); // check if --incremental is active Object checkIncremental = inc_throwAway_visited; + {{! TODO maybe check for something like _ragconnect_mqttHandler_computed to see if --cache=all }} {{/configIncrementalOptionActive}} } } -- GitLab