use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.
the class InternalTypeSystem method applyRuleUpperBoundParameterizedTypeRef.
protected Result<TypeRef> applyRuleUpperBoundParameterizedTypeRef(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 applyRuleSubstTypeVariablesInFunctionTypeExprOrRef.
protected Result<TypeArgument> applyRuleSubstTypeVariablesInFunctionTypeExprOrRef(final RuleEnvironment G, final RuleApplicationTrace _trace_, final FunctionTypeExprOrRef typeRef) throws RuleFailedException {
// output parameter
TypeRef result = null;
result = this.typeSystemHelper.createSubstitutionOfFunctionTypeExprOrRef(G, typeRef);
return new Result<TypeArgument>(result);
}
use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.
the class InternalTypeSystem method applyRuleTypeSetterDeclaration.
protected Result<TypeRef> applyRuleTypeSetterDeclaration(final RuleEnvironment G, final RuleApplicationTrace _trace_, final SetterDeclaration setter) throws RuleFailedException {
// output parameter
TypeRef T = null;
TypeRef _declaredTypeRef = setter.getDeclaredTypeRef();
boolean _tripleNotEquals = (_declaredTypeRef != null);
if (_tripleNotEquals) {
T = setter.getDeclaredTypeRef();
}
if ((T == null)) {
T = RuleEnvironmentExtensions.anyTypeRef(G);
}
return new Result<TypeRef>(T);
}
use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.
the class N4JSStatementValidator method checkForInLoop.
/**
* 9.1.4 Iteration Statements, Constraints 118 (For-In-Statement Constraints) Variable declaration must be a string
*/
@Check
public void checkForInLoop(ForStatement forStatement) {
if (forStatement.isForIn()) {
TypeRef loopVarType = null;
EObject location = null;
RuleEnvironment G = (RuleEnvironment) getContext().get(RuleEnvironment.class);
if (G == null)
// wrongly configured test
return;
if (!forStatement.getVarDeclsOrBindings().isEmpty()) {
VariableDeclarationOrBinding varDeclOrBinding = forStatement.getVarDeclsOrBindings().iterator().next();
location = varDeclOrBinding;
if (varDeclOrBinding instanceof VariableDeclaration) {
loopVarType = ((VariableDeclaration) varDeclOrBinding).getDeclaredTypeRef();
} else {
VariableBinding varBinding = (VariableBinding) varDeclOrBinding;
Result<TypeRef> res = typeSystem.type(G, varBinding.getExpression());
if (!res.failed()) {
loopVarType = res.getFirst();
}
}
} else if (forStatement.getInitExpr() != null) {
location = forStatement.getInitExpr();
Result<TypeRef> res = typeSystem.type(G, forStatement.getInitExpr());
if (!res.failed()) {
loopVarType = res.getFirst();
}
}
if (loopVarType != null) {
Result<Boolean> res = typeSystem.subtype(G, RuleEnvironmentExtensions.stringTypeRef(G), loopVarType);
if (res.failed() || !res.getFirst()) {
addIssue(getMessageForTYS_FOR_IN_VAR_STRING(loopVarType.getTypeRefAsString()), location, TYS_FOR_IN_VAR_STRING);
}
}
}
}
use of org.eclipse.xsemantics.runtime.Result in project n4js by eclipse.
the class InternalTypeSystem method applyRuleExpectedTypeOfRightSideInPropertyNameValuePair.
protected Result<TypeRef> applyRuleExpectedTypeOfRightSideInPropertyNameValuePair(final RuleEnvironment G, final RuleApplicationTrace _trace_, final PropertyNameValuePair pnvp, final Expression rhs) throws RuleFailedException {
// output parameter
TypeRef T = null;
TypeRef _declaredTypeRef = pnvp.getDeclaredTypeRef();
boolean _tripleNotEquals = (_declaredTypeRef != null);
if (_tripleNotEquals) {
T = pnvp.getDeclaredTypeRef();
} else {
T = RuleEnvironmentExtensions.topTypeRef(G);
}
return new Result<TypeRef>(T);
}
Aggregations