use of org.eclipse.n4js.ts.typeRefs.TypeRef 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);
}
use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.
the class InternalTypeSystem method typeImpl.
protected Result<TypeRef> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ThisLiteral t) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeRef> _result_ = applyRuleTypeThisKeyword(G, _subtrace_, t);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("typeThisKeyword") + stringRepForEnv(G) + " |- " + stringRep(t) + " : " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleTypeThisKeyword) {
typeThrowException(ruleName("typeThisKeyword") + stringRepForEnv(G) + " |- " + stringRep(t) + " : " + "TypeRef", TYPETHISKEYWORD, e_applyRuleTypeThisKeyword, t, new ErrorInformation[] { new ErrorInformation(t) });
return null;
}
}
use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.
the class InternalTypeSystem method lowerBoundImpl.
protected Result<TypeRef> lowerBoundImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final FunctionTypeExprOrRef F) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeRef> _result_ = applyRuleLowerBoundFunctionTypeExprOrRef(G, _subtrace_, F);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("lowerBoundFunctionTypeExprOrRef") + stringRepForEnv(G) + " |~ " + stringRep(F) + " \\/ " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleLowerBoundFunctionTypeExprOrRef) {
lowerBoundThrowException(ruleName("lowerBoundFunctionTypeExprOrRef") + stringRepForEnv(G) + " |~ " + stringRep(F) + " \\/ " + "TypeRef", LOWERBOUNDFUNCTIONTYPEEXPRORREF, e_applyRuleLowerBoundFunctionTypeExprOrRef, F, new ErrorInformation[] { new ErrorInformation(F) });
return null;
}
}
use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.
the class InternalTypeSystem method applyRuleTypeAwaitExpression.
protected Result<TypeRef> applyRuleTypeAwaitExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final AwaitExpression e) throws RuleFailedException {
// output parameter
TypeRef T = null;
/* G |- e.expression : var TypeRef exprType */
Expression _expression = e.getExpression();
TypeRef exprType = null;
Result<TypeRef> result = typeInternal(G, _trace_, _expression);
checkAssignableTo(result.getFirst(), TypeRef.class);
exprType = (TypeRef) result.getFirst();
Type _declaredType = exprType.getDeclaredType();
TClass _promiseType = RuleEnvironmentExtensions.promiseType(G);
boolean _tripleEquals = (_declaredType == _promiseType);
if (_tripleEquals) {
/* G |~ exprType.typeArgs.get(0) /\ T */
TypeArgument _get = exprType.getTypeArgs().get(0);
Result<TypeRef> result_1 = upperBoundInternal(G, _trace_, _get);
checkAssignableTo(result_1.getFirst(), TypeRef.class);
T = (TypeRef) result_1.getFirst();
} else {
boolean _isPromisifiableExpression = this.promisifyHelper.isPromisifiableExpression(e.getExpression());
if (_isPromisifiableExpression) {
final TypeRef promisifiedReturnTypeRef = this.promisifyHelper.extractPromisifiedReturnType(e.getExpression());
Type _declaredType_1 = promisifiedReturnTypeRef.getDeclaredType();
TClass _promiseType_1 = RuleEnvironmentExtensions.promiseType(G);
boolean _tripleEquals_1 = (_declaredType_1 == _promiseType_1);
if (_tripleEquals_1) {
/* G |~ promisifiedReturnTypeRef.typeArgs.get(0) /\ T */
TypeArgument _get_1 = promisifiedReturnTypeRef.getTypeArgs().get(0);
Result<TypeRef> result_2 = upperBoundInternal(G, _trace_, _get_1);
checkAssignableTo(result_2.getFirst(), TypeRef.class);
T = (TypeRef) result_2.getFirst();
} else {
T = promisifiedReturnTypeRef;
}
} else {
T = exprType;
}
}
return new Result<TypeRef>(T);
}
use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.
the class InternalTypeSystem method applyRuleExpectedTypeOfRightSideInVariableBinding.
protected Result<TypeRef> applyRuleExpectedTypeOfRightSideInVariableBinding(final RuleEnvironment G, final RuleApplicationTrace _trace_, final VariableBinding binding, final Expression initExpr) throws RuleFailedException {
// output parameter
TypeRef T = null;
T = RuleEnvironmentExtensions.topTypeRef(G);
return new Result<TypeRef>(T);
}
Aggregations