use of abs.frontend.analyser.SemanticWarning in project abstools by abstools.
the class TypeCheckerHelper method typeCheck.
public static void typeCheck(ConstructorPattern p, SemanticConditionList e, Type t) {
DataConstructor c = p.getDataConstructor();
if (c == null) {
e.add(new SemanticError(p, ErrorMessage.CONSTRUCTOR_NOT_RESOLVABLE, p.getConstructor()));
return;
}
String cname = c.qualifiedName();
if (deprecatedConstructors.contains(cname) && !(cname.startsWith(p.getModuleDecl().getName()))) {
e.add(new SemanticWarning(p, ErrorMessage.DEPRECATED_CONSTRUCTOR, c.qualifiedName()));
}
if (c.getNumConstructorArg() != p.getNumParam()) {
e.add(new TypeError(p, ErrorMessage.WRONG_NUMBER_OF_ARGS, c.getNumConstructorArg(), p.getNumParam()));
return;
}
// isExceptionType only for clarity, since exceptions are datatypes
assert t.isDataType() || t.isExceptionType() : t;
if (!t.isExceptionType()) {
if (!t.getDecl().equals(c.getDataTypeDecl())) {
e.add(new TypeError(p, ErrorMessage.WRONG_CONSTRUCTOR, t.toString(), p.getConstructor()));
}
}
Type myType = p.getType();
if (!(myType instanceof DataTypeType))
return;
if (!(t instanceof DataTypeType)) {
e.add(new TypeError(p, ErrorMessage.TYPE_MISMATCH, myType, t));
return;
}
DataTypeType myDType = (DataTypeType) myType;
DataTypeType otherType = (DataTypeType) t;
if (!myDType.getDecl().equals(otherType.getDecl())) {
e.add(new TypeError(p, ErrorMessage.TYPE_MISMATCH, myDType, t));
return;
}
typeCheckMatchingParamsPattern(e, p, c);
}
use of abs.frontend.analyser.SemanticWarning in project abstools by abstools.
the class HttpExportChecker method checkDataTypeDecl.
@Override
public void checkDataTypeDecl(DataTypeDecl decl) {
for (DataConstructor c : decl.getDataConstructors()) {
Set<String> names = new HashSet<>();
for (ConstructorArg ca : c.getConstructorArgs()) {
ASTNode arg = null;
String key = null;
abs.frontend.ast.List<Annotation> ann = ca.getTypeUse().getAnnotations();
PureExp keyann = CompilerUtils.getAnnotationValueFromName(ann, "ABS.StdLib.HTTPName");
if (keyann != null) {
if (!(keyann instanceof StringLiteral)) {
errors.add(new TypeError(keyann, ErrorMessage.WRONG_HTTPNAME, keyann.getType()));
} else {
key = ((StringLiteral) keyann).getContent();
arg = keyann;
}
}
if (ca.hasSelectorName() && key == null) {
key = ca.getSelectorName().toString();
arg = ca.getSelectorName();
}
if (key != null) {
if (names.contains(key)) {
errors.add(new SemanticWarning(arg, ErrorMessage.DUPLICATE_HTTPNAME, key));
} else {
names.add(key);
}
}
}
}
}
use of abs.frontend.analyser.SemanticWarning in project abstools by abstools.
the class MainBlockChecker method checkModel.
@Override
public void checkModel(Model model) {
int nMainBlocks = 0;
for (CompilationUnit u : model.getCompilationUnits()) {
for (ModuleDecl m : u.getModuleDecls()) {
if (m.hasBlock()) {
nMainBlocks = nMainBlocks + 1;
}
}
}
if (nMainBlocks == 0) {
CompilationUnit c = model.getCompilationUnit(0);
errors.add(new SemanticWarning(c, ErrorMessage.MAIN_BLOCK_NOT_FOUND, "dummy string to keep constructor happy"));
} else if (nMainBlocks > 1) {
Block b = model.getMainBlock();
String moduleName = ((ModuleDecl) (b.getParent().getParent())).getName();
for (CompilationUnit u : model.getCompilationUnits()) {
for (ModuleDecl m : u.getModuleDecls()) {
if (m.hasBlock() && m.getBlock() != b) {
errors.add(new SemanticWarning(m.getBlock(), ErrorMessage.MAIN_BLOCK_AMBIGUOUS, moduleName));
}
}
}
}
}
Aggregations