Class TryCatchFinallyStatementTransformer
java.lang.Object
gw.internal.gosu.ir.transform.AbstractElementTransformer<T>
gw.internal.gosu.ir.transform.statement.AbstractStatementTransformer<TryCatchFinallyStatement>
gw.internal.gosu.ir.transform.statement.TryCatchFinallyStatementTransformer
public class TryCatchFinallyStatementTransformer
extends AbstractStatementTransformer<TryCatchFinallyStatement>
-
Field Summary
Fields inherited from class gw.internal.gosu.ir.transform.AbstractElementTransformer
CAPTURED_VAR_PREFIX, CTX_SYMBOL, CTX_SYMBOL_SUFFIX, CUSTOM_RUNTIMES, EMPTY_CLASS_ARRAY, ENHANCEMENT_THIS_REF, ENHANCEMENT_TYPE_PARAM_PREFIX, ENUM_PARAM_PREFIX, OBJECT_TYPE, OUTER_ACCESS, TYPE_PARAM_PREFIX
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprivate
TryCatchFinallyStatementTransformer
(TopLevelTransformationContext cc, TryCatchFinallyStatement stmt) -
Method Summary
Modifier and TypeMethodDescriptionprivate IRStatement
assignCatchClauseSymbol
(IRSymbol genericCatchSymbol, String expectedName, IType expectedType, boolean isBoxed) private IRStatement
boxCatchSymbol
(IRType componentType, String properName, IRExpression rootValue) static IRStatement
protected IRStatement
private List<IRCatchClause>
private void
compileOtherCatchStatements
(TopLevelTransformationContext cc, List<CatchClause> otherCatches, List<IRCatchClause> resultingClauses) Handle case where a catch clause declares a non-bytecode exception type e.g., soap exception type.private IRSymbol
createCatchClauseSymbol
(Symbol symbol, IType type) private IRStatement
reassignCatchSymbol
(IRType symbolType, String properName, IRExpression rootValue) private IRExpression
wrapCatchSymbol
(IRExpression rootValue) private boolean
wrapInEvalException
(IType type) private IRStatement
wrapUndeclaredAsEvaluationException
(IRSymbol catchSymbol, String properName, boolean isBoxed) Methods inherited from class gw.internal.gosu.ir.transform.statement.AbstractStatementTransformer
_stmt, compile, visitStatementLineNumber, visitStatementLineNumber
Methods inherited from class gw.internal.gosu.ir.transform.AbstractElementTransformer
_cc, assignStructuralTypeOwner, avoidVerifyError, booleanLiteral, boxValue, boxValue, boxValueToType, buildAddition, buildArithmetic, buildArrayLength, buildArrayLoad, buildArrayLoad, buildArrayStore, buildAssignment, buildCast, buildComposite, buildComposite, buildEquals, buildFieldGet, buildFieldSet, buildGreaterThan, buildIf, buildIfElse, buildInitializedArray, buildMethodCall, buildMethodCall, buildMethodCall, buildNegation, buildNewExpression, buildNewExpression, buildNewExpression, buildNotEquals, buildNullCheckTernary, buildReturn, buildSubtraction, buildTernary, buildThrow, callMethod, callMethod, callMethod, callMethod, callMethod, callSpecialMethod, callSpecialMethod, callSpecialMethod, callStaticMethod, castResultingTypeIfNecessary, charLiteral, checkCast, checkCast, checkCast, classLiteral, classLiteral, classLiteral, clearCustomRuntimes, collectArgsIntoObjArray, convertBoxedNullToPrimitive, convertNullToPrimitive, convertOperandToBig, convertOperandToPrimitive, convertOperandToRational, exprList, fastStringCoercion, findComparableParamType, findDimensionType, getActualPropertyInfo, getCapturedSymbolParameterName, getClassInfos, getConcreteType, getConstructorParamTypes, getCustomRuntime, getDeclaredField, getDeclaredFieldImpl, getDeclaredMethod, getDeclaredMethod, getDefaultConstIns, getDescriptor, getDescriptor, getDescriptor, getDescriptor, getEnclosingDFS, getField, getField_new, getGosuClass, getInstanceField, getIRTypes, getIRTypes, getModifiers, getParsedElement, getRuntimeEnclosingType, getStaticField, getTypes, getTypeVarParamName, getTypeVarsForDFS, handleCustomExpressionRuntime, handleNamedArgs, identifier, initLocalVar, initLocalVarWithDefault, initMultiArray, inStaticContext, isBigType, isBoxedIntType, isBytecodeType, isBytecodeType, isCheckedArithmeticEnabled, isCompilingEnhancement, isEnhancementType, isEvalProgram, isExecuteMethod, isHandledByCustomCoercion, isIntType, isMemberOnEnclosingType, isMemberOnEnhancementOfEnclosingType, isNonBigBoxedNumberType, isNonStaticInnerClass, isNumberType, isPrimitiveNumberType, isProgram, isProgramOrEnclosedInProgram, makeAnnotationInfos, makeArrayViaTypeInfo, makeEmptyArrayViaTypeInfo, makeIRSymbol, maybeUnwrapMetaType, newArray, nullCheckVar, nullLiteral, numberConvert, numberConvert, numericLiteral, pushArrayOfDefValueExpr, pushArrayOfString, pushArrayOfTypes, pushCapturedSymbols, pushConstant, pushEnumSuperConstructorArguments, pushExternalSymbolsMap, pushLazyType, pushLazyType, pushNull, pushOuter, pushOuter, pushOuter, pushParamTypes, pushRuntimeTypeOfTypeVar, pushString, pushThis, pushThisOrOuter, pushType, pushType, pushTypeParametersForConstructor, requiresExternalSymbolCapture, requiresImplicitEnhancementArg, requiresImplicitEnhancementArg, setCc, setField, setField, setInstanceField, setStaticField, stringLiteral, unboxValueFromType, unboxValueToType, unboxValueToType, valueOf
-
Constructor Details
-
TryCatchFinallyStatementTransformer
private TryCatchFinallyStatementTransformer(TopLevelTransformationContext cc, TryCatchFinallyStatement stmt)
-
-
Method Details
-
compile
-
compile_impl
- Specified by:
compile_impl
in classAbstractStatementTransformer<TryCatchFinallyStatement>
-
compileCatchStatements
-
wrapInEvalException
-
createCatchClauseSymbol
-
wrapUndeclaredAsEvaluationException
private IRStatement wrapUndeclaredAsEvaluationException(IRSymbol catchSymbol, String properName, boolean isBoxed) -
compileOtherCatchStatements
private void compileOtherCatchStatements(TopLevelTransformationContext cc, List<CatchClause> otherCatches, List<IRCatchClause> resultingClauses) Handle case where a catch clause declares a non-bytecode exception type e.g., soap exception type. In such a case the catch clause and all subsequent catch clauses must be handled in a single catch-clause for Throwable. If none of the subsequent catch clauses handle Throwable explicitly and none of the clauses field the exception, it is rethrown. Note if a 'default' catch clause is declard (i.e. a JavaScript-style catch clause with no exception type declared), it is treated as handling Throwable explicitly; in other words no code is generated to rethrow the exception.For example, the following try-catch statement declares a soap exception, which is not really a valid Java exception type. It's a simple case with no finally clause and no default catch, but it illustrates the essence of the problem.
try { doSomething() } catch( re : RuntimeException ) { print( "RuntimeException" ) } catch( fake : DoesntActuallyExtendThrowable ) { print( "DoesntActuallyExtendThrowable" ) } catch( e : RealException ) { print( "RealException" ) }
We must treat this statement as the following (simplified) code:try { doSomething() } catch( re : RuntimeException ) { print( "RuntimeException" ) } catch( t : Throwable ) { var rtt = TypeSystem.getFromObject( t ) if( DoesntActuallyExtendThrowable.Type.isAssignableFrom( rtt ) ) { print( "DoesntActuallyExtendThrowable" ) } if( RealException.Type.isAssignableFrom( rtt ) ) { print( "RealException" ) } else { throw t } }
-
assignCatchClauseSymbol
private IRStatement assignCatchClauseSymbol(IRSymbol genericCatchSymbol, String expectedName, IType expectedType, boolean isBoxed) -
reassignCatchSymbol
private IRStatement reassignCatchSymbol(IRType symbolType, String properName, IRExpression rootValue) -
wrapCatchSymbol
-
boxCatchSymbol
-