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 TField tfield) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeRef> _result_ = applyRuleTypeTField(G, _subtrace_, tfield);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("typeTField") + stringRepForEnv(G) + " |- " + stringRep(tfield) + " : " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleTypeTField) {
typeThrowException(ruleName("typeTField") + stringRepForEnv(G) + " |- " + stringRep(tfield) + " : " + "TypeRef", TYPETFIELD, e_applyRuleTypeTField, tfield, new ErrorInformation[] { new ErrorInformation(tfield) });
return null;
}
}
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 VariableDeclaration vdecl) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeRef> _result_ = applyRuleTypeVariableDeclaration(G, _subtrace_, vdecl);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("typeVariableDeclaration") + stringRepForEnv(G) + " |- " + stringRep(vdecl) + " : " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleTypeVariableDeclaration) {
typeThrowException(ruleName("typeVariableDeclaration") + stringRepForEnv(G) + " |- " + stringRep(vdecl) + " : " + "TypeRef", TYPEVARIABLEDECLARATION, e_applyRuleTypeVariableDeclaration, vdecl, new ErrorInformation[] { new ErrorInformation(vdecl) });
return null;
}
}
use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.
the class InternalTypeSystem method expectedTypeInImpl.
protected Result<TypeRef> expectedTypeInImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final JSXPropertyAttribute container, final Expression expr) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeRef> _result_ = applyRuleExpectedTypeInJSXPropertyAttribute(G, _subtrace_, container, expr);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("expectedTypeInJSXPropertyAttribute") + stringRepForEnv(G) + " |- " + stringRep(container) + " |> " + stringRep(expr) + " : " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleExpectedTypeInJSXPropertyAttribute) {
expectedTypeInThrowException(ruleName("expectedTypeInJSXPropertyAttribute") + stringRepForEnv(G) + " |- " + stringRep(container) + " |> " + stringRep(expr) + " : " + "TypeRef", EXPECTEDTYPEINJSXPROPERTYATTRIBUTE, e_applyRuleExpectedTypeInJSXPropertyAttribute, container, expr, new ErrorInformation[] { new ErrorInformation(container), new ErrorInformation(expr) });
return null;
}
}
use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.
the class InternalTypeSystem method applyRuleExpectedTypeInShiftExpression.
protected Result<TypeRef> applyRuleExpectedTypeInShiftExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final ShiftExpression e, final Expression expression) throws RuleFailedException {
// output parameter
TypeRef T = null;
T = RuleEnvironmentExtensions.anyTypeRef(G);
return new Result<TypeRef>(T);
}
use of org.eclipse.n4js.ts.typeRefs.TypeRef in project n4js by eclipse.
the class InternalTypeSystem method applyRuleExpectedTypeInRelationalExpression.
protected Result<TypeRef> applyRuleExpectedTypeInRelationalExpression(final RuleEnvironment G, final RuleApplicationTrace _trace_, final RelationalExpression e, final Expression expression) throws RuleFailedException {
// output parameter
TypeRef T = null;
RelationalOperator _op = e.getOp();
if (_op != null) {
switch(_op) {
case INSTANCEOF:
Expression _rhs = e.getRhs();
boolean _tripleEquals = (expression == _rhs);
if (_tripleEquals) {
T = TypeUtils.createNonSimplifiedUnionType(RuleEnvironmentExtensions.functionTypeRef(G), TypeUtils.createTypeTypeRef(RuleEnvironmentExtensions.objectTypeRef(G), false), TypeUtils.createTypeTypeRef(RuleEnvironmentExtensions.n4EnumTypeRef(G), false));
} else {
T = RuleEnvironmentExtensions.anyTypeRef(G);
}
break;
case IN:
Expression _rhs_1 = e.getRhs();
boolean _tripleEquals_1 = (expression == _rhs_1);
if (_tripleEquals_1) {
T = RuleEnvironmentExtensions.objectTypeRef(G);
} else {
boolean _isTypeAware = this.jsVariantHelper.isTypeAware(e);
if (_isTypeAware) {
T = TypeUtils.createNonSimplifiedUnionType(RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G));
} else {
T = RuleEnvironmentExtensions.anyTypeRef(G);
}
}
break;
default:
boolean _isTypeAware_1 = this.jsVariantHelper.isTypeAware(e);
if (_isTypeAware_1) {
final UnionTypeExpression primsTR = TypeUtils.createNonSimplifiedUnionType(RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G), RuleEnvironmentExtensions.booleanTypeRef(G));
Expression _xifexpression = null;
Expression _lhs = e.getLhs();
boolean _tripleEquals_2 = (expression == _lhs);
if (_tripleEquals_2) {
_xifexpression = e.getRhs();
} else {
_xifexpression = e.getLhs();
}
final Expression otherSide = _xifexpression;
/* G |- otherSide : var TypeRef otherSideTR */
TypeRef otherSideTR = null;
Result<TypeRef> result = typeInternal(G, _trace_, otherSide);
checkAssignableTo(result.getFirst(), TypeRef.class);
otherSideTR = (TypeRef) result.getFirst();
boolean _and = false;
/* G |- otherSideTR <: primsTR */
boolean _ruleinvocation = subtypeSucceeded(G, _trace_, otherSideTR, primsTR);
if (!_ruleinvocation) {
_and = false;
} else {
/* G |- otherSideTR <: G.nullTypeRef */
ParameterizedTypeRef _nullTypeRef = RuleEnvironmentExtensions.nullTypeRef(G);
boolean _ruleinvocation_1 = subtypeSucceeded(G, _trace_, otherSideTR, _nullTypeRef);
boolean _not = (!_ruleinvocation_1);
_and = _not;
}
if (_and) {
T = otherSideTR;
} else {
T = primsTR;
}
} else {
T = RuleEnvironmentExtensions.anyTypeRef(G);
}
break;
}
} else {
boolean _isTypeAware_1 = this.jsVariantHelper.isTypeAware(e);
if (_isTypeAware_1) {
final UnionTypeExpression primsTR = TypeUtils.createNonSimplifiedUnionType(RuleEnvironmentExtensions.numberTypeRef(G), RuleEnvironmentExtensions.stringTypeRef(G), RuleEnvironmentExtensions.booleanTypeRef(G));
Expression _xifexpression = null;
Expression _lhs = e.getLhs();
boolean _tripleEquals_2 = (expression == _lhs);
if (_tripleEquals_2) {
_xifexpression = e.getRhs();
} else {
_xifexpression = e.getLhs();
}
final Expression otherSide = _xifexpression;
/* G |- otherSide : var TypeRef otherSideTR */
TypeRef otherSideTR = null;
Result<TypeRef> result = typeInternal(G, _trace_, otherSide);
checkAssignableTo(result.getFirst(), TypeRef.class);
otherSideTR = (TypeRef) result.getFirst();
boolean _and = false;
/* G |- otherSideTR <: primsTR */
boolean _ruleinvocation = subtypeSucceeded(G, _trace_, otherSideTR, primsTR);
if (!_ruleinvocation) {
_and = false;
} else {
/* G |- otherSideTR <: G.nullTypeRef */
ParameterizedTypeRef _nullTypeRef = RuleEnvironmentExtensions.nullTypeRef(G);
boolean _ruleinvocation_1 = subtypeSucceeded(G, _trace_, otherSideTR, _nullTypeRef);
boolean _not = (!_ruleinvocation_1);
_and = _not;
}
if (_and) {
T = otherSideTR;
} else {
T = primsTR;
}
} else {
T = RuleEnvironmentExtensions.anyTypeRef(G);
}
}
return new Result<TypeRef>(T);
}
Aggregations