use of abs.frontend.analyser.TypeError in project abstools by abstools.
the class TypeCheckerHelper method checkForDuplicatesOfVarDecl.
/**
* checks whether the local variable v was already defined in the current function
*/
public static void checkForDuplicatesOfVarDecl(SemanticConditionList e, VarDeclStmt v) {
String varName = v.getVarDecl().getName();
VarOrFieldDecl otherVar = v.lookupVarOrFieldName(varName, false);
if (otherVar != null && v.inSameMethodOrBlock(otherVar)) {
e.add(new TypeError(v, ErrorMessage.VARIABLE_ALREADY_DECLARED, varName));
}
}
use of abs.frontend.analyser.TypeError in project abstools by abstools.
the class TypeCheckerHelper method typeCheckDeltaClause.
public static void typeCheckDeltaClause(DeltaClause clause, Map<String, DeltaDecl> deltaNames, Set<String> definedFeatures, SemanticConditionList e) {
/* Does the delta exist? */
final Deltaspec spec = clause.getDeltaspec();
if (!deltaNames.containsKey(spec.getDeltaID()))
e.add(new TypeError(spec, ErrorMessage.NAME_NOT_RESOLVABLE, spec.getDeltaID()));
else {
DeltaDecl dd = deltaNames.get(spec.getDeltaID());
if (dd.getNumParam() != spec.getNumDeltaparam()) {
e.add(new TypeError(spec, ErrorMessage.WRONG_NUMBER_OF_ARGS, dd.getNumParam(), spec.getNumDeltaparam()));
} else {
for (int i = 0; i < dd.getNumParam(); i++) {
DeltaParamDecl formal = dd.getParam(i);
Deltaparam actual = spec.getDeltaparam(i);
// TODO: W00t?!
if (actual instanceof Const) {
Value a = ((Const) actual).getValue();
if (!formal.accepts(a)) {
e.add(new TypeError(a, ErrorMessage.CANNOT_ASSIGN, a.getName(), formal.getType().getSimpleName()));
}
}
}
}
}
/* Do the referenced features exist? */
if (clause.hasAppCond()) {
clause.getAppCond().typeCheck(definedFeatures, e);
}
if (clause.hasFromAppCond()) {
clause.getFromAppCond().typeCheck(definedFeatures, e);
}
/* What about deltas mentioned in the 'after' clause? */
for (DeltaID did : clause.getAfterDeltaIDs()) {
if (!deltaNames.containsKey(did.getName())) {
e.add(new TypeError(did, ErrorMessage.NAME_NOT_RESOLVABLE, did.getName()));
}
}
}
Aggregations