From 17b6b904e8d1c7dcf3d5241d68f1ffec4bd63da9 Mon Sep 17 00:00:00 2001 From: hneemann Date: Thu, 7 Jan 2021 11:27:35 +0100 Subject: [PATCH] removes genericCode from generated concrete circuits --- .../digital/core/element/ElementAttributes.java | 12 ++++++++++++ .../digital/draw/library/ResolveGenerics.java | 6 ++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/neemann/digital/core/element/ElementAttributes.java b/src/main/java/de/neemann/digital/core/element/ElementAttributes.java index 691045a30..b6d36b485 100644 --- a/src/main/java/de/neemann/digital/core/element/ElementAttributes.java +++ b/src/main/java/de/neemann/digital/core/element/ElementAttributes.java @@ -318,4 +318,16 @@ public class ElementAttributes implements HGSMap { return null; return cache.get(key); } + + /** + * Removes an entry from the cache. + * + * @param key the key to remove + * @return the previous value associated with key, or null if there was no mapping for key. + */ + public Object removeFromCache(String key) { + if (cache == null) + return null; + return cache.remove(key); + } } diff --git a/src/main/java/de/neemann/digital/draw/library/ResolveGenerics.java b/src/main/java/de/neemann/digital/draw/library/ResolveGenerics.java index 92f577c2d..76ebc7aa7 100644 --- a/src/main/java/de/neemann/digital/draw/library/ResolveGenerics.java +++ b/src/main/java/de/neemann/digital/draw/library/ResolveGenerics.java @@ -253,7 +253,9 @@ public class ResolveGenerics { * @return this for chained calls */ public CircuitHolder cleanupConcreteCircuit() { - for (VisualElement gic : circuit.getElements(v -> v.equalsDescription(GenericInitCode.DESCRIPTION))) + for (VisualElement gic : circuit.getElements(v -> + v.equalsDescription(GenericInitCode.DESCRIPTION) + || v.equalsDescription(GenericCode.DESCRIPTION))) circuit.delete(gic); for (VisualElement v : circuit.getElements()) { try { @@ -266,7 +268,7 @@ public class ResolveGenerics { // can not happen e.printStackTrace(); } - v.getElementAttributes().putToCache(GEN_ARGS_KEY, null); + v.getElementAttributes().removeFromCache(GEN_ARGS_KEY); } circuit.getAttributes().set(Keys.IS_GENERIC, false);