List of usage examples for org.eclipse.jdt.internal.compiler.codegen CodeStream generateUnboxingConversion
public void generateUnboxingConversion(int unboxedTypeID)
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.TSuperMessageSend.java
License:Open Source License
@Override public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { // for code gen we need to add the marker arg... int len = this.binding.parameters.length; TypeBinding[] extendedParameters = new TypeBinding[len + 1]; System.arraycopy(this.binding.parameters, 0, extendedParameters, 0, len); char[] tSuperMarkName = TSuperHelper.getTSuperMarkName(this.tsuperReference.resolvedType.enclosingType()); extendedParameters[len] = currentScope.getType(tSuperMarkName); // ... and find the copied method binding MethodBinding codegenBinding = currentScope.getMethod(this.actualReceiverType, this.selector, extendedParameters, this); if (codegenBinding.problemId() == ProblemReasons.NotFound) { // tsuper.m() may in fact refer to tsuper.super.m(). // try to find the method as super.tsuper() instead: ReferenceBinding superRole = ((ReferenceBinding) this.receiver.resolvedType).superclass(); codegenBinding = getAlternateMethod(currentScope, superRole, extendedParameters); if (codegenBinding == null) codegenBinding = getAlternateMethod(currentScope, superRole, this.binding.parameters); if (codegenBinding == null) throw new InternalCompilerError("cannot find real method binding for tsuper call!"); //$NON-NLS-1$ this.receiver = new SuperReference(this.receiver.sourceStart, this.receiver.sourceEnd); this.receiver.resolvedType = superRole; this.receiver.constant = Constant.NotAConstant; this.actualReceiverType = superRole; }/*from w w w . j a v a 2 s .co m*/ MethodBinding tsuperMethod = this.binding; this.binding = codegenBinding; try { super.generateCode(currentScope, codeStream, valueRequired); } finally { this.binding = tsuperMethod; } if (valueRequired && this.binding.isCallin()) { if (this.resolvedType != null && this.resolvedType.isValidBinding()) { if (this.resolvedType.isBaseType()) { // something like: ((Integer)result).intValue() char[][] boxtypeName = AstGenerator.boxTypeName((BaseTypeBinding) this.resolvedType); codeStream.checkcast(currentScope.getType(boxtypeName, 3)); codeStream.generateUnboxingConversion(this.resolvedType.id); } else { // (RefType)result codeStream.checkcast(this.resolvedType); } } } }