mirror of
https://github.com/hneemann/Digital.git
synced 2025-08-04 02:08:00 -04:00
fixes an issue with generic code loading files
This commit is contained in:
parent
2dab02e0c5
commit
292b2ec718
@ -57,8 +57,7 @@ public class ResolveGenerics {
|
|||||||
if (!gen.isEmpty()) {
|
if (!gen.isEmpty()) {
|
||||||
boolean isCustom = library.getElementType(ve.getElementName(), ve.getElementAttributes()).isCustom();
|
boolean isCustom = library.getElementType(ve.getElementName(), ve.getElementAttributes()).isCustom();
|
||||||
Statement genS = getStatement(gen);
|
Statement genS = getStatement(gen);
|
||||||
Context mod = new Context();
|
Context mod = publishCircuitPath(new Context(), circuit);
|
||||||
mod.declareVar(Context.BASE_FILE_KEY, circuit.getOrigin().getPath());
|
|
||||||
if (isCustom) {
|
if (isCustom) {
|
||||||
mod.declareVar("args", args)
|
mod.declareVar("args", args)
|
||||||
.declareFunc("setCircuit", new SetCircuitFunc(ve));
|
.declareFunc("setCircuit", new SetCircuitFunc(ve));
|
||||||
@ -79,6 +78,16 @@ public class ResolveGenerics {
|
|||||||
return new CircuitHolder(c, args);
|
return new CircuitHolder(c, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Context publishCircuitPath(Context context, Circuit circuit) throws NodeException {
|
||||||
|
try {
|
||||||
|
if (circuit.getOrigin() != null)
|
||||||
|
context.declareVar(Context.BASE_FILE_KEY, circuit.getOrigin().getPath());
|
||||||
|
return context;
|
||||||
|
} catch (HGSEvalException e) {
|
||||||
|
throw new NodeException("error setting the base filename", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Args createArgs(VisualElement visualElement, Circuit circuit) throws NodeException {
|
private Args createArgs(VisualElement visualElement, Circuit circuit) throws NodeException {
|
||||||
Context context;
|
Context context;
|
||||||
if (visualElement != null) {
|
if (visualElement != null) {
|
||||||
@ -96,12 +105,7 @@ public class ResolveGenerics {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
context = new Context();
|
context = publishCircuitPath(new Context(), circuit);
|
||||||
try {
|
|
||||||
context.declareVar(Context.BASE_FILE_KEY, circuit.getOrigin().getPath());
|
|
||||||
} catch (HGSEvalException e) {
|
|
||||||
throw new NodeException("error setting the base filename", e);
|
|
||||||
}
|
|
||||||
List<VisualElement> g = circuit.getElements(v -> v.equalsDescription(GenericInitCode.DESCRIPTION) && v.getElementAttributes().get(Keys.ENABLED));
|
List<VisualElement> g = circuit.getElements(v -> v.equalsDescription(GenericInitCode.DESCRIPTION) && v.getElementAttributes().get(Keys.ENABLED));
|
||||||
if (g.size() == 0)
|
if (g.size() == 0)
|
||||||
throw new NodeException(Lang.get("err_noGenericInitCode"));
|
throw new NodeException(Lang.get("err_noGenericInitCode"));
|
||||||
|
@ -631,7 +631,7 @@ public class Context implements HGSMap {
|
|||||||
File hexFile = fileLocator.locate();
|
File hexFile = fileLocator.locate();
|
||||||
|
|
||||||
if (hexFile == null)
|
if (hexFile == null)
|
||||||
throw new HGSEvalException("file " + name + " not found!");
|
throw new HGSEvalException("File " + name + " not found! Is circuit saved?");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DataField dataField = Importer.read(hexFile, dataBits);
|
DataField dataField = Importer.read(hexFile, dataBits);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user