Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
133 changes: 42 additions & 91 deletions src/org/rascalmpl/semantics/dynamic/BasicType.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {
@Override
public io.usethesource.vallang.type.Type typeOf(Environment __eval, IEvaluator<Result<IValue>> eval, boolean instantiateTypeParameters) {

throw new NonWellformedType(
"bag should have one type argument, like bag[value].", this);
throw new NonWellformedType("bag should have one type argument, like bag[value].", this);

}

Expand All @@ -58,11 +57,9 @@ public Bool(ISourceLocation __param1, IConstructor tree) {
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {

if (__eval.__getTypeArgument().getArity() == 0) {
return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf()
.boolType();
return TF.boolType();
}
throw new NonWellformedType(
"bool cannot have type arguments.", this);
throw new NonWellformedType("bool cannot have type arguments.", this);

}

Expand All @@ -85,11 +82,9 @@ public DateTime(ISourceLocation __param1, IConstructor tree) {
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {

if (__eval.__getTypeArgument().getArity() == 0) {
return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf()
.dateTimeType();
return TF.dateTimeType();
}
throw new NonWellformedType(
"datetime cannot have type arguments.", this);
throw new NonWellformedType("datetime cannot have type arguments.", this);

}

Expand All @@ -110,11 +105,9 @@ public Int(ISourceLocation __param1, IConstructor tree) {
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {

if (__eval.__getTypeArgument().getArity() == 0) {
return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf()
.integerType();
return TF.integerType();
}
throw new NonWellformedType("int cannot have type arguments.",
this);
throw new NonWellformedType("int cannot have type arguments.", this);

}

Expand All @@ -138,11 +131,9 @@ public Rational(ISourceLocation __param1, IConstructor tree) {
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {

if (__eval.__getTypeArgument().getArity() == 0) {
return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf()
.integerType();
return TF.rationalType();
Comment thread
rodinaarssen marked this conversation as resolved.
Resolved
}
throw new NonWellformedType("rat cannot have type arguments.",
this);
throw new NonWellformedType("rat cannot have type arguments.", this);

}

Expand All @@ -164,25 +155,21 @@ public List(ISourceLocation __param1, IConstructor tree) {

@Override
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {
if (__eval.__getTypeArgument() == TF.voidType()) {
if (__eval.__getTypeArgument().isBottom()) {
Comment thread
rodinaarssen marked this conversation as resolved.
Resolved
return TF.listType(TF.voidType());
}

if (__eval.__getTypeArgument().getArity() == 1) {
return TF.listType(__eval.__getTypeArgument().getFieldType(0));
}

throw new NonWellformedType(
"list should have exactly one type argument, like list[value]",
this);
throw new NonWellformedType("list should have exactly one type argument, like list[value]", this);

}

@Override
public io.usethesource.vallang.type.Type typeOf(Environment __eval, IEvaluator<Result<IValue>> eval, boolean instantiateTypeParameters) {
throw new NonWellformedType(
"list should have one type argument, like list[value].",
this);
throw new NonWellformedType("list should have one type argument, like list[value].", this);
}

}
Expand All @@ -197,11 +184,9 @@ public Loc(ISourceLocation __param1, IConstructor tree) {
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {

if (__eval.__getTypeArgument().getArity() == 0) {
return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf()
.sourceLocationType();
return TF.sourceLocationType();
}
throw new NonWellformedType("loc cannot have type arguments.",
this);
throw new NonWellformedType("loc cannot have type arguments.", this);

}

Expand Down Expand Up @@ -230,18 +215,14 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {
return TF.mapTypeFromTuple(__eval.__getTypeArgument());
}

throw new NonWellformedType(
"map should have exactly two type arguments, like map[value,value]",
this);
throw new NonWellformedType("map should have exactly two type arguments, like map[value,value]", this);

}

@Override
public io.usethesource.vallang.type.Type typeOf(Environment __eval, IEvaluator<Result<IValue>> eval, boolean instantiateTypeParameters) {

throw new NonWellformedType(
"map should have at two type arguments, like map[value,value].",
this);
throw new NonWellformedType("map should have at two type arguments, like map[value,value].", this);

}

Expand All @@ -257,11 +238,9 @@ public Node(ISourceLocation __param1, IConstructor tree) {
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {

if (__eval.__getTypeArgument().getArity() == 0) {
return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf()
.nodeType();
return TF.nodeType();
}
throw new NonWellformedType(
"node cannot have type arguments.", this);
throw new NonWellformedType("node cannot have type arguments.", this);

}

Expand All @@ -284,11 +263,9 @@ public Num(ISourceLocation __param1, IConstructor tree) {
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {

if (__eval.__getTypeArgument().getArity() == 0) {
return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf()
.numberType();
return TF.numberType();
}
throw new NonWellformedType("num cannot have type arguments.",
this);
throw new NonWellformedType("num cannot have type arguments.", this);

}

Expand All @@ -311,11 +288,9 @@ public Real(ISourceLocation __param1, IConstructor tree) {
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {

if (__eval.__getTypeArgument().getArity() == 0) {
return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf()
.realType();
return TF.realType();
}
throw new NonWellformedType(
"real cannot have type arguments.", this);
throw new NonWellformedType("real cannot have type arguments.", this);

}

Expand All @@ -335,27 +310,21 @@ public Type(ISourceLocation __param1, IConstructor tree) {

@Override
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {
var rtf = org.rascalmpl.types.RascalTypeFactory.getInstance();
if (__eval.__getTypeArgument().isBottom()) {
return org.rascalmpl.types.RascalTypeFactory
.getInstance().reifiedType(TF.voidType());
return rtf.reifiedType(TF.voidType());
}

if (__eval.__getTypeArgument().getArity() == 1) {
return org.rascalmpl.types.RascalTypeFactory
.getInstance().reifiedType(
__eval.__getTypeArgument().getFieldType(0));
return rtf.reifiedType(__eval.__getTypeArgument().getFieldType(0));
}
throw new NonWellformedType(
"type should have exactly one type argument, like type[value]",
this);
throw new NonWellformedType("type should have exactly one type argument, like type[value]", this);

}

@Override
public io.usethesource.vallang.type.Type typeOf(Environment env, IEvaluator<Result<IValue>> eval, boolean instantiateTypeParameters) {
throw new NonWellformedType(
"type should have at one type argument, like type[value].",
this);
throw new NonWellformedType("type should have at one type argument, like type[value].", this);
}

}
Expand All @@ -369,17 +338,14 @@ public Relation(ISourceLocation __param1, IConstructor tree) {
@Override
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {

return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf()
.relTypeFromTuple(__eval.__getTypeArgument());
return TF.relTypeFromTuple(__eval.__getTypeArgument());

}

@Override
public io.usethesource.vallang.type.Type typeOf(Environment __eval, IEvaluator<Result<IValue>> eval, boolean instantiateTypeParameters) {

throw new NonWellformedType(
"rel should have at least one type argument, like rel[value,value].",
this);
throw new NonWellformedType("rel should have at least one type argument, like rel[value,value].", this);

}

Expand All @@ -394,17 +360,14 @@ public ListRelation(ISourceLocation __param1, IConstructor tree) {
@Override
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {

return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf()
.lrelTypeFromTuple(__eval.__getTypeArgument());
return TF.lrelTypeFromTuple(__eval.__getTypeArgument());

}

@Override
public io.usethesource.vallang.type.Type typeOf(Environment __eval, IEvaluator<Result<IValue>> eval, boolean instantiateTypeParameters) {

throw new NonWellformedType(
"lrel should have at least one type argument, like lrel[value,value].",
this);
throw new NonWellformedType("lrel should have at least one type argument, like lrel[value,value].", this);

}

Expand All @@ -419,24 +382,20 @@ public Set(ISourceLocation __param1, IConstructor tree) {
@Override
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {
if (__eval.__getTypeArgument().isBottom()) {
return TF.listType(TF.voidType());
return TF.setType(TF.voidType());
Comment thread
rodinaarssen marked this conversation as resolved.
Resolved
}

if (__eval.__getTypeArgument().getArity() == 1) {
return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf()
.setType(__eval.__getTypeArgument().getFieldType(0));
return TF.setType(__eval.__getTypeArgument().getFieldType(0));
}
throw new NonWellformedType(
"set should have exactly one type argument, like set[value]",
this);
throw new NonWellformedType("set should have exactly one type argument, like set[value]", this);

}

@Override
public io.usethesource.vallang.type.Type typeOf(Environment __eval, IEvaluator<Result<IValue>> eval, boolean instantiateTypeParameters) {

throw new NonWellformedType(
"set should have one type argument, like set[value].", this);
throw new NonWellformedType("set should have one type argument, like set[value].", this);

}

Expand All @@ -452,11 +411,9 @@ public String(ISourceLocation __param1, IConstructor tree) {
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {

if (__eval.__getTypeArgument().getArity() == 0) {
return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf()
.stringType();
return TF.stringType();
}
throw new NonWellformedType(
"string cannot have type arguments.", this);
throw new NonWellformedType("string cannot have type arguments.", this);

}

Expand Down Expand Up @@ -484,9 +441,7 @@ public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {
@Override
public io.usethesource.vallang.type.Type typeOf(Environment __eval, IEvaluator<Result<IValue>> eval, boolean instantiateTypeParameters) {

throw new NonWellformedType(
"tuple should have type arguments, like tuple[value,value].",
this);
throw new NonWellformedType("tuple should have type arguments, like tuple[value,value].", this);

}

Expand All @@ -502,11 +457,9 @@ public Value(ISourceLocation __param1, IConstructor tree) {
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {

if (__eval.__getTypeArgument().getArity() == 0) {
return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf()
.valueType();
return TF.valueType();
}
throw new NonWellformedType(
"value cannot have type arguments.", this);
throw new NonWellformedType("value cannot have type arguments.", this);

}

Expand All @@ -527,11 +480,9 @@ public Void(ISourceLocation __param1, IConstructor tree) {
@Override
public io.usethesource.vallang.type.Type __evaluate(BasicTypeEvaluator __eval) {
if (__eval.__getTypeArgument().getArity() == 0) {
return org.rascalmpl.interpreter.BasicTypeEvaluator.__getTf()
.voidType();
return TF.voidType();
}
throw new NonWellformedType(
"void cannot have type arguments.", this);
throw new NonWellformedType("void cannot have type arguments.", this);
}

@Override
Expand Down
Loading