use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.
the class InternalTypeSystem method applyRuleSubstTypeVariablesWildcard.
protected Result<TypeArgument> applyRuleSubstTypeVariablesWildcard(final RuleEnvironment G, final RuleApplicationTrace _trace_, final Wildcard wildcard) throws RuleFailedException {
// output parameter
Wildcard T = null;
TypeRef ub = wildcard.getDeclaredUpperBound();
if ((ub != null)) {
/* G |- ub ~> ub */
Result<TypeArgument> result = substTypeVariablesInternal(G, _trace_, ub);
checkAssignableTo(result.getFirst(), TypeRef.class);
ub = (TypeRef) result.getFirst();
}
TypeRef lb = wildcard.getDeclaredLowerBound();
if ((lb != null)) {
/* G |- lb ~> lb */
Result<TypeArgument> result_1 = substTypeVariablesInternal(G, _trace_, lb);
checkAssignableTo(result_1.getFirst(), TypeRef.class);
lb = (TypeRef) result_1.getFirst();
}
if (((ub != wildcard.getDeclaredUpperBound()) || (lb != wildcard.getDeclaredLowerBound()))) {
T = TypeUtils.<Wildcard>copy(wildcard);
T.setDeclaredUpperBound(TypeUtils.<TypeRef>copyIfContained(ub));
T.setDeclaredLowerBound(TypeUtils.<TypeRef>copyIfContained(lb));
} else {
T = wildcard;
}
return new Result<TypeArgument>(T);
}
use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.
the class InternalTypeSystem method applyRuleTypeN4FieldDeclaration.
protected Result<TypeRef> applyRuleTypeN4FieldDeclaration(final RuleEnvironment G, final RuleApplicationTrace _trace_, final N4FieldDeclaration fieldDecl) throws RuleFailedException {
// output parameter
TypeRef T = null;
TypeRef _declaredTypeRef = fieldDecl.getDeclaredTypeRef();
boolean _tripleNotEquals = (_declaredTypeRef != null);
if (_tripleNotEquals) {
T = fieldDecl.getDeclaredTypeRef();
} else {
Expression _expression = fieldDecl.getExpression();
boolean _tripleNotEquals_1 = (_expression != null);
if (_tripleNotEquals_1) {
/* G |- fieldDecl.expression : var TypeRef E */
Expression _expression_1 = fieldDecl.getExpression();
TypeRef E = null;
Result<TypeRef> result = typeInternal(G, _trace_, _expression_1);
checkAssignableTo(result.getFirst(), TypeRef.class);
E = (TypeRef) result.getFirst();
/* G |~ E /\ E */
Result<TypeRef> result_1 = upperBoundInternal(G, _trace_, E);
checkAssignableTo(result_1.getFirst(), TypeRef.class);
E = (TypeRef) result_1.getFirst();
if ((((E.getDeclaredType() == RuleEnvironmentExtensions.undefinedType(G)) || (E.getDeclaredType() == RuleEnvironmentExtensions.nullType(G))) || (E.getDeclaredType() == RuleEnvironmentExtensions.voidType(G)))) {
T = RuleEnvironmentExtensions.anyTypeRef(G);
} else {
T = E;
}
} else {
T = RuleEnvironmentExtensions.anyTypeRef(G);
}
}
return new Result<TypeRef>(T);
}
use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.
the class InternalTypeSystem method applyRuleTypeArrayLiteral.
protected Result<TypeRef> applyRuleTypeArrayLiteral(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ArrayLiteral al) throws RuleFailedException {
// output parameter
TypeRef T = null;
/* fail error "rule typeArrayLiteral should never be invoked (PolyComputer is responsible for typing ArrayLiterals)" */
String error = "rule typeArrayLiteral should never be invoked (PolyComputer is responsible for typing ArrayLiterals)";
throwForExplicitFail(error, new ErrorInformation(null, null));
return new Result<TypeRef>(T);
}
use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.
the class InternalTypeSystem method applyRuleLowerBoundParameterizedTypeRef.
protected Result<TypeRef> applyRuleLowerBoundParameterizedTypeRef(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ParameterizedTypeRef ptr) throws RuleFailedException {
// output parameter
TypeRef T = null;
Type _declaredType = ptr.getDeclaredType();
if ((_declaredType instanceof TypeVariable)) {
T = ptr;
} else {
T = ptr;
}
return new Result<TypeRef>(T);
}
use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.
the class InternalTypeSystem method applyRuleSubstTypeVariablesInFunctionTypeRef.
protected Result<TypeArgument> applyRuleSubstTypeVariablesInFunctionTypeRef(final RuleEnvironment G, final RuleApplicationTrace _trace_, final FunctionTypeRef typeRef) throws RuleFailedException {
// output parameter
TypeRef result = null;
TypeArgument _value = this.applyRuleSubstTypeVariablesInFunctionTypeExprOrRef(G, _trace_, typeRef).getValue();
result = ((TypeRef) _value);
return new Result<TypeArgument>(result);
}
Aggregations