use of org.eclipse.xsemantics.runtime.RuleFailedException in project n4js by eclipse.
the class InternalTypeSystem method applyRuleTypeSuperLiteral.
protected Result<TypeRef> applyRuleTypeSuperLiteral(final RuleEnvironment G, final RuleApplicationTrace _trace_, final SuperLiteral superLiteral) throws RuleFailedException {
// output parameter
TypeRef T = null;
final N4MemberDeclaration containingMemberDecl = EcoreUtil2.<N4MemberDeclaration>getContainerOfType(superLiteral.eContainer(), N4MemberDeclaration.class);
/* if (containingMemberDecl === null) { T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef } else { val containingClass = (containingMemberDecl.eContainer as N4ClassDeclaration).definedType as TClass; val superClass = G.getDeclaredOrImplicitSuperType(containingClass) var effectiveSuperClass = superClass if( containingClass.isStaticPolyfill ) { effectiveSuperClass = G.getDeclaredOrImplicitSuperType( superClass as TClass ) } { superLiteral.eContainer instanceof ParameterizedPropertyAccessExpression || superLiteral.eContainer instanceof IndexedAccessExpression if(containingMemberDecl.static) T = effectiveSuperClass?.createConstructorTypeRef else T = effectiveSuperClass?.createTypeRef if (T !== null) T = TypeUtils.enforceNominalTyping(T) } or { superLiteral.eContainer instanceof ParameterizedCallExpression if(containingMemberDecl instanceof N4MethodDeclaration && containingMemberDecl.name == 'constructor') { val ctor = containerTypesHelper.fromContext(superLiteral.eResource).findConstructor(effectiveSuperClass); T = ctor?.createTypeRef } else { T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef } } or { superLiteral.eContainer instanceof NewExpression } } or { T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef } */
{
RuleFailedException previousFailure = null;
try {
if ((containingMemberDecl == null)) {
T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef();
} else {
EObject _eContainer = containingMemberDecl.eContainer();
Type _definedType = ((N4ClassDeclaration) _eContainer).getDefinedType();
final TClass containingClass = ((TClass) _definedType);
final TClassifier superClass = RuleEnvironmentExtensions.getDeclaredOrImplicitSuperType(G, containingClass);
TClassifier effectiveSuperClass = superClass;
boolean _isStaticPolyfill = containingClass.isStaticPolyfill();
if (_isStaticPolyfill) {
effectiveSuperClass = RuleEnvironmentExtensions.getDeclaredOrImplicitSuperType(G, ((TClass) superClass));
}
/* { superLiteral.eContainer instanceof ParameterizedPropertyAccessExpression || superLiteral.eContainer instanceof IndexedAccessExpression if(containingMemberDecl.static) T = effectiveSuperClass?.createConstructorTypeRef else T = effectiveSuperClass?.createTypeRef if (T !== null) T = TypeUtils.enforceNominalTyping(T) } or { superLiteral.eContainer instanceof ParameterizedCallExpression if(containingMemberDecl instanceof N4MethodDeclaration && containingMemberDecl.name == 'constructor') { val ctor = containerTypesHelper.fromContext(superLiteral.eResource).findConstructor(effectiveSuperClass); T = ctor?.createTypeRef } else { T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef } } or { superLiteral.eContainer instanceof NewExpression } */
{
try {
/* superLiteral.eContainer instanceof ParameterizedPropertyAccessExpression || superLiteral.eContainer instanceof IndexedAccessExpression */
if (!((superLiteral.eContainer() instanceof ParameterizedPropertyAccessExpression) || (superLiteral.eContainer() instanceof IndexedAccessExpression))) {
sneakyThrowRuleFailedException("superLiteral.eContainer instanceof ParameterizedPropertyAccessExpression || superLiteral.eContainer instanceof IndexedAccessExpression");
}
boolean _isStatic = containingMemberDecl.isStatic();
if (_isStatic) {
TypeRef _createConstructorTypeRef = null;
if (effectiveSuperClass != null) {
_createConstructorTypeRef = TypeUtils.createConstructorTypeRef(effectiveSuperClass);
}
T = _createConstructorTypeRef;
} else {
ParameterizedTypeRef _createTypeRef = null;
if (effectiveSuperClass != null) {
_createTypeRef = TypeUtils.createTypeRef(effectiveSuperClass);
}
T = _createTypeRef;
}
if ((T != null)) {
T = TypeUtils.enforceNominalTyping(T);
}
} catch (Exception e) {
previousFailure = extractRuleFailedException(e);
/* { superLiteral.eContainer instanceof ParameterizedCallExpression if(containingMemberDecl instanceof N4MethodDeclaration && containingMemberDecl.name == 'constructor') { val ctor = containerTypesHelper.fromContext(superLiteral.eResource).findConstructor(effectiveSuperClass); T = ctor?.createTypeRef } else { T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef } } or { superLiteral.eContainer instanceof NewExpression } */
{
try {
EObject _eContainer_1 = superLiteral.eContainer();
/* superLiteral.eContainer instanceof ParameterizedCallExpression */
if (!(_eContainer_1 instanceof ParameterizedCallExpression)) {
sneakyThrowRuleFailedException("superLiteral.eContainer instanceof ParameterizedCallExpression");
}
if (((containingMemberDecl instanceof N4MethodDeclaration) && Objects.equal(containingMemberDecl.getName(), "constructor"))) {
final TMethod ctor = this.containerTypesHelper.fromContext(superLiteral.eResource()).findConstructor(effectiveSuperClass);
ParameterizedTypeRef _createTypeRef_1 = null;
if (ctor != null) {
_createTypeRef_1 = TypeUtils.createTypeRef(ctor);
}
T = _createTypeRef_1;
} else {
T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef();
}
} catch (Exception e_1) {
previousFailure = extractRuleFailedException(e_1);
EObject _eContainer_2 = superLiteral.eContainer();
/* superLiteral.eContainer instanceof NewExpression */
if (!(_eContainer_2 instanceof NewExpression)) {
sneakyThrowRuleFailedException("superLiteral.eContainer instanceof NewExpression");
}
}
}
}
}
}
} catch (Exception e_2) {
previousFailure = extractRuleFailedException(e_2);
T = TypeRefsFactory.eINSTANCE.createUnknownTypeRef();
}
}
return new Result<TypeRef>(T);
}
use of org.eclipse.xsemantics.runtime.RuleFailedException in project n4js by eclipse.
the class InternalTypeSystem method typeImpl.
protected Result<TypeRef> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final PromisifyExpression e) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeRef> _result_ = applyRuleTypePromisifyExpression(G, _subtrace_, e);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("typePromisifyExpression") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleTypePromisifyExpression) {
typeThrowException(ruleName("typePromisifyExpression") + stringRepForEnv(G) + " |- " + stringRep(e) + " : " + "TypeRef", TYPEPROMISIFYEXPRESSION, e_applyRuleTypePromisifyExpression, e, new ErrorInformation[] { new ErrorInformation(e) });
return null;
}
}
use of org.eclipse.xsemantics.runtime.RuleFailedException in project n4js by eclipse.
the class InternalTypeSystem method expectedTypeInImpl.
protected Result<TypeRef> expectedTypeInImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final Argument argument, final Expression argumentExpression) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeRef> _result_ = applyRuleExpectedTypeOfArgument(G, _subtrace_, argument, argumentExpression);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("expectedTypeOfArgument") + stringRepForEnv(G) + " |- " + stringRep(argument) + " |> " + stringRep(argumentExpression) + " : " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleExpectedTypeOfArgument) {
expectedTypeInThrowException(ruleName("expectedTypeOfArgument") + stringRepForEnv(G) + " |- " + stringRep(argument) + " |> " + stringRep(argumentExpression) + " : " + "TypeRef", EXPECTEDTYPEOFARGUMENT, e_applyRuleExpectedTypeOfArgument, argument, argumentExpression, new ErrorInformation[] { new ErrorInformation(argument), new ErrorInformation(argumentExpression) });
return null;
}
}
use of org.eclipse.xsemantics.runtime.RuleFailedException in project n4js by eclipse.
the class InternalTypeSystem method typeImpl.
protected Result<TypeRef> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final StringLiteral l) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeRef> _result_ = applyRuleTypeStringLiteral(G, _subtrace_, l);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("typeStringLiteral") + stringRepForEnv(G) + " |- " + stringRep(l) + " : " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleTypeStringLiteral) {
typeThrowException(ruleName("typeStringLiteral") + stringRepForEnv(G) + " |- " + stringRep(l) + " : " + "ParameterizedTypeRef", TYPESTRINGLITERAL, e_applyRuleTypeStringLiteral, l, new ErrorInformation[] { new ErrorInformation(l) });
return null;
}
}
use of org.eclipse.xsemantics.runtime.RuleFailedException in project n4js by eclipse.
the class InternalTypeSystem method typeImpl.
protected Result<TypeRef> typeImpl(final RuleEnvironment G, final RuleApplicationTrace _trace_, final CatchVariable catchVariable) throws RuleFailedException {
try {
final RuleApplicationTrace _subtrace_ = newTrace(_trace_);
final Result<TypeRef> _result_ = applyRuleTypeCatchVariable(G, _subtrace_, catchVariable);
addToTrace(_trace_, new Provider<Object>() {
public Object get() {
return ruleName("typeCatchVariable") + stringRepForEnv(G) + " |- " + stringRep(catchVariable) + " : " + stringRep(_result_.getFirst());
}
});
addAsSubtrace(_trace_, _subtrace_);
return _result_;
} catch (Exception e_applyRuleTypeCatchVariable) {
typeThrowException(ruleName("typeCatchVariable") + stringRepForEnv(G) + " |- " + stringRep(catchVariable) + " : " + "ParameterizedTypeRef", TYPECATCHVARIABLE, e_applyRuleTypeCatchVariable, catchVariable, new ErrorInformation[] { new ErrorInformation(catchVariable) });
return null;
}
}
Aggregations