From 6ee86b26db634f9d515f7d0cfa3a97c6af1308fd Mon Sep 17 00:00:00 2001 From: Eyck Jentzsch Date: Thu, 18 Sep 2025 15:50:28 +0200 Subject: [PATCH] updates target definition and fixes error/warning handling --- .gitignore | 1 + .../com.minres.coredsl.json.target.target | 2 +- .../coredsl/json/CoreDslJsonGenerator.xtend | 8 ++++++-- .../src/com/minres/coredsl/json/Main.xtend | 16 ++++++++++++---- 4 files changed, 20 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 98aba88..549b265 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ /.launch/ /.settings/ +/RV32GC.json diff --git a/com.minres.coredsl.json.target/com.minres.coredsl.json.target.target b/com.minres.coredsl.json.target/com.minres.coredsl.json.target.target index 79fb4c3..264f25a 100644 --- a/com.minres.coredsl.json.target/com.minres.coredsl.json.target.target +++ b/com.minres.coredsl.json.target/com.minres.coredsl.json.target.target @@ -39,7 +39,7 @@ - + diff --git a/com.minres.coredsl.json/src/com/minres/coredsl/json/CoreDslJsonGenerator.xtend b/com.minres.coredsl.json/src/com/minres/coredsl/json/CoreDslJsonGenerator.xtend index a475b58..59bbde7 100644 --- a/com.minres.coredsl.json/src/com/minres/coredsl/json/CoreDslJsonGenerator.xtend +++ b/com.minres.coredsl.json/src/com/minres/coredsl/json/CoreDslJsonGenerator.xtend @@ -45,7 +45,7 @@ class CoreDslJsonGenerator extends AbstractGenerator { } def JSONArray compile(CoreDef coreDef) { val insts = coreDef.allInstr - val enabled_insts = insts.filter[it.isHls] + val enabled_insts = insts//.filter[it.isHls] val res = enabled_insts.map[ inst | inst.jsonDescr ].toList return res.length>0?new JSONArray(res) :new JSONArray() } @@ -60,7 +60,11 @@ class CoreDslJsonGenerator extends AbstractGenerator { } def String getSource(Statement stmt){ - (stmt.eResource as XtextResource).serializer.serialize(stmt) + try { + (stmt.eResource as XtextResource).serializer.serialize(stmt) + } catch(RuntimeException e){ + "" + } } def Iterable allInstr(CoreDef core) { diff --git a/com.minres.coredsl.json/src/com/minres/coredsl/json/Main.xtend b/com.minres.coredsl.json/src/com/minres/coredsl/json/Main.xtend index f159797..c6072e7 100644 --- a/com.minres.coredsl.json/src/com/minres/coredsl/json/Main.xtend +++ b/com.minres.coredsl.json/src/com/minres/coredsl/json/Main.xtend @@ -28,6 +28,7 @@ import org.eclipse.xtext.generator.IFileSystemAccess import java.lang.reflect.MalformedParametersException import org.apache.log4j.Level import org.eclipse.emf.ecore.resource.Resource +import org.eclipse.xtext.diagnostics.Severity class Main implements Callable { @@ -83,10 +84,17 @@ class GeneratorMain { val resource = resourceSet.getResource(URI.createFileURI(file.absolutePath), true) // Validate the resource val issues = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl) - if (!issues.empty) { - logger.error("Error validating " + resource.URI) - issues.forEach[logger.error(it)] - throw new ParseException("error validating " + resource.URI) + if (!issues.empty) { + val errors = issues.filter[it.severity == Severity.ERROR] + val warnings = issues.filter[it.severity == Severity.WARNING] + if (!errors.empty) { + logger.error("Error validating " + resource.URI) + issues.forEach[logger.error(it)] + throw new ParseException("error validating " + resource.URI) + } else if (!warnings.empty) { + logger.warn("There are warnings validating " + resource.URI) + issues.forEach[logger.warn(it)] + } } // Configure and start the generator resource.runGenerator(params.outputFile)