use of abs.frontend.typechecker.DataTypeType in project abstools by abstools.
the class ClassGenerator method generateParameterDescription.
private void generateParameterDescription(Type paramtype) {
ecs.print("<<\"" + paramtype.getQualifiedName() + "\">>,");
ecs.print(" {");
if (paramtype.isDataType()) {
DataTypeType paramdatatype = (DataTypeType) paramtype;
if (paramdatatype.hasTypeArgs()) {
String interp = "";
for (Type typearg : paramdatatype.getTypeArgs()) {
ecs.print(interp);
interp = ", ";
generateParameterDescription(typearg);
}
}
}
ecs.print(" }");
}
use of abs.frontend.typechecker.DataTypeType in project abstools by abstools.
the class TypeExtensionHelper method checkEq.
public void checkEq(Type lht, Type rht, ASTNode<?> origin) {
if (lht.isDataType() && rht.isDataType()) {
DataTypeType dtl = (DataTypeType) lht;
DataTypeType dtr = (DataTypeType) rht;
if (dtl.hasTypeArgs() && dtr.hasTypeArgs() && dtl.getTypeArgs().size() == dtr.getTypeArgs().size()) {
for (int i = 0; i < dtl.getTypeArgs().size(); i++) {
checkEq(dtr.getTypeArg(i), dtl.getTypeArg(i), origin);
}
}
}
if (lht.isReferenceType() && rht.isReferenceType()) {
for (TypeSystemExtension tse : obs) {
tse.checkEq(rht, lht, origin);
}
}
}
use of abs.frontend.typechecker.DataTypeType in project abstools by abstools.
the class TypeExtensionHelper method checkAssignable.
public void checkAssignable(Type adaptTo, AdaptDirection dir, Type rht, Type lht, ASTNode<?> n) {
rht = resolveBoundedType(rht);
if (lht.isDataType() && rht.isDataType()) {
DataTypeType dtl = (DataTypeType) lht;
DataTypeType dtr = (DataTypeType) rht;
if (dtl.hasTypeArgs() && dtr.hasTypeArgs() && dtl.getTypeArgs().size() == dtr.getTypeArgs().size()) {
for (int i = 0; i < dtl.getTypeArgs().size(); i++) {
checkAssignable(adaptTo, dir, dtr.getTypeArg(i), dtl.getTypeArg(i), n);
}
}
}
if (lht.isReferenceType() && rht.isReferenceType()) {
for (TypeSystemExtension tse : obs) {
tse.checkAssignable(adaptTo, dir, rht, lht, n);
}
}
}
use of abs.frontend.typechecker.DataTypeType in project abstools by abstools.
the class TypeExtensionHelper method checkTypeParameter.
private void checkTypeParameter(HashMap<TypeParameter, Type> map, Type rht, Type lht, ASTNode<?> origin) {
rht = resolveBoundedType(rht);
if (rht.isBoundedType())
return;
if (lht.isTypeParameter() && rht.isReferenceType()) {
TypeParameter typeParam = (TypeParameter) lht;
Type lt = map.get(typeParam);
if (lt != null) {
checkEq(lt, rht, origin);
} else {
map.put(typeParam, rht);
}
} else if (lht.isDataType()) {
DataTypeType argdt = (DataTypeType) lht;
if (argdt.hasTypeArgs()) {
DataTypeType dt = (DataTypeType) rht;
for (int i = 0; i < dt.numTypeArgs(); i++) {
checkTypeParameter(map, dt.getTypeArg(i), argdt.getTypeArg(i), origin);
}
}
} else if (lht.isReferenceType()) {
checkEq(lht, rht, origin);
}
}
use of abs.frontend.typechecker.DataTypeType in project abstools by abstools.
the class OtherAnalysisTests method awaitRewriteModule1.
@Test
public void awaitRewriteModule1() {
Model.doAACrewrite = false;
Model m = assertParseOk("module A; export *; data X; module B; export *; data X; module C; import * from A; import B.X; class C { X m() { return await this!m();}}");
ClassDecl c = (ClassDecl) m.lookupModule("C").getDecl(0);
ReturnStmt ret = (ReturnStmt) c.getMethod(0).getBlock().getStmt(0);
assertThat(ret.getRetExp().getType(), instanceOf(DataTypeType.class));
assertEquals("A.X", ret.getRetExp().getType().getQualifiedName());
Model.doAACrewrite = true;
m = assertParseOk("module A; export *; data X; module B; export *; data X; module C; import * from A; import B.X; class C { X m() { return await this!m();}}", Config.WITH_STD_LIB);
c = (ClassDecl) m.lookupModule("C").getDecl(0);
Stmt s = c.getMethod(0).getBlock().getStmt(0);
VarDeclStmt b = (VarDeclStmt) s;
Type t = ((DataTypeType) b.getVarDecl().getType()).getTypeArg(0);
assertEquals("A.X", t.getQualifiedName());
}
Aggregations