public void arrayAt(int typeBindingID) { switch (typeBindingID) { case TypeIds.T_int : iaload(); break; case TypeIds.T_byte : case TypeIds.T_boolean : baload(); break; case TypeIds.T_short : saload(); break; case TypeIds.T_char : caload(); break; case TypeIds.T_long : laload(); break; case TypeIds.T_float : faload(); break; case TypeIds.T_double : daload(); break; default : aaload(); } }
case TypeIds.T_int : if (valueRequired) dup_x2(); iastore(); break; case TypeIds.T_byte : case TypeIds.T_boolean : if (valueRequired) dup_x2(); bastore(); break; case TypeIds.T_short : if (valueRequired) dup_x2(); sastore(); break; case TypeIds.T_char : if (valueRequired) dup_x2(); castore(); break; case TypeIds.T_long : if (valueRequired) dup2_x2(); lastore(); break; case TypeIds.T_float : if (valueRequired) dup_x2();
/** * Code generation for the null literal * * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream * @param valueRequired boolean */ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { int pc = codeStream.position; if (valueRequired) { codeStream.aconst_null(); codeStream.generateImplicitConversion(this.implicitConversion); } codeStream.recordPositionsFrom(pc, this.sourceStart); } public TypeBinding literalType(BlockScope scope) {
@Override public void generateReceiver(CodeStream codeStream) { codeStream.aload_0(); if (this.delegateThis != null) { codeStream.fieldAccess(Opcodes.OPC_getfield, this.delegateThis, null /* default declaringClass */); // delegated field access } }
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { int pc = codeStream.position; if (valueRequired) codeStream.aload_0(); if ((this.bits & IsImplicitThis) == 0) codeStream.recordPositionsFrom(pc, this.sourceStart); }
public void generateStoreSaveValueIfNecessary(CodeStream codeStream){ if (this.saveValueVariable != null) { codeStream.store(this.saveValueVariable, false); // the variable is visible as soon as the local is stored codeStream.addVariable(this.saveValueVariable); } }
this.ldc(String.valueOf(methodBinding.declaringClass.constantPoolName()).replace('/', '.')); invokeClassForName(); int paramLength = methodBinding.parameters.length; this.generateInlinedValue(paramLength); newArray(scope.createArrayType(scope.getType(TypeConstants.JAVA_LANG_CLASS, 3), 1)); if (paramLength > 0) { dup(); for (int i = 0; i < paramLength; i++) { this.generateInlinedValue(i); TypeBinding parameter = methodBinding.parameters[i]; if (parameter.isBaseType()) { getTYPE(parameter.id); } else if (parameter.isArrayType()) { ArrayBinding array = (ArrayBinding)parameter; if (array.leafComponentType.isBaseType()) { getTYPE(array.leafComponentType.id); } else { this.ldc(String.valueOf(array.leafComponentType.constantPoolName()).replace('/', '.')); invokeClassForName(); this.generateInlinedValue(dimensions); newarray(TypeIds.T_int); invokeArrayNewInstance(); invokeObjectGetClass(); } else { this.ldc(String.valueOf(methodBinding.declaringClass.constantPoolName()).replace('/', '.')); invokeClassForName();
public void generateSyntheticBodyForSwitchTable(SyntheticMethodBinding methodBinding) { ClassScope scope = ((SourceTypeBinding)methodBinding.declaringClass).scope; initializeMaxLocals(methodBinding); final BranchLabel nullLabel = new BranchLabel(this); FieldBinding syntheticFieldBinding = methodBinding.targetReadField; fieldAccess(Opcodes.OPC_getstatic, syntheticFieldBinding, null /* default declaringClass */); dup(); ifnull(nullLabel); areturn(); pushOnStack(syntheticFieldBinding.type); nullLabel.place(); pop(); ReferenceBinding enumBinding = (ReferenceBinding) methodBinding.targetEnumType; ArrayBinding arrayBinding = scope.createArrayType(enumBinding, 1); invokeJavaLangEnumValues(enumBinding, arrayBinding); arraylength(); newarray(ClassFileConstants.INT_ARRAY); astore_0(); LocalVariableBinding localVariableBinding = new LocalVariableBinding(" tab".toCharArray(), scope.createArrayType(TypeBinding.INT, 1), 0, false); //$NON-NLS-1$ addVariable(localVariableBinding); final FieldBinding[] fields = enumBinding.fields(); if (fields != null) { final ExceptionLabel anyExceptionHandler = new ExceptionLabel(this, TypeBinding.LONG /* represents NoSuchFieldError*/); anyExceptionHandler.placeStart(); aload_0(); fieldAccess(Opcodes.OPC_getstatic, fieldBinding, null /* default declaringClass */); invokeEnumOrdinal(enumBinding.constantPoolName()); this.generateInlinedValue(fieldBinding.id + 1); // zero should not be returned see bug 141810 iastore();
codeStream.addVisibleLocalVariable(this.binding); && ((this.initialization instanceof CastExpression) // arrayLoc = (type[])null && (((CastExpression)this.initialization).innermostCastedExpression().resolvedType == TypeBinding.NULL))){ codeStream.checkcast(this.binding.type); codeStream.store(this.binding, false); if ((this.bits & ASTNode.FirstAssignmentToLocal) != 0) { codeStream.recordPositionsFrom(pc, this.sourceStart);
classFile.generateCodeAttributeHeader(); CodeStream codeStream = classFile.codeStream; codeStream.reset(this, classFile); for (int i = 0, max = this.arguments.length; i < max; i++) { LocalVariableBinding argBinding; codeStream.addVisibleLocalVariable(argBinding = this.arguments[i].binding); argBinding.recordInitializationStartPC(0); codeStream.return_(); codeStream.exitUserScope(this.scope); codeStream.recordPositionsFrom(0, this.declarationSourceEnd); classFile.completeCodeAttribute(codeAttributeOffset); attributeNumber++;
public void place() { if ((this.tagBits & USED) != 0) { this.position = this.codeStream.getPosition(); } else { this.position = this.codeStream.position; } if (this.instructionPosition != POS_NOT_SET) { int offset = this.position - this.instructionPosition; int[] forwardRefs = forwardReferences(); for (int i = 0, length = forwardReferenceCount(); i < length; i++) { this.codeStream.writeSignedWord(forwardRefs[i], offset); } // add the label in the codeStream labels collection this.codeStream.addLabel(this); } }
/** * Code generation for labeled statement * * may not need actual source positions recording * * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream */ public void generateCode(BlockScope currentScope, CodeStream codeStream) { if ((this.bits & IsReachable) == 0) { return; } int pc = codeStream.position; if (this.targetLabel != null) { this.targetLabel.initialize(codeStream); if (this.statement != null) { this.statement.generateCode(currentScope, codeStream); } this.targetLabel.place(); } // May loose some local variable initializations : affecting the local variable attributes if (this.mergedInitStateIndex != -1) { codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.mergedInitStateIndex); codeStream.addDefinitelyAssignedVariables(currentScope, this.mergedInitStateIndex); } codeStream.recordPositionsFrom(pc, this.sourceStart); }
public void generateSyntheticBodyForEnumValueOf(SyntheticMethodBinding methodBinding) { initializeMaxLocals(methodBinding); final ReferenceBinding declaringClass = methodBinding.declaringClass; generateClassLiteralAccessForType(declaringClass, null); aload_0(); invokeJavaLangEnumvalueOf(declaringClass); this.checkcast(declaringClass); areturn(); }
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { int pc = codeStream.position; if (valueRequired) { codeStream.aload_0(); codeStream.fieldAccess(Opcodes.OPC_getfield, this.delegateThis, null /* default declaringClass */); // delegate field access } codeStream.recordPositionsFrom(pc, this.sourceStart); }
public ClassFile(SourceTypeBinding typeBinding) { // default constructor for subclasses this.constantPool = new ConstantPool(this); final CompilerOptions options = typeBinding.scope.compilerOptions(); this.targetJDK = options.targetJDK; this.produceAttributes = options.produceDebugAttributes; this.referenceBinding = typeBinding; this.isNestedType = typeBinding.isNestedType(); if (this.targetJDK >= ClassFileConstants.JDK1_6) { this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP_TABLE; this.codeStream = new StackMapFrameCodeStream(this); } else if (this.targetJDK == ClassFileConstants.CLDC_1_1) { this.targetJDK = ClassFileConstants.JDK1_1; // put back 45.3 this.produceAttributes |= ClassFileConstants.ATTR_STACK_MAP; this.codeStream = new StackMapFrameCodeStream(this); } else { this.codeStream = new CodeStream(this); } initByteArrays(); }
this.ldc(String.valueOf(methodBinding.declaringClass.constantPoolName()).replace('/', '.')); invokeClassForName(); int paramLength = methodBinding.parameters.length; this.generateInlinedValue(paramLength); newArray(scope.createArrayType(scope.getType(TypeConstants.JAVA_LANG_CLASS, 3), 1)); if (paramLength > 0) { dup(); for (int i = 0; i < paramLength; i++) { this.generateInlinedValue(i); TypeBinding parameter = methodBinding.parameters[i]; if (parameter.isBaseType()) { getTYPE(parameter.id); } else if (parameter.isArrayType()) { ArrayBinding array = (ArrayBinding)parameter; if (array.leafComponentType.isBaseType()) { getTYPE(array.leafComponentType.id); } else { this.ldc(String.valueOf(array.leafComponentType.constantPoolName()).replace('/', '.')); invokeClassForName(); this.generateInlinedValue(dimensions); newarray(TypeIds.T_int); invokeArrayNewInstance(); invokeObjectGetClass(); } else { this.ldc(String.valueOf(methodBinding.declaringClass.constantPoolName()).replace('/', '.')); invokeClassForName();
public void generateSyntheticBodyForSwitchTable(SyntheticMethodBinding methodBinding) { ClassScope scope = ((SourceTypeBinding)methodBinding.declaringClass).scope; initializeMaxLocals(methodBinding); final BranchLabel nullLabel = new BranchLabel(this); FieldBinding syntheticFieldBinding = methodBinding.targetReadField; fieldAccess(Opcodes.OPC_getstatic, syntheticFieldBinding, null /* default declaringClass */); dup(); ifnull(nullLabel); areturn(); pushOnStack(syntheticFieldBinding.type); nullLabel.place(); pop(); ReferenceBinding enumBinding = (ReferenceBinding) methodBinding.targetEnumType; ArrayBinding arrayBinding = scope.createArrayType(enumBinding, 1); invokeJavaLangEnumValues(enumBinding, arrayBinding); arraylength(); newarray(ClassFileConstants.INT_ARRAY); astore_0(); LocalVariableBinding localVariableBinding = new LocalVariableBinding(" tab".toCharArray(), scope.createArrayType(TypeBinding.INT, 1), 0, false); //$NON-NLS-1$ addVariable(localVariableBinding); final FieldBinding[] fields = enumBinding.fields(); if (fields != null) { final ExceptionLabel anyExceptionHandler = new ExceptionLabel(this, TypeBinding.LONG /* represents NoSuchFieldError*/); anyExceptionHandler.placeStart(); aload_0(); fieldAccess(Opcodes.OPC_getstatic, fieldBinding, null /* default declaringClass */); invokeEnumOrdinal(enumBinding.constantPoolName()); this.generateInlinedValue(fieldBinding.id + 1); // zero should not be returned see bug 141810 iastore();
codeStream.addVisibleLocalVariable(this.binding); && ((this.initialization instanceof CastExpression) // arrayLoc = (type[])null && (((CastExpression)this.initialization).innermostCastedExpression().resolvedType == TypeBinding.NULL))){ codeStream.checkcast(this.binding.type); codeStream.store(this.binding, false); if ((this.bits & ASTNode.FirstAssignmentToLocal) != 0) { codeStream.recordPositionsFrom(pc, this.sourceStart);
classFile.generateCodeAttributeHeader(); CodeStream codeStream = classFile.codeStream; codeStream.reset(this, classFile); for (int i = 0, max = this.arguments.length; i < max; i++) { LocalVariableBinding argBinding; codeStream.addVisibleLocalVariable(argBinding = this.arguments[i].binding); argBinding.recordInitializationStartPC(0); codeStream.return_(); codeStream.exitUserScope(this.scope); codeStream.recordPositionsFrom(0, this.declarationSourceEnd); try { classFile.completeCodeAttribute(codeAttributeOffset);
public void place() { if ((this.tagBits & USED) != 0) { this.position = this.codeStream.getPosition(); } else { this.position = this.codeStream.position; } if (this.instructionPosition != POS_NOT_SET) { int offset = this.position - this.instructionPosition; int[] forwardRefs = forwardReferences(); for (int i = 0, length = forwardReferenceCount(); i < length; i++) { this.codeStream.writeSignedWord(forwardRefs[i], offset); } // add the label in the codeStream labels collection this.codeStream.addLabel(this); } }