use of org.eclipse.n4js.ts.types.TFormalParameter in project n4js by eclipse.
the class InternalTypeSystem method applyRuleExpectedTypeInFormalParameter.
protected Result<TypeRef> applyRuleExpectedTypeInFormalParameter(final RuleEnvironment G, final RuleApplicationTrace _trace_, final FormalParameter formalParam, final Expression initializer) throws RuleFailedException {
// output parameter
TypeRef T = null;
TypeRef _declaredTypeRef = formalParam.getDeclaredTypeRef();
boolean _tripleNotEquals = (_declaredTypeRef != null);
if (_tripleNotEquals) {
T = formalParam.getDeclaredTypeRef();
} else {
TFormalParameter _definedTypeElement = formalParam.getDefinedTypeElement();
TypeRef _typeRef = null;
if (_definedTypeElement != null) {
_typeRef = _definedTypeElement.getTypeRef();
}
boolean _tripleNotEquals_1 = (_typeRef != null);
if (_tripleNotEquals_1) {
T = formalParam.getDefinedTypeElement().getTypeRef();
} else {
T = RuleEnvironmentExtensions.anyTypeRef(G);
}
}
return new Result<TypeRef>(T);
}
use of org.eclipse.n4js.ts.types.TFormalParameter in project n4js by eclipse.
the class InternalTypeSystem method applyRuleTypeFormalParameter.
protected Result<TypeRef> applyRuleTypeFormalParameter(final RuleEnvironment G, final RuleApplicationTrace _trace_, final FormalParameter fpar) throws RuleFailedException {
// output parameter
TypeRef T = null;
final TypeRef fparTypeRef = fpar.getDeclaredTypeRef();
if ((fparTypeRef != null)) {
if (((fparTypeRef instanceof ThisTypeRefStructural) || ((fparTypeRef instanceof FunctionTypeExpression) && IteratorExtensions.<TFormalParameter>exists(Iterators.<TFormalParameter>filter(((FunctionTypeExpression) fparTypeRef).eAllContents(), TFormalParameter.class), ((Function1<TFormalParameter, Boolean>) (TFormalParameter currFpar) -> {
TypeRef _typeRef = currFpar.getTypeRef();
return Boolean.valueOf((_typeRef instanceof ThisTypeRef));
}))))) {
T = this.typeSystemHelper.bindAndSubstituteThisTypeRef(G, fparTypeRef, fparTypeRef);
} else {
TypeRef _xifexpression = null;
TFormalParameter _definedTypeElement = null;
if (fpar != null) {
_definedTypeElement = fpar.getDefinedTypeElement();
}
TypeRef _typeRef = null;
if (_definedTypeElement != null) {
_typeRef = _definedTypeElement.getTypeRef();
}
boolean _tripleNotEquals = (_typeRef != null);
if (_tripleNotEquals) {
_xifexpression = fpar.getDefinedTypeElement().getTypeRef();
} else {
_xifexpression = fpar.getDeclaredTypeRef();
}
T = _xifexpression;
}
} else {
boolean _isHasInitializerAssignment = fpar.isHasInitializerAssignment();
if (_isHasInitializerAssignment) {
Expression _initializer = fpar.getInitializer();
boolean _tripleNotEquals_1 = (_initializer != null);
if (_tripleNotEquals_1) {
/* G |- fpar.initializer : var TypeRef E */
Expression _initializer_1 = fpar.getInitializer();
TypeRef E = null;
Result<TypeRef> result = typeInternal(G, _trace_, _initializer_1);
checkAssignableTo(result.getFirst(), TypeRef.class);
E = (TypeRef) result.getFirst();
T = this.typeSystemHelper.sanitizeTypeOfVariableFieldProperty(G, E);
} else {
T = RuleEnvironmentExtensions.anyTypeRef(G);
}
} else {
boolean _enforceDynamicTypes = this.jsVariantHelper.enforceDynamicTypes(fpar);
if (_enforceDynamicTypes) {
T = RuleEnvironmentExtensions.anyTypeRefDynamic(G);
} else {
/* T = env(G, fpar, TypeRef) or T = G.anyTypeRef */
{
RuleFailedException previousFailure = null;
try {
T = this.<TypeRef>env(G, fpar, TypeRef.class);
} catch (Exception e) {
previousFailure = extractRuleFailedException(e);
T = RuleEnvironmentExtensions.anyTypeRef(G);
}
}
}
}
}
T = TypeUtils.wrapIfVariadic(RuleEnvironmentExtensions.getPredefinedTypes(G).builtInTypeScope, T, fpar);
return new Result<TypeRef>(T);
}
use of org.eclipse.n4js.ts.types.TFormalParameter in project n4js by eclipse.
the class FormalParameterImpl method setDefinedTypeElement.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setDefinedTypeElement(TFormalParameter newDefinedTypeElement) {
TFormalParameter oldDefinedTypeElement = definedTypeElement;
definedTypeElement = newDefinedTypeElement;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, N4JSPackage.FORMAL_PARAMETER__DEFINED_TYPE_ELEMENT, oldDefinedTypeElement, definedTypeElement));
}
use of org.eclipse.n4js.ts.types.TFormalParameter in project n4js by eclipse.
the class FunctionTypeExprOrRefImpl method getTypeRefAsString.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getTypeRefAsString() {
String _xifexpression = null;
TypeRef _declaredThisType = this.getDeclaredThisType();
boolean _tripleNotEquals = (_declaredThisType != null);
if (_tripleNotEquals) {
String _typeRefAsString = this.getDeclaredThisType().getTypeRefAsString();
String _plus = ("@This(" + _typeRefAsString);
_xifexpression = (_plus + ") ");
} else {
_xifexpression = "";
}
String _plus_1 = ("{" + _xifexpression);
String _plus_2 = (_plus_1 + "function");
String _xifexpression_1 = null;
boolean _isGeneric = this.isGeneric();
if (_isGeneric) {
final Function1<TypeVariable, String> _function = new Function1<TypeVariable, String>() {
public String apply(final TypeVariable it) {
return it.getTypeVariableAsString(FunctionTypeExprOrRefImpl.this.getTypeVarUpperBound(it));
}
};
String _join = IterableExtensions.join(XcoreEListExtensions.<TypeVariable, String>map(this.getTypeVars(), _function), ",");
String _plus_3 = ("<" + _join);
_xifexpression_1 = (_plus_3 + ">");
} else {
_xifexpression_1 = "";
}
String _plus_4 = (_plus_2 + _xifexpression_1);
String _plus_5 = (_plus_4 + "(");
final Function1<TFormalParameter, String> _function_1 = new Function1<TFormalParameter, String>() {
public String apply(final TFormalParameter it) {
return it.getFormalParameterAsTypesString();
}
};
String _join_1 = IterableExtensions.join(XcoreEListExtensions.<TFormalParameter, String>map(this.getFpars(), _function_1), ",");
String _plus_6 = (_plus_5 + _join_1);
String _plus_7 = (_plus_6 + ")");
String _xifexpression_2 = null;
TypeRef _returnTypeRef = this.getReturnTypeRef();
boolean _tripleNotEquals_1 = (_returnTypeRef != null);
if (_tripleNotEquals_1) {
String _typeRefAsString_1 = this.getReturnTypeRef().getTypeRefAsString();
_xifexpression_2 = (":" + _typeRefAsString_1);
} else {
_xifexpression_2 = "";
}
String _plus_8 = (_plus_7 + _xifexpression_2);
String _xifexpression_3 = null;
boolean _isReturnValueOptional = this.isReturnValueOptional();
if (_isReturnValueOptional) {
_xifexpression_3 = "?";
} else {
_xifexpression_3 = "";
}
String _plus_9 = (_plus_8 + _xifexpression_3);
String _plus_10 = (_plus_9 + "}");
String _modifiersAsString = this.getModifiersAsString();
return (_plus_10 + _modifiersAsString);
}
use of org.eclipse.n4js.ts.types.TFormalParameter in project n4js by eclipse.
the class FunctionTypeRefImpl method getTypeRefAsString.
/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public String getTypeRefAsString() {
String _xifexpression = null;
TypeRef _declaredThisType = this.getDeclaredThisType();
boolean _tripleNotEquals = (_declaredThisType != null);
if (_tripleNotEquals) {
String _typeRefAsString = this.getDeclaredThisType().getTypeRefAsString();
String _plus = ("@This(" + _typeRefAsString);
_xifexpression = (_plus + ") ");
} else {
_xifexpression = "";
}
String _plus_1 = ("{" + _xifexpression);
String _plus_2 = (_plus_1 + "function");
String _xifexpression_1 = null;
boolean _isGeneric = this.isGeneric();
if (_isGeneric) {
final Function1<TypeVariable, String> _function = new Function1<TypeVariable, String>() {
public String apply(final TypeVariable it) {
return it.getTypeVariableAsString(FunctionTypeRefImpl.this.getTypeVarUpperBound(it));
}
};
String _join = IterableExtensions.join(XcoreEListExtensions.<TypeVariable, String>map(this.getTypeVars(), _function), ",");
String _plus_3 = ("<" + _join);
_xifexpression_1 = (_plus_3 + ">");
} else {
_xifexpression_1 = "";
}
String _plus_4 = (_plus_2 + _xifexpression_1);
String _plus_5 = (_plus_4 + "(");
final Function1<TFormalParameter, String> _function_1 = new Function1<TFormalParameter, String>() {
public String apply(final TFormalParameter it) {
return it.getFormalParameterAsTypesString();
}
};
String _join_1 = IterableExtensions.join(XcoreEListExtensions.<TFormalParameter, String>map(this.getFpars(), _function_1), ",");
String _plus_6 = (_plus_5 + _join_1);
String _plus_7 = (_plus_6 + ")");
String _xifexpression_2 = null;
TypeRef _returnTypeRef = this.getReturnTypeRef();
boolean _tripleNotEquals_1 = (_returnTypeRef != null);
if (_tripleNotEquals_1) {
String _typeRefAsString_1 = this.getReturnTypeRef().getTypeRefAsString();
_xifexpression_2 = (":" + _typeRefAsString_1);
} else {
_xifexpression_2 = "";
}
String _plus_8 = (_plus_7 + _xifexpression_2);
String _xifexpression_3 = null;
boolean _isReturnValueOptional = this.isReturnValueOptional();
if (_isReturnValueOptional) {
_xifexpression_3 = "?";
} else {
_xifexpression_3 = "";
}
String _plus_9 = (_plus_8 + _xifexpression_3);
String _plus_10 = (_plus_9 + "}");
String _modifiersAsString = this.getModifiersAsString();
return (_plus_10 + _modifiersAsString);
}
Aggregations