use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class JavaBackendTest method getJavaCode.
protected JavaCode getJavaCode(String absCode, Config... config) throws Exception {
Model model = null;
String code = null;
code = absCode;
final int len = config.length;
Config[] c2 = new Config[len + 2];
for (int i = 0; i < len; i++) {
c2[i] = config[i];
}
c2[len] = Config.TYPE_CHECK;
// c2[len+1] = Config.WITH_LOC_INF; // XXX: Trips up CI.
model = assertParse(code, c2);
if (model.hasErrors()) {
fail(model.getErrors().getFirstError().getHelpMessage());
} else {
SemanticConditionList el = model.typeCheck();
if (el.containsErrors()) {
fail(el.getFirstError().getMsg());
}
}
if (model.hasErrors()) {
fail(model.getErrors().getFirstError().getHelpMessage());
return null;
}
return getJavaCode(model);
}
use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class LocationTypeInferenceExtension method finished.
@Override
public void finished() {
ConstraintSolver solver = new ConstraintSolver(constraints, debug);
results = solver.solve();
if (debug) {
for (Map.Entry<LocationTypeVar, LocationType> e : results.entrySet()) {
System.out.println("" + e.getKey() + " := " + e.getValue());
}
}
if (!errors.containsErrors()) {
SemanticConditionList sel = new SemanticConditionList();
List<TypeSystemExtension> exts = model.getTypeExt().getTypeSystemExtensionList();
model.getTypeExt().clearTypeSystemExtensions();
LocationTypeExtension lte = new LocationTypeExtension(model, results);
lte.setDefaultType(defaultType);
model.getTypeExt().register(lte);
model.typeCheck(sel);
errors.addAll(sel);
model.getTypeExt().clearTypeSystemExtensions();
model.getTypeExt().registerAll(exts);
}
}
use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class Main method typeCheckModel.
private void typeCheckModel(Model m) {
if (!arguments.notypecheck) {
if (arguments.verbose)
System.out.println("Typechecking Model...");
registerNullableTypeChecking(m);
registerLocationTypeChecking(m);
SemanticConditionList typeerrors = m.typeCheck();
for (SemanticCondition se : typeerrors) {
System.err.println(se.getHelpMessage());
}
}
}
use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class Main method analyzeFlattenAndRewriteModel.
/**
* This horrible method does too many things and needs to be in every code
* path that expects a working model, especially when products are
* involved. (ProductDecl.getProduct() returns null until
* evaluateAllProductDeclarations() was called once.)
*
* @param m
* @throws WrongProgramArgumentException
* @throws DeltaModellingException
* @throws FileNotFoundException
*/
private void analyzeFlattenAndRewriteModel(Model m) throws WrongProgramArgumentException, DeltaModellingException, FileNotFoundException {
m.verbose = arguments.verbose;
m.debug = arguments.debug;
m.doAACrewrite = !arguments.prettyprint_keepsugar;
m.doForEachRewrite = !arguments.prettyprint_keepsugar;
if (m.hasParserErrors()) {
System.err.println("Syntactic errors: " + m.getParserErrors().size());
for (ParserError e : m.getParserErrors()) {
System.err.println(e.getHelpMessage());
System.err.flush();
}
return;
}
// resolve ProductExpressions to simple sets of features
m.evaluateAllProductDeclarations();
rewriteModel(m, arguments.product);
m.flattenTraitOnly();
m.collapseTraitModifiers();
m.expandPartialFunctions();
m.expandForeachLoops();
m.expandAwaitAsyncCalls();
if (arguments.product != null) {
// apply deltas that correspond to arguments.productproduct
if (arguments.notypecheck) {
m.flattenForProductUnsafe(arguments.product);
} else {
m.flattenForProduct(arguments.product);
}
}
if (arguments.dump) {
m.dumpMVars();
m.dump(System.out);
}
final SemanticConditionList semErrs = m.getErrors();
if (semErrs.containsErrors()) {
System.err.println("Semantic errors: " + semErrs.getErrorCount());
}
for (SemanticCondition error : semErrs) {
// Print both errors and warnings
System.err.println(error.getHelpMessage());
System.err.flush();
}
if (!semErrs.containsErrors()) {
typeCheckModel(m);
}
}
use of org.abs_models.frontend.analyser.SemanticConditionList in project abstools by abstools.
the class CheckSPLCommand method typeCheckProductLine.
private void typeCheckProductLine(Model m) {
// int n = m.getFeatureModelConfigurations().size();
int n = m.getProductList().getNumChild();
if (n == 0)
return;
if (parent.verbose) {
System.out.println("Typechecking Software Product Line (" + n + " products)...");
}
SemanticConditionList errors = m.typeCheckPL();
for (SemanticCondition err : errors) {
System.err.println(err.getHelpMessage());
}
}
Aggregations