use of org.eclipse.n4js.n4JS.IdentifierRef in project n4js by eclipse.
the class InternalTypeSystem method applyRuleExpectedTypeInForStatement.
protected Result<TypeRef> applyRuleExpectedTypeInForStatement(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ForStatement forStmnt, final Expression expression) throws RuleFailedException {
// output parameter
TypeRef T = null;
if ((forStmnt.isForOf() && (expression == forStmnt.getExpression()))) {
final Wildcard wildThing = TypeRefsFactory.eINSTANCE.createWildcard();
boolean _isTopOfDestructuringForStatement = DestructureUtils.isTopOfDestructuringForStatement(forStmnt);
if (_isTopOfDestructuringForStatement) {
} else {
VariableDeclaration _xifexpression = null;
boolean _isEmpty = forStmnt.getVarDecl().isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
_xifexpression = forStmnt.getVarDecl().get(0);
}
final VariableDeclaration varDeclInFor = _xifexpression;
VariableDeclaration _xifexpression_1 = null;
if (((forStmnt.getInitExpr() instanceof IdentifierRef) && (((IdentifierRef) forStmnt.getInitExpr()).getId() instanceof VariableDeclaration))) {
Expression _initExpr = forStmnt.getInitExpr();
IdentifiableElement _id = ((IdentifierRef) _initExpr).getId();
_xifexpression_1 = ((VariableDeclaration) _id);
}
final VariableDeclaration varDeclOutside = _xifexpression_1;
boolean _or = false;
TypeRef _declaredTypeRef = null;
if (varDeclInFor != null) {
_declaredTypeRef = varDeclInFor.getDeclaredTypeRef();
}
boolean _tripleNotEquals = (_declaredTypeRef != null);
if (_tripleNotEquals) {
_or = true;
} else {
_or = (varDeclOutside != null);
}
if (_or) {
VariableDeclaration _xifexpression_2 = null;
if ((varDeclOutside != null)) {
_xifexpression_2 = varDeclOutside;
} else {
_xifexpression_2 = varDeclInFor;
}
final VariableDeclaration varDecl = _xifexpression_2;
/* G |- varDecl : var TypeRef varTypeRef */
TypeRef varTypeRef = null;
Result<TypeRef> result = typeInternal(G, _trace_, varDecl);
checkAssignableTo(result.getFirst(), TypeRef.class);
varTypeRef = (TypeRef) result.getFirst();
wildThing.setDeclaredUpperBound(TypeUtils.<TypeRef>copyIfContained(varTypeRef));
}
}
T = RuleEnvironmentExtensions.iterableTypeRef(G, wildThing);
} else {
if ((forStmnt.isForIn() && (expression == forStmnt.getExpression()))) {
T = TypeUtils.createNonSimplifiedUnionType(RuleEnvironmentExtensions.objectTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G), RuleEnvironmentExtensions.argumentsTypeRef(G));
}
}
return new Result<TypeRef>(T);
}
Aggregations