mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-16 00:15:01 -04:00
Fixed a misleading error message.
This commit is contained in:
parent
c947390476
commit
5955df2576
@ -124,60 +124,60 @@ public final class ElementTypeDescriptionCustom extends ElementTypeDescription {
|
||||
throw new NodeException(Lang.get("err_recursiveNestingAt_N0", circuit.getOrigin()));
|
||||
|
||||
if (isGeneric()) {
|
||||
try {
|
||||
Context args;
|
||||
if (containingVisualElement != null) {
|
||||
args = containingVisualElement.getGenericArgs();
|
||||
if (args == null) {
|
||||
String argsCode = containingVisualElement.getElementAttributes().get(Keys.GENERIC);
|
||||
try {
|
||||
Statement s = getStatement(argsCode);
|
||||
args = new Context();
|
||||
if (containingVisualElement.getGenericArgs() != null)
|
||||
args.declareVar("args", containingVisualElement.getGenericArgs());
|
||||
s.execute(args);
|
||||
} catch (HGSEvalException e) {
|
||||
throw new NodeException(Lang.get("err_evaluatingGenericsCode_N_N_N", circuit.getOrigin(), containingVisualElement, argsCode), e);
|
||||
}
|
||||
}
|
||||
} else
|
||||
args = new Context();
|
||||
|
||||
Circuit c = circuit.createDeepCopy();
|
||||
for (VisualElement ve : c.getElements()) {
|
||||
String gen = ve.getElementAttributes().get(Keys.GENERIC).trim();
|
||||
Context args;
|
||||
if (containingVisualElement != null) {
|
||||
args = containingVisualElement.getGenericArgs();
|
||||
if (args == null) {
|
||||
String argsCode = containingVisualElement.getElementAttributes().get(Keys.GENERIC);
|
||||
try {
|
||||
if (!gen.isEmpty()) {
|
||||
boolean isCustom = library.getElementType(ve.getElementName(), ve.getElementAttributes()).isCustom();
|
||||
Statement genS = getStatement(gen);
|
||||
if (isCustom) {
|
||||
Context mod = new Context()
|
||||
.declareVar("args", args)
|
||||
.declareFunc("setCircuit", new Function(1) {
|
||||
@Override
|
||||
protected Object f(Object... args) {
|
||||
ve.setElementName(args[0].toString());
|
||||
return null;
|
||||
}
|
||||
});
|
||||
genS.execute(mod);
|
||||
ve.setGenericArgs(mod);
|
||||
} else {
|
||||
Context mod = new Context()
|
||||
.declareVar("args", args)
|
||||
.declareVar("this", new SubstituteLibrary.AllowSetAttributes(ve.getElementAttributes()));
|
||||
genS.execute(mod);
|
||||
}
|
||||
}
|
||||
} catch (HGSEvalException e) {
|
||||
throw new NodeException(Lang.get("err_evaluatingGenericsCode_N_N_N", circuit.getOrigin(), ve, gen), e);
|
||||
Statement s = getStatement(argsCode);
|
||||
args = new Context();
|
||||
if (containingVisualElement.getGenericArgs() != null)
|
||||
args.declareVar("args", containingVisualElement.getGenericArgs());
|
||||
s.execute(args);
|
||||
} catch (HGSEvalException | ParserException |IOException e) {
|
||||
final NodeException ex = new NodeException(Lang.get("err_evaluatingGenericsCode_N_N", containingVisualElement, argsCode), e);
|
||||
ex.setOrigin(circuit.getOrigin());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
} else
|
||||
args = new Context();
|
||||
|
||||
return new ModelCreator(c, library, true, new NetList(netList, errorVisualElement), subName, depth, errorVisualElement);
|
||||
} catch (IOException | ParserException e) {
|
||||
throw new NodeException(Lang.get("err_evaluatingGenericsCode"), e);
|
||||
Circuit c = circuit.createDeepCopy();
|
||||
for (VisualElement ve : c.getElements()) {
|
||||
String gen = ve.getElementAttributes().get(Keys.GENERIC).trim();
|
||||
try {
|
||||
if (!gen.isEmpty()) {
|
||||
boolean isCustom = library.getElementType(ve.getElementName(), ve.getElementAttributes()).isCustom();
|
||||
Statement genS = getStatement(gen);
|
||||
if (isCustom) {
|
||||
Context mod = new Context()
|
||||
.declareVar("args", args)
|
||||
.declareFunc("setCircuit", new Function(1) {
|
||||
@Override
|
||||
protected Object f(Object... args) {
|
||||
ve.setElementName(args[0].toString());
|
||||
return null;
|
||||
}
|
||||
});
|
||||
genS.execute(mod);
|
||||
ve.setGenericArgs(mod);
|
||||
} else {
|
||||
Context mod = new Context()
|
||||
.declareVar("args", args)
|
||||
.declareVar("this", new SubstituteLibrary.AllowSetAttributes(ve.getElementAttributes()));
|
||||
genS.execute(mod);
|
||||
}
|
||||
}
|
||||
} catch (HGSEvalException | ParserException | IOException e) {
|
||||
final NodeException ex = new NodeException(Lang.get("err_evaluatingGenericsCode_N_N", ve, gen), e);
|
||||
ex.setOrigin(circuit.getOrigin());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
|
||||
return new ModelCreator(c, library, true, new NetList(netList, errorVisualElement), subName, depth, errorVisualElement);
|
||||
} else
|
||||
return new ModelCreator(circuit, library, true, new NetList(netList, errorVisualElement), subName, depth, errorVisualElement);
|
||||
}
|
||||
@ -210,18 +210,18 @@ public final class ElementTypeDescriptionCustom extends ElementTypeDescription {
|
||||
/**
|
||||
* @return the generics field default value
|
||||
*/
|
||||
public String getDeclarationDefault() {
|
||||
public String getDeclarationDefault() throws NodeException {
|
||||
if (declarationDefault == null)
|
||||
declarationDefault = createDeclarationDefault();
|
||||
return declarationDefault;
|
||||
}
|
||||
|
||||
private String createDeclarationDefault() {
|
||||
private String createDeclarationDefault() throws NodeException {
|
||||
TreeSet<String> nameSet = new TreeSet<>();
|
||||
for (VisualElement ve : circuit.getElements()) {
|
||||
String gen = ve.getElementAttributes().get(Keys.GENERIC).trim();
|
||||
try {
|
||||
if (!gen.isEmpty()) {
|
||||
if (!gen.isEmpty()) {
|
||||
try {
|
||||
Parser p = new Parser(gen);
|
||||
p.enableRefReadCollection();
|
||||
p.parse(false);
|
||||
@ -236,9 +236,11 @@ public final class ElementTypeDescriptionCustom extends ElementTypeDescription {
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ParserException | IOException e) {
|
||||
final NodeException ex = new NodeException(Lang.get("err_evaluatingGenericsCode_N_N", ve, gen), e);
|
||||
ex.setOrigin(circuit.getOrigin());
|
||||
throw ex;
|
||||
}
|
||||
} catch (ParserException | IOException e) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
@ -24,6 +24,7 @@ import de.neemann.digital.draw.shapes.ShapeFactory;
|
||||
import de.neemann.digital.gui.Main;
|
||||
import de.neemann.digital.gui.Settings;
|
||||
import de.neemann.digital.gui.components.modification.*;
|
||||
import de.neemann.digital.hdl.hgs.ParserException;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
import de.neemann.digital.undo.*;
|
||||
import de.neemann.gui.*;
|
||||
@ -1026,8 +1027,13 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
if (elementType instanceof ElementTypeDescriptionCustom) {
|
||||
ElementTypeDescriptionCustom customDescr = (ElementTypeDescriptionCustom) elementType;
|
||||
if (customDescr.isGeneric()) {
|
||||
if (element.getElementAttributes().get(Keys.GENERIC).isEmpty())
|
||||
element.getElementAttributes().set(Keys.GENERIC, customDescr.getDeclarationDefault());
|
||||
if (element.getElementAttributes().get(Keys.GENERIC).isEmpty()) {
|
||||
try {
|
||||
element.getElementAttributes().set(Keys.GENERIC, customDescr.getDeclarationDefault());
|
||||
} catch (NodeException ex) {
|
||||
new ErrorMessage(Lang.get("msg_errParsingGenerics")).addCause(ex).show(CircuitComponent.this);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1024,9 +1024,11 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
||||
<string name="err_NameOfIOIsInvalidOrNotUnique_N">Der Signalname "{0}" ist ungültig oder mehrfach verwendet!</string>
|
||||
<string name="err_substitutingError">Fehler bei der Substitution von Elementen für die Analyse.</string>
|
||||
<string name="err_genericCircuitsAreNotYetSupported">Generische Schaltungen werden noch nicht unterstützt.</string>
|
||||
<string name="err_evaluatingGenericsCode_N_N_N">Fehler bei der Auswertung des generischen Codes der Schaltung. Datei {0}; Komponente: {1}; Code:
|
||||
{2}</string>
|
||||
<string name="err_evaluatingGenericsCode">Fehler bei der Auswertung des generischen Codes der Schaltung.</string>
|
||||
<string name="err_evaluatingGenericsCode_N_N">Fehler bei der Auswertung des generischen Codes der Schaltung. Code:
|
||||
{1}
|
||||
in Komponente: {0}
|
||||
</string>
|
||||
<string name="msg_errParsingGenerics">Fehler bei der Analyse des generischen Codes.</string>
|
||||
|
||||
<string name="key_AddrBits">Adress-Bits</string><!-- ROM, RAMDualPort, RAMSinglePort, RAMSinglePortSel, EEPROM -->
|
||||
<string name="key_AddrBits_tt">Anzahl der Adress-Bits, die verwendet werden.</string>
|
||||
|
@ -1016,9 +1016,10 @@
|
||||
<string name="err_NameOfIOIsInvalidOrNotUnique_N">The signal name "{0}" is invalid or used multiple times!</string>
|
||||
<string name="err_substitutingError">Error when substituting components for the analysis.</string>
|
||||
<string name="err_genericCircuitsAreNotYetSupported">Generic circuits are not yet supported.</string>
|
||||
<string name="err_evaluatingGenericsCode_N_N_N">Error in the evaluation of the generic code of the circuit. File {0}; Component: {1}; Code
|
||||
{2}</string>
|
||||
<string name="err_evaluatingGenericsCode">Error in the evaluation of the generic code of the circuit.</string>
|
||||
<string name="err_evaluatingGenericsCode_N_N">Error in the evaluation of the generic code of the circuit. Code
|
||||
{1}
|
||||
at Component: {0}</string>
|
||||
<string name="msg_errParsingGenerics">Error while parsing generics code.</string>
|
||||
|
||||
<string name="key_AddrBits">Address Bits</string><!-- ROM, RAMDualPort, RAMSinglePort, RAMSinglePortSel, EEPROM -->
|
||||
<string name="key_AddrBits_tt">Number of address bits used.</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user