1 /*******************************************************************************
2  * Copyright (c) 2000, 2004 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  *
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.codegen;
12 
13 import org.eclipse.jdt.internal.compiler.*;
14 
15 import org.eclipse.jdt.internal.compiler.impl.*;
16 import org.eclipse.jdt.internal.compiler.ast.*;
17 import org.eclipse.jdt.internal.compiler.classfmt.*;
18 import org.eclipse.jdt.internal.compiler.flow.*;
19 import org.eclipse.jdt.internal.compiler.lookup.*;
20 
21 public class CodeStream implements OperatorIds, ClassFileConstants, Opcodes, BaseTypes, TypeConstants, TypeIds {
22 
23 	public static final boolean DEBUG = false;
24 
25 	// It will be responsible for the following items.
26 	// -> Tracking Max Stack.
27 
28 	public int stackMax; // Use Ints to keep from using extra bc when adding
29 	public int stackDepth; // Use Ints to keep from using extra bc when adding
30 	public int maxLocals;
31 	public static final int LABELS_INCREMENT = 5;
32 	public byte[] bCodeStream;
33 	public int pcToSourceMapSize;
34 	public int[] pcToSourceMap = new int[24];
35 	public int lastEntryPC; // last entry recorded
36 	public int[] lineSeparatorPositions;
37 	public int position; // So when first set can be incremented
38 	public int classFileOffset;
39 	public int startingClassFileOffset; // I need to keep the starting point inside the byte array
40 	public ConstantPool constantPool; // The constant pool used to generate bytecodes that need to store information into the constant pool
41 	public ClassFile classFile; // The current classfile it is associated to.
42 	// local variable attributes output
43 	public static final int LOCALS_INCREMENT = 10;
44 	public LocalVariableBinding[] locals = new LocalVariableBinding[LOCALS_INCREMENT];
45 	static LocalVariableBinding[] noLocals = new LocalVariableBinding[LOCALS_INCREMENT];
46 	public LocalVariableBinding[] visibleLocals = new LocalVariableBinding[LOCALS_INCREMENT];
47 	static LocalVariableBinding[] noVisibleLocals = new LocalVariableBinding[LOCALS_INCREMENT];
48 	int visibleLocalsCount;
49 	public AbstractMethodDeclaration methodDeclaration;
50 	public ExceptionLabel[] exceptionHandlers = new ExceptionLabel[LABELS_INCREMENT];
51 	static ExceptionLabel[] noExceptionHandlers = new ExceptionLabel[LABELS_INCREMENT];
52 	public int exceptionHandlersIndex;
53 	public int exceptionHandlersCounter;
54 
55 	public static FieldBinding[] ImplicitThis = new FieldBinding[] {};
56 	public boolean generateLineNumberAttributes;
57 	public boolean generateLocalVariableTableAttributes;
58 	public boolean preserveUnusedLocals;
59 	// store all the labels placed at the current position to be able to optimize
60 	// a jump to the next bytecode.
61 	public Label[] labels = new Label[LABELS_INCREMENT];
62 	static Label[] noLabels = new Label[LABELS_INCREMENT];
63 	public int countLabels;
64 	public int allLocalsCounter;
65 	public int maxFieldCount;
66 	// to handle goto_w
67 	public boolean wideMode = false;
68 	public static final CompilationResult RESTART_IN_WIDE_MODE = new CompilationResult((char[])null, 0, 0, 0);
69 
70 	// target level to manage different code generation between different target levels
71 	private long targetLevel;
72 
CodeStream(ClassFile classFile, long targetLevel)73 public CodeStream(ClassFile classFile, long targetLevel) {
74 	this.targetLevel = targetLevel;
75 	this.generateLineNumberAttributes = (classFile.produceDebugAttributes & CompilerOptions.Lines) != 0;
76 	this.generateLocalVariableTableAttributes = (classFile.produceDebugAttributes & CompilerOptions.Vars) != 0;
77 	if (this.generateLineNumberAttributes) {
78 		this.lineSeparatorPositions = classFile.referenceBinding.scope.referenceCompilationUnit().compilationResult.lineSeparatorPositions;
79 	}
80 }
aaload()81 final public void aaload() {
82 	if (DEBUG) System.out.println(position + "\t\taaload"); //$NON-NLS-1$
83 	countLabels = 0;
84 	stackDepth--;
85 	if (classFileOffset >= bCodeStream.length) {
86 		resizeByteArray();
87 	}
88 	position++;
89 	bCodeStream[classFileOffset++] = OPC_aaload;
90 }
aastore()91 final public void aastore() {
92 	if (DEBUG) System.out.println(position + "\t\taastore"); //$NON-NLS-1$
93 	countLabels = 0;
94 	stackDepth -= 3;
95 	if (classFileOffset >= bCodeStream.length) {
96 		resizeByteArray();
97 	}
98 	position++;
99 	bCodeStream[classFileOffset++] = OPC_aastore;
100 }
aconst_null()101 final public void aconst_null() {
102 	if (DEBUG) System.out.println(position + "\t\taconst_null"); //$NON-NLS-1$
103 	countLabels = 0;
104 	stackDepth++;
105 	if (stackDepth > stackMax) {
106 		stackMax = stackDepth;
107 	}
108 	if (classFileOffset >= bCodeStream.length) {
109 		resizeByteArray();
110 	}
111 	position++;
112 	bCodeStream[classFileOffset++] = OPC_aconst_null;
113 }
addDefinitelyAssignedVariables(Scope scope, int initStateIndex)114 public final void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
115 	// Required to fix 1PR0XVS: LFRE:WINNT - Compiler: variable table for method appears incorrect
116 	if (!generateLocalVariableTableAttributes)
117 		return;
118 /*	if (initStateIndex == lastInitStateIndexWhenAddingInits)
119 		return;
120 	lastInitStateIndexWhenAddingInits = initStateIndex;
121 	if (lastInitStateIndexWhenRemovingInits != initStateIndex){
122 		lastInitStateIndexWhenRemovingInits = -2; // reinitialize remove index
123 		// remove(1)-add(1)-remove(1) -> ignore second remove
124 		// remove(1)-add(2)-remove(1) -> perform second remove
125 	}
126 
127 */	for (int i = 0; i < visibleLocalsCount; i++) {
128 		LocalVariableBinding localBinding = visibleLocals[i];
129 		if (localBinding != null) {
130 			// Check if the local is definitely assigned
131 			if ((initStateIndex != -1) && isDefinitelyAssigned(scope, initStateIndex, localBinding)) {
132 				if ((localBinding.initializationCount == 0) || (localBinding.initializationPCs[((localBinding.initializationCount - 1) << 1) + 1] != -1)) {
133 					/* There are two cases:
134 					 * 1) there is no initialization interval opened ==> add an opened interval
135 					 * 2) there is already some initialization intervals but the last one is closed ==> add an opened interval
136 					 * An opened interval means that the value at localBinding.initializationPCs[localBinding.initializationCount - 1][1]
137 					 * is equals to -1.
138 					 * initializationPCs is a collection of pairs of int:
139 					 * 	first value is the startPC and second value is the endPC. -1 one for the last value means that the interval
140 					 * 	is not closed yet.
141 					 */
142 					localBinding.recordInitializationStartPC(position);
143 				}
144 			}
145 		}
146 	}
147 }
addLabel(Label aLabel)148 public void addLabel(Label aLabel) {
149 	if (countLabels == labels.length)
150 		System.arraycopy(labels, 0, labels = new Label[countLabels + LABELS_INCREMENT], 0, countLabels);
151 	labels[countLabels++] = aLabel;
152 }
addVisibleLocalVariable(LocalVariableBinding localBinding)153 public void addVisibleLocalVariable(LocalVariableBinding localBinding) {
154 	if (!generateLocalVariableTableAttributes)
155 		return;
156 
157 	if (visibleLocalsCount >= visibleLocals.length)
158 		System.arraycopy(visibleLocals, 0, visibleLocals = new LocalVariableBinding[visibleLocalsCount * 2], 0, visibleLocalsCount);
159 	visibleLocals[visibleLocalsCount++] = localBinding;
160 }
aload(int iArg)161 final public void aload(int iArg) {
162 	if (DEBUG) System.out.println(position + "\t\taload:"+iArg); //$NON-NLS-1$
163 	countLabels = 0;
164 	stackDepth++;
165 	if (stackDepth > stackMax)
166 		stackMax = stackDepth;
167 	if (maxLocals <= iArg) {
168 		maxLocals = iArg + 1;
169 	}
170 	if (iArg > 255) { // Widen
171 		if (classFileOffset + 3 >= bCodeStream.length) {
172 			resizeByteArray();
173 		}
174 		position += 2;
175 		bCodeStream[classFileOffset++] = OPC_wide;
176 		bCodeStream[classFileOffset++] = OPC_aload;
177 		writeUnsignedShort(iArg);
178 	} else {
179 		// Don't need to use the wide bytecode
180 		if (classFileOffset + 1 >= bCodeStream.length) {
181 			resizeByteArray();
182 		}
183 		position += 2;
184 		bCodeStream[classFileOffset++] = OPC_aload;
185 		bCodeStream[classFileOffset++] = (byte) iArg;
186 	}
187 }
aload_0()188 final public void aload_0() {
189 	if (DEBUG) System.out.println(position + "\t\taload_0"); //$NON-NLS-1$
190 	countLabels = 0;
191 	stackDepth++;
192 	if (stackDepth > stackMax) {
193 		stackMax = stackDepth;
194 	}
195 	if (maxLocals == 0) {
196 		maxLocals = 1;
197 	}
198 	if (classFileOffset >= bCodeStream.length) {
199 		resizeByteArray();
200 	}
201 	position++;
202 	bCodeStream[classFileOffset++] = OPC_aload_0;
203 }
aload_1()204 final public void aload_1() {
205 	if (DEBUG) System.out.println(position + "\t\taload_1"); //$NON-NLS-1$
206 	countLabels = 0;
207 	stackDepth++;
208 	if (stackDepth > stackMax)
209 		stackMax = stackDepth;
210 	if (maxLocals <= 1) {
211 		maxLocals = 2;
212 	}
213 	if (classFileOffset >= bCodeStream.length) {
214 		resizeByteArray();
215 	}
216 	position++;
217 	bCodeStream[classFileOffset++] = OPC_aload_1;
218 }
aload_2()219 final public void aload_2() {
220 	if (DEBUG) System.out.println(position + "\t\taload_2"); //$NON-NLS-1$
221 	countLabels = 0;
222 	stackDepth++;
223 	if (stackDepth > stackMax)
224 		stackMax = stackDepth;
225 	if (maxLocals <= 2) {
226 		maxLocals = 3;
227 	}
228 	if (classFileOffset >= bCodeStream.length) {
229 		resizeByteArray();
230 	}
231 	position++;
232 	bCodeStream[classFileOffset++] = OPC_aload_2;
233 }
aload_3()234 final public void aload_3() {
235 	if (DEBUG) System.out.println(position + "\t\taload_3"); //$NON-NLS-1$
236 	countLabels = 0;
237 	stackDepth++;
238 	if (stackDepth > stackMax)
239 		stackMax = stackDepth;
240 	if (maxLocals <= 3) {
241 		maxLocals = 4;
242 	}
243 	if (classFileOffset >= bCodeStream.length) {
244 		resizeByteArray();
245 	}
246 	position++;
247 	bCodeStream[classFileOffset++] = OPC_aload_3;
248 }
anewarray(TypeBinding typeBinding)249 public final void anewarray(TypeBinding typeBinding) {
250 	if (DEBUG) System.out.println(position + "\t\tanewarray: " + typeBinding); //$NON-NLS-1$
251 	countLabels = 0;
252 	if (classFileOffset + 2 >= bCodeStream.length) {
253 		resizeByteArray();
254 	}
255 	position++;
256 	bCodeStream[classFileOffset++] = OPC_anewarray;
257 	writeUnsignedShort(constantPool.literalIndex(typeBinding));
258 }
areturn()259 final public void areturn() {
260 	if (DEBUG) System.out.println(position + "\t\tareturn"); //$NON-NLS-1$
261 	countLabels = 0;
262 	stackDepth--;
263 	// the stackDepth should be equal to 0
264 	if (classFileOffset >= bCodeStream.length) {
265 		resizeByteArray();
266 	}
267 	position++;
268 	bCodeStream[classFileOffset++] = OPC_areturn;
269 }
arrayAt(int typeBindingID)270 public void arrayAt(int typeBindingID) {
271 	switch (typeBindingID) {
272 		case T_int :
273 			this.iaload();
274 			break;
275 		case T_byte :
276 		case T_boolean :
277 			this.baload();
278 			break;
279 		case T_short :
280 			this.saload();
281 			break;
282 		case T_char :
283 			this.caload();
284 			break;
285 		case T_long :
286 			this.laload();
287 			break;
288 		case T_float :
289 			this.faload();
290 			break;
291 		case T_double :
292 			this.daload();
293 			break;
294 		default :
295 			this.aaload();
296 	}
297 }
arrayAtPut(int elementTypeID, boolean valueRequired)298 public void arrayAtPut(int elementTypeID, boolean valueRequired) {
299 	switch (elementTypeID) {
300 		case T_int :
301 			if (valueRequired)
302 				dup_x2();
303 			iastore();
304 			break;
305 		case T_byte :
306 		case T_boolean :
307 			if (valueRequired)
308 				dup_x2();
309 			bastore();
310 			break;
311 		case T_short :
312 			if (valueRequired)
313 				dup_x2();
314 			sastore();
315 			break;
316 		case T_char :
317 			if (valueRequired)
318 				dup_x2();
319 			castore();
320 			break;
321 		case T_long :
322 			if (valueRequired)
323 				dup2_x2();
324 			lastore();
325 			break;
326 		case T_float :
327 			if (valueRequired)
328 				dup_x2();
329 			fastore();
330 			break;
331 		case T_double :
332 			if (valueRequired)
333 				dup2_x2();
334 			dastore();
335 			break;
336 		default :
337 			if (valueRequired)
338 				dup_x2();
339 			aastore();
340 	}
341 }
arraylength()342 final public void arraylength() {
343 	if (DEBUG) System.out.println(position + "\t\tarraylength"); //$NON-NLS-1$
344 	countLabels = 0;
345 	if (classFileOffset >= bCodeStream.length) {
346 		resizeByteArray();
347 	}
348 	position++;
349 	bCodeStream[classFileOffset++] = OPC_arraylength;
350 }
astore(int iArg)351 final public void astore(int iArg) {
352 	if (DEBUG) System.out.println(position + "\t\tastore:"+iArg); //$NON-NLS-1$
353 	countLabels = 0;
354 	stackDepth--;
355 	if (maxLocals <= iArg) {
356 		maxLocals = iArg + 1;
357 	}
358 	if (iArg > 255) { // Widen
359 		if (classFileOffset + 3 >= bCodeStream.length) {
360 			resizeByteArray();
361 		}
362 		position+=2;
363 		bCodeStream[classFileOffset++] = OPC_wide;
364 		bCodeStream[classFileOffset++] = OPC_astore;
365 		writeUnsignedShort(iArg);
366 	} else {
367 		if (classFileOffset + 1 >= bCodeStream.length) {
368 			resizeByteArray();
369 		}
370 		position+=2;
371 		bCodeStream[classFileOffset++] = OPC_astore;
372 		bCodeStream[classFileOffset++] = (byte) iArg;
373 	}
374 }
astore_0()375 final public void astore_0() {
376 	if (DEBUG) System.out.println(position + "\t\tastore_0"); //$NON-NLS-1$
377 	countLabels = 0;
378 	stackDepth--;
379 	if (maxLocals == 0) {
380 		maxLocals = 1;
381 	}
382 	if (classFileOffset >= bCodeStream.length) {
383 		resizeByteArray();
384 	}
385 	position++;
386 	bCodeStream[classFileOffset++] = OPC_astore_0;
387 }
astore_1()388 final public void astore_1() {
389 	if (DEBUG) System.out.println(position + "\t\tastore_1"); //$NON-NLS-1$
390 	countLabels = 0;
391 	stackDepth--;
392 	if (maxLocals <= 1) {
393 		maxLocals = 2;
394 	}
395 	if (classFileOffset >= bCodeStream.length) {
396 		resizeByteArray();
397 	}
398 	position++;
399 	bCodeStream[classFileOffset++] = OPC_astore_1;
400 }
astore_2()401 final public void astore_2() {
402 	if (DEBUG) System.out.println(position + "\t\tastore_2"); //$NON-NLS-1$
403 	countLabels = 0;
404 	stackDepth--;
405 	if (maxLocals <= 2) {
406 		maxLocals = 3;
407 	}
408 	if (classFileOffset >= bCodeStream.length) {
409 		resizeByteArray();
410 	}
411 	position++;
412 	bCodeStream[classFileOffset++] = OPC_astore_2;
413 }
astore_3()414 final public void astore_3() {
415 	if (DEBUG) System.out.println(position + "\t\tastore_3"); //$NON-NLS-1$
416 	countLabels = 0;
417 	stackDepth--;
418 	if (maxLocals <= 3) {
419 		maxLocals = 4;
420 	}
421 	if (classFileOffset >= bCodeStream.length) {
422 		resizeByteArray();
423 	}
424 	position++;
425 	bCodeStream[classFileOffset++] = OPC_astore_3;
426 }
athrow()427 final public void athrow() {
428 	if (DEBUG) System.out.println(position + "\t\tathrow"); //$NON-NLS-1$
429 	countLabels = 0;
430 	stackDepth--;
431 	if (classFileOffset >= bCodeStream.length) {
432 		resizeByteArray();
433 	}
434 	position++;
435 	bCodeStream[classFileOffset++] = OPC_athrow;
436 }
baload()437 final public void baload() {
438 	if (DEBUG) System.out.println(position + "\t\tbaload"); //$NON-NLS-1$
439 	countLabels = 0;
440 	stackDepth--;
441 	if (classFileOffset >= bCodeStream.length) {
442 		resizeByteArray();
443 	}
444 	position++;
445 	bCodeStream[classFileOffset++] = OPC_baload;
446 }
bastore()447 final public void bastore() {
448 	if (DEBUG) System.out.println(position + "\t\tbastore"); //$NON-NLS-1$
449 	countLabels = 0;
450 	stackDepth -= 3;
451 	if (classFileOffset >= bCodeStream.length) {
452 		resizeByteArray();
453 	}
454 	position++;
455 	bCodeStream[classFileOffset++] = OPC_bastore;
456 }
bipush(byte b)457 final public void bipush(byte b) {
458 	if (DEBUG) System.out.println(position + "\t\tbipush "+b); //$NON-NLS-1$
459 	countLabels = 0;
460 	stackDepth++;
461 	if (stackDepth > stackMax)
462 		stackMax = stackDepth;
463 	if (classFileOffset + 1 >= bCodeStream.length) {
464 		resizeByteArray();
465 	}
466 	position += 2;
467 	bCodeStream[classFileOffset++] = OPC_bipush;
468 	bCodeStream[classFileOffset++] = b;
469 }
caload()470 final public void caload() {
471 	if (DEBUG) System.out.println(position + "\t\tcaload"); //$NON-NLS-1$
472 	countLabels = 0;
473 	stackDepth--;
474 	if (classFileOffset >= bCodeStream.length) {
475 		resizeByteArray();
476 	}
477 	position++;
478 	bCodeStream[classFileOffset++] = OPC_caload;
479 }
castore()480 final public void castore() {
481 	if (DEBUG) System.out.println(position + "\t\tcastore"); //$NON-NLS-1$
482 	countLabels = 0;
483 	stackDepth -= 3;
484 	if (classFileOffset >= bCodeStream.length) {
485 		resizeByteArray();
486 	}
487 	position++;
488 	bCodeStream[classFileOffset++] = OPC_castore;
489 }
checkcast(TypeBinding typeBinding)490 public final void checkcast(TypeBinding typeBinding) {
491 	if (DEBUG) System.out.println(position + "\t\tcheckcast:"+typeBinding); //$NON-NLS-1$
492 	countLabels = 0;
493 	if (classFileOffset + 2 >= bCodeStream.length) {
494 		resizeByteArray();
495 	}
496 	position++;
497 	bCodeStream[classFileOffset++] = OPC_checkcast;
498 	writeUnsignedShort(constantPool.literalIndex(typeBinding));
499 }
d2f()500 final public void d2f() {
501 	if (DEBUG) System.out.println(position + "\t\td2f"); //$NON-NLS-1$
502 	countLabels = 0;
503 	stackDepth--;
504 	if (classFileOffset >= bCodeStream.length) {
505 		resizeByteArray();
506 	}
507 	position++;
508 	bCodeStream[classFileOffset++] = OPC_d2f;
509 }
d2i()510 final public void d2i() {
511 	if (DEBUG) System.out.println(position + "\t\td2i"); //$NON-NLS-1$
512 	countLabels = 0;
513 	stackDepth--;
514 	if (classFileOffset >= bCodeStream.length) {
515 		resizeByteArray();
516 	}
517 	position++;
518 	bCodeStream[classFileOffset++] = OPC_d2i;
519 }
d2l()520 final public void d2l() {
521 	if (DEBUG) System.out.println(position + "\t\td2l"); //$NON-NLS-1$
522 	countLabels = 0;
523 	if (classFileOffset >= bCodeStream.length) {
524 		resizeByteArray();
525 	}
526 	position++;
527 	bCodeStream[classFileOffset++] = OPC_d2l;
528 }
dadd()529 final public void dadd() {
530 	if (DEBUG) System.out.println(position + "\t\tdadd"); //$NON-NLS-1$
531 	countLabels = 0;
532 	stackDepth -= 2;
533 	if (classFileOffset >= bCodeStream.length) {
534 		resizeByteArray();
535 	}
536 	position++;
537 	bCodeStream[classFileOffset++] = OPC_dadd;
538 }
daload()539 final public void daload() {
540 	if (DEBUG) System.out.println(position + "\t\tdaload"); //$NON-NLS-1$
541 	countLabels = 0;
542 	if (classFileOffset >= bCodeStream.length) {
543 		resizeByteArray();
544 	}
545 	position++;
546 	bCodeStream[classFileOffset++] = OPC_daload;
547 }
dastore()548 final public void dastore() {
549 	if (DEBUG) System.out.println(position + "\t\tdastore"); //$NON-NLS-1$
550 	countLabels = 0;
551 	stackDepth -= 4;
552 	if (classFileOffset >= bCodeStream.length) {
553 		resizeByteArray();
554 	}
555 	position++;
556 	bCodeStream[classFileOffset++] = OPC_dastore;
557 }
dcmpg()558 final public void dcmpg() {
559 	if (DEBUG) System.out.println(position + "\t\tdcmpg"); //$NON-NLS-1$
560 	countLabels = 0;
561 	stackDepth -= 3;
562 	if (classFileOffset >= bCodeStream.length) {
563 		resizeByteArray();
564 	}
565 	position++;
566 	bCodeStream[classFileOffset++] = OPC_dcmpg;
567 }
dcmpl()568 final public void dcmpl() {
569 	if (DEBUG) System.out.println(position + "\t\tdcmpl"); //$NON-NLS-1$
570 	countLabels = 0;
571 	stackDepth -= 3;
572 	if (classFileOffset >= bCodeStream.length) {
573 		resizeByteArray();
574 	}
575 	position++;
576 	bCodeStream[classFileOffset++] = OPC_dcmpl;
577 }
dconst_0()578 final public void dconst_0() {
579 	if (DEBUG) System.out.println(position + "\t\tdconst_0"); //$NON-NLS-1$
580 	countLabels = 0;
581 	stackDepth += 2;
582 	if (stackDepth > stackMax)
583 		stackMax = stackDepth;
584 	if (classFileOffset >= bCodeStream.length) {
585 		resizeByteArray();
586 	}
587 	position++;
588 	bCodeStream[classFileOffset++] = OPC_dconst_0;
589 }
dconst_1()590 final public void dconst_1() {
591 	if (DEBUG) System.out.println(position + "\t\tdconst_1"); //$NON-NLS-1$
592 	countLabels = 0;
593 	stackDepth += 2;
594 	if (stackDepth > stackMax)
595 		stackMax = stackDepth;
596 	if (classFileOffset >= bCodeStream.length) {
597 		resizeByteArray();
598 	}
599 	position++;
600 	bCodeStream[classFileOffset++] = OPC_dconst_1;
601 }
ddiv()602 final public void ddiv() {
603 	if (DEBUG) System.out.println(position + "\t\tddiv"); //$NON-NLS-1$
604 	countLabels = 0;
605 	stackDepth -= 2;
606 	if (classFileOffset >= bCodeStream.length) {
607 		resizeByteArray();
608 	}
609 	position++;
610 	bCodeStream[classFileOffset++] = OPC_ddiv;
611 }
decrStackSize(int offset)612 public void decrStackSize(int offset) {
613 	stackDepth -= offset;
614 }
dload(int iArg)615 final public void dload(int iArg) {
616 	if (DEBUG) System.out.println(position + "\t\tdload:"+iArg); //$NON-NLS-1$
617 	countLabels = 0;
618 	stackDepth += 2;
619 	if (stackDepth > stackMax)
620 		stackMax = stackDepth;
621 	if (maxLocals < iArg + 2) {
622 		maxLocals = iArg + 2; // + 2 because it is a double
623 	}
624 	if (iArg > 255) { // Widen
625 		if (classFileOffset + 3 >= bCodeStream.length) {
626 			resizeByteArray();
627 		}
628 		position += 2;
629 		bCodeStream[classFileOffset++] = OPC_wide;
630 		bCodeStream[classFileOffset++] = OPC_dload;
631 		writeUnsignedShort(iArg);
632 	} else {
633 		// Don't need to use the wide bytecode
634 		if (classFileOffset + 1 >= bCodeStream.length) {
635 			resizeByteArray();
636 		}
637 		position += 2;
638 		bCodeStream[classFileOffset++] = OPC_dload;
639 		bCodeStream[classFileOffset++] = (byte) iArg;
640 	}
641 }
dload_0()642 final public void dload_0() {
643 	if (DEBUG) System.out.println(position + "\t\tdload_0"); //$NON-NLS-1$
644 	countLabels = 0;
645 	stackDepth += 2;
646 	if (stackDepth > stackMax)
647 		stackMax = stackDepth;
648 	if (maxLocals < 2) {
649 		maxLocals = 2;
650 	}
651 	if (classFileOffset >= bCodeStream.length) {
652 		resizeByteArray();
653 	}
654 	position++;
655 	bCodeStream[classFileOffset++] = OPC_dload_0;
656 }
dload_1()657 final public void dload_1() {
658 	if (DEBUG) System.out.println(position + "\t\tdload_1"); //$NON-NLS-1$
659 	countLabels = 0;
660 	stackDepth += 2;
661 	if (stackDepth > stackMax)
662 		stackMax = stackDepth;
663 	if (maxLocals < 3) {
664 		maxLocals = 3;
665 	}
666 	if (classFileOffset >= bCodeStream.length) {
667 		resizeByteArray();
668 	}
669 	position++;
670 	bCodeStream[classFileOffset++] = OPC_dload_1;
671 }
dload_2()672 final public void dload_2() {
673 	if (DEBUG) System.out.println(position + "\t\tdload_2"); //$NON-NLS-1$
674 	countLabels = 0;
675 	stackDepth += 2;
676 	if (stackDepth > stackMax)
677 		stackMax = stackDepth;
678 	if (maxLocals < 4) {
679 		maxLocals = 4;
680 	}
681 	if (classFileOffset >= bCodeStream.length) {
682 		resizeByteArray();
683 	}
684 	position++;
685 	bCodeStream[classFileOffset++] = OPC_dload_2;
686 }
dload_3()687 final public void dload_3() {
688 	if (DEBUG) System.out.println(position + "\t\tdload_3"); //$NON-NLS-1$
689 	countLabels = 0;
690 	stackDepth += 2;
691 	if (stackDepth > stackMax)
692 		stackMax = stackDepth;
693 	if (maxLocals < 5) {
694 		maxLocals = 5;
695 	}
696 	if (classFileOffset >= bCodeStream.length) {
697 		resizeByteArray();
698 	}
699 	position++;
700 	bCodeStream[classFileOffset++] = OPC_dload_3;
701 }
dmul()702 final public void dmul() {
703 	if (DEBUG) System.out.println(position + "\t\tdmul"); //$NON-NLS-1$
704 	countLabels = 0;
705 	stackDepth -= 2;
706 	if (classFileOffset >= bCodeStream.length) {
707 		resizeByteArray();
708 	}
709 	position++;
710 	bCodeStream[classFileOffset++] = OPC_dmul;
711 }
dneg()712 final public void dneg() {
713 	if (DEBUG) System.out.println(position + "\t\tdneg"); //$NON-NLS-1$
714 	countLabels = 0;
715 	if (classFileOffset >= bCodeStream.length) {
716 		resizeByteArray();
717 	}
718 	position++;
719 	bCodeStream[classFileOffset++] = OPC_dneg;
720 }
drem()721 final public void drem() {
722 	if (DEBUG) System.out.println(position + "\t\tdrem"); //$NON-NLS-1$
723 	countLabels = 0;
724 	stackDepth -= 2;
725 	if (classFileOffset >= bCodeStream.length) {
726 		resizeByteArray();
727 	}
728 	position++;
729 	bCodeStream[classFileOffset++] = OPC_drem;
730 }
dreturn()731 final public void dreturn() {
732 	if (DEBUG) System.out.println(position + "\t\tdreturn"); //$NON-NLS-1$
733 	countLabels = 0;
734 	stackDepth -= 2;
735 	// the stackDepth should be equal to 0
736 	if (classFileOffset >= bCodeStream.length) {
737 		resizeByteArray();
738 	}
739 	position++;
740 	bCodeStream[classFileOffset++] = OPC_dreturn;
741 }
dstore(int iArg)742 final public void dstore(int iArg) {
743 	if (DEBUG) System.out.println(position + "\t\tdstore:"+iArg); //$NON-NLS-1$
744 	countLabels = 0;
745 	stackDepth -= 2;
746 	if (maxLocals <= iArg + 1) {
747 		maxLocals = iArg + 2;
748 	}
749 	if (iArg > 255) { // Widen
750 		if (classFileOffset + 3 >= bCodeStream.length) {
751 			resizeByteArray();
752 		}
753 		position += 2;
754 		bCodeStream[classFileOffset++] = OPC_wide;
755 		bCodeStream[classFileOffset++] = OPC_dstore;
756 		writeUnsignedShort(iArg);
757 	} else {
758 		if (classFileOffset + 1 >= bCodeStream.length) {
759 			resizeByteArray();
760 		}
761 		position += 2;
762 		bCodeStream[classFileOffset++] = OPC_dstore;
763 		bCodeStream[classFileOffset++] = (byte) iArg;
764 	}
765 }
dstore_0()766 final public void dstore_0() {
767 	if (DEBUG) System.out.println(position + "\t\tdstore_0"); //$NON-NLS-1$
768 	countLabels = 0;
769 	stackDepth -= 2;
770 	if (maxLocals < 2) {
771 		maxLocals = 2;
772 	}
773 	if (classFileOffset >= bCodeStream.length) {
774 		resizeByteArray();
775 	}
776 	position++;
777 	bCodeStream[classFileOffset++] = OPC_dstore_0;
778 }
dstore_1()779 final public void dstore_1() {
780 	if (DEBUG) System.out.println(position + "\t\tdstore_1"); //$NON-NLS-1$
781 	countLabels = 0;
782 	stackDepth -= 2;
783 	if (maxLocals < 3) {
784 		maxLocals = 3;
785 	}
786 	if (classFileOffset >= bCodeStream.length) {
787 		resizeByteArray();
788 	}
789 	position++;
790 	bCodeStream[classFileOffset++] = OPC_dstore_1;
791 }
dstore_2()792 final public void dstore_2() {
793 	if (DEBUG) System.out.println(position + "\t\tdstore_2"); //$NON-NLS-1$
794 	countLabels = 0;
795 	stackDepth -= 2;
796 	if (maxLocals < 4) {
797 		maxLocals = 4;
798 	}
799 	if (classFileOffset >= bCodeStream.length) {
800 		resizeByteArray();
801 	}
802 	position++;
803 	bCodeStream[classFileOffset++] = OPC_dstore_2;
804 }
dstore_3()805 final public void dstore_3() {
806 	if (DEBUG) System.out.println(position + "\t\tdstore_3"); //$NON-NLS-1$
807 	countLabels = 0;
808 	stackDepth -= 2;
809 	if (maxLocals < 5) {
810 		maxLocals = 5;
811 	}
812 	if (classFileOffset >= bCodeStream.length) {
813 		resizeByteArray();
814 	}
815 	position++;
816 	bCodeStream[classFileOffset++] = OPC_dstore_3;
817 }
dsub()818 final public void dsub() {
819 	if (DEBUG) System.out.println(position + "\t\tdsub"); //$NON-NLS-1$
820 	countLabels = 0;
821 	stackDepth -= 2;
822 	if (classFileOffset >= bCodeStream.length) {
823 		resizeByteArray();
824 	}
825 	position++;
826 	bCodeStream[classFileOffset++] = OPC_dsub;
827 }
dup()828 final public void dup() {
829 	if (DEBUG) System.out.println(position + "\t\tdup"); //$NON-NLS-1$
830 	countLabels = 0;
831 	stackDepth++;
832 	if (stackDepth > stackMax) {
833 		stackMax = stackDepth;
834 	}
835 	if (classFileOffset >= bCodeStream.length) {
836 		resizeByteArray();
837 	}
838 	position++;
839 	bCodeStream[classFileOffset++] = OPC_dup;
840 }
dup_x1()841 final public void dup_x1() {
842 	if (DEBUG) System.out.println(position + "\t\tdup_x1"); //$NON-NLS-1$
843 	countLabels = 0;
844 	stackDepth++;
845 	if (stackDepth > stackMax)
846 		stackMax = stackDepth;
847 	if (classFileOffset >= bCodeStream.length) {
848 		resizeByteArray();
849 	}
850 	position++;
851 	bCodeStream[classFileOffset++] = OPC_dup_x1;
852 }
dup_x2()853 final public void dup_x2() {
854 	if (DEBUG) System.out.println(position + "\t\tdup_x2"); //$NON-NLS-1$
855 	countLabels = 0;
856 	stackDepth++;
857 	if (stackDepth > stackMax)
858 		stackMax = stackDepth;
859 	if (classFileOffset >= bCodeStream.length) {
860 		resizeByteArray();
861 	}
862 	position++;
863 	bCodeStream[classFileOffset++] = OPC_dup_x2;
864 }
dup2()865 final public void dup2() {
866 	if (DEBUG) System.out.println(position + "\t\tdup2"); //$NON-NLS-1$
867 	countLabels = 0;
868 	stackDepth += 2;
869 	if (stackDepth > stackMax)
870 		stackMax = stackDepth;
871 	if (classFileOffset >= bCodeStream.length) {
872 		resizeByteArray();
873 	}
874 	position++;
875 	bCodeStream[classFileOffset++] = OPC_dup2;
876 }
dup2_x1()877 final public void dup2_x1() {
878 	if (DEBUG) System.out.println(position + "\t\tdup2_x1"); //$NON-NLS-1$
879 	countLabels = 0;
880 	stackDepth += 2;
881 	if (stackDepth > stackMax)
882 		stackMax = stackDepth;
883 	if (classFileOffset >= bCodeStream.length) {
884 		resizeByteArray();
885 	}
886 	position++;
887 	bCodeStream[classFileOffset++] = OPC_dup2_x1;
888 }
dup2_x2()889 final public void dup2_x2() {
890 	if (DEBUG) System.out.println(position + "\t\tdup2_x2"); //$NON-NLS-1$
891 	countLabels = 0;
892 	stackDepth += 2;
893 	if (stackDepth > stackMax)
894 		stackMax = stackDepth;
895 	if (classFileOffset >= bCodeStream.length) {
896 		resizeByteArray();
897 	}
898 	position++;
899 	bCodeStream[classFileOffset++] = OPC_dup2_x2;
900 }
exitUserScope(BlockScope blockScope)901 public void exitUserScope(BlockScope blockScope) {
902 	// mark all the scope's locals as loosing their definite assignment
903 
904 	if (!generateLocalVariableTableAttributes)
905 		return;
906 	for (int i = 0; i < visibleLocalsCount; i++) {
907 		LocalVariableBinding visibleLocal = visibleLocals[i];
908 		if ((visibleLocal != null) && (visibleLocal.declaringScope == blockScope)) {
909 			// there maybe some some preserved locals never initialized
910 			if (visibleLocal.initializationCount > 0){
911 				visibleLocals[i].recordInitializationEndPC(position);
912 			}
913 			visibleLocals[i] = null; // this variable is no longer visible afterwards
914 		}
915 	}
916 }
f2d()917 final public void f2d() {
918 	if (DEBUG) System.out.println(position + "\t\tf2d"); //$NON-NLS-1$
919 	countLabels = 0;
920 	stackDepth++;
921 	if (stackDepth > stackMax)
922 		stackMax = stackDepth;
923 	if (classFileOffset >= bCodeStream.length) {
924 		resizeByteArray();
925 	}
926 	position++;
927 	bCodeStream[classFileOffset++] = OPC_f2d;
928 }
f2i()929 final public void f2i() {
930 	if (DEBUG) System.out.println(position + "\t\tf2i"); //$NON-NLS-1$
931 	countLabels = 0;
932 	if (classFileOffset >= bCodeStream.length) {
933 		resizeByteArray();
934 	}
935 	position++;
936 	bCodeStream[classFileOffset++] = OPC_f2i;
937 }
f2l()938 final public void f2l() {
939 	if (DEBUG) System.out.println(position + "\t\tf2l"); //$NON-NLS-1$
940 	countLabels = 0;
941 	stackDepth++;
942 	if (stackDepth > stackMax)
943 		stackMax = stackDepth;
944 	if (classFileOffset >= bCodeStream.length) {
945 		resizeByteArray();
946 	}
947 	position++;
948 	bCodeStream[classFileOffset++] = OPC_f2l;
949 }
fadd()950 final public void fadd() {
951 	if (DEBUG) System.out.println(position + "\t\tfadd"); //$NON-NLS-1$
952 	countLabels = 0;
953 	stackDepth--;
954 	if (classFileOffset >= bCodeStream.length) {
955 		resizeByteArray();
956 	}
957 	position++;
958 	bCodeStream[classFileOffset++] = OPC_fadd;
959 }
faload()960 final public void faload() {
961 	if (DEBUG) System.out.println(position + "\t\tfaload"); //$NON-NLS-1$
962 	countLabels = 0;
963 	stackDepth--;
964 	if (classFileOffset >= bCodeStream.length) {
965 		resizeByteArray();
966 	}
967 	position++;
968 	bCodeStream[classFileOffset++] = OPC_faload;
969 }
fastore()970 final public void fastore() {
971 	if (DEBUG) System.out.println(position + "\t\tfaload"); //$NON-NLS-1$
972 	countLabels = 0;
973 	stackDepth -= 3;
974 	if (classFileOffset >= bCodeStream.length) {
975 		resizeByteArray();
976 	}
977 	position++;
978 	bCodeStream[classFileOffset++] = OPC_fastore;
979 }
fcmpg()980 final public void fcmpg() {
981 	if (DEBUG) System.out.println(position + "\t\tfcmpg"); //$NON-NLS-1$
982 	countLabels = 0;
983 	stackDepth--;
984 	if (classFileOffset >= bCodeStream.length) {
985 		resizeByteArray();
986 	}
987 	position++;
988 	bCodeStream[classFileOffset++] = OPC_fcmpg;
989 }
fcmpl()990 final public void fcmpl() {
991 	if (DEBUG) System.out.println(position + "\t\tfcmpl"); //$NON-NLS-1$
992 	countLabels = 0;
993 	stackDepth--;
994 	if (classFileOffset >= bCodeStream.length) {
995 		resizeByteArray();
996 	}
997 	position++;
998 	bCodeStream[classFileOffset++] = OPC_fcmpl;
999 }
fconst_0()1000 final public void fconst_0() {
1001 	if (DEBUG) System.out.println(position + "\t\tfconst_0"); //$NON-NLS-1$
1002 	countLabels = 0;
1003 	stackDepth++;
1004 	if (stackDepth > stackMax)
1005 		stackMax = stackDepth;
1006 	if (classFileOffset >= bCodeStream.length) {
1007 		resizeByteArray();
1008 	}
1009 	position++;
1010 	bCodeStream[classFileOffset++] = OPC_fconst_0;
1011 }
fconst_1()1012 final public void fconst_1() {
1013 	if (DEBUG) System.out.println(position + "\t\tfconst_1"); //$NON-NLS-1$
1014 	countLabels = 0;
1015 	stackDepth++;
1016 	if (stackDepth > stackMax)
1017 		stackMax = stackDepth;
1018 	if (classFileOffset >= bCodeStream.length) {
1019 		resizeByteArray();
1020 	}
1021 	position++;
1022 	bCodeStream[classFileOffset++] = OPC_fconst_1;
1023 }
fconst_2()1024 final public void fconst_2() {
1025 	if (DEBUG) System.out.println(position + "\t\tfconst_2"); //$NON-NLS-1$
1026 	countLabels = 0;
1027 	stackDepth++;
1028 	if (stackDepth > stackMax)
1029 		stackMax = stackDepth;
1030 	if (classFileOffset >= bCodeStream.length) {
1031 		resizeByteArray();
1032 	}
1033 	position++;
1034 	bCodeStream[classFileOffset++] = OPC_fconst_2;
1035 }
fdiv()1036 final public void fdiv() {
1037 	if (DEBUG) System.out.println(position + "\t\tfdiv"); //$NON-NLS-1$
1038 	countLabels = 0;
1039 	stackDepth--;
1040 	if (classFileOffset >= bCodeStream.length) {
1041 		resizeByteArray();
1042 	}
1043 	position++;
1044 	bCodeStream[classFileOffset++] = OPC_fdiv;
1045 }
fload(int iArg)1046 final public void fload(int iArg) {
1047 	if (DEBUG) System.out.println(position + "\t\tfload:"+iArg); //$NON-NLS-1$
1048 	countLabels = 0;
1049 	stackDepth++;
1050 	if (maxLocals <= iArg) {
1051 		maxLocals = iArg + 1;
1052 	}
1053 	if (stackDepth > stackMax)
1054 		stackMax = stackDepth;
1055 	if (iArg > 255) { // Widen
1056 		if (classFileOffset + 3 >= bCodeStream.length) {
1057 			resizeByteArray();
1058 		}
1059 		position += 2;
1060 		bCodeStream[classFileOffset++] = OPC_wide;
1061 		bCodeStream[classFileOffset++] = OPC_fload;
1062 		writeUnsignedShort(iArg);
1063 	} else {
1064 		if (classFileOffset + 1 >= bCodeStream.length) {
1065 			resizeByteArray();
1066 		}
1067 		position += 2;
1068 		bCodeStream[classFileOffset++] = OPC_fload;
1069 		bCodeStream[classFileOffset++] = (byte) iArg;
1070 	}
1071 }
fload_0()1072 final public void fload_0() {
1073 	if (DEBUG) System.out.println(position + "\t\tfload_0"); //$NON-NLS-1$
1074 	countLabels = 0;
1075 	stackDepth++;
1076 	if (maxLocals == 0) {
1077 		maxLocals = 1;
1078 	}
1079 	if (stackDepth > stackMax)
1080 		stackMax = stackDepth;
1081 	if (classFileOffset >= bCodeStream.length) {
1082 		resizeByteArray();
1083 	}
1084 	position++;
1085 	bCodeStream[classFileOffset++] = OPC_fload_0;
1086 }
fload_1()1087 final public void fload_1() {
1088 	if (DEBUG) System.out.println(position + "\t\tfload_1"); //$NON-NLS-1$
1089 	countLabels = 0;
1090 	stackDepth++;
1091 	if (maxLocals <= 1) {
1092 		maxLocals = 2;
1093 	}
1094 	if (stackDepth > stackMax)
1095 		stackMax = stackDepth;
1096 	if (classFileOffset >= bCodeStream.length) {
1097 		resizeByteArray();
1098 	}
1099 	position++;
1100 	bCodeStream[classFileOffset++] = OPC_fload_1;
1101 }
fload_2()1102 final public void fload_2() {
1103 	if (DEBUG) System.out.println(position + "\t\tfload_2"); //$NON-NLS-1$
1104 	countLabels = 0;
1105 	stackDepth++;
1106 	if (maxLocals <= 2) {
1107 		maxLocals = 3;
1108 	}
1109 	if (stackDepth > stackMax)
1110 		stackMax = stackDepth;
1111 	if (classFileOffset >= bCodeStream.length) {
1112 		resizeByteArray();
1113 	}
1114 	position++;
1115 	bCodeStream[classFileOffset++] = OPC_fload_2;
1116 }
fload_3()1117 final public void fload_3() {
1118 	if (DEBUG) System.out.println(position + "\t\tfload_3"); //$NON-NLS-1$
1119 	countLabels = 0;
1120 	stackDepth++;
1121 	if (maxLocals <= 3) {
1122 		maxLocals = 4;
1123 	}
1124 	if (stackDepth > stackMax)
1125 		stackMax = stackDepth;
1126 	if (classFileOffset >= bCodeStream.length) {
1127 		resizeByteArray();
1128 	}
1129 	position++;
1130 	bCodeStream[classFileOffset++] = OPC_fload_3;
1131 }
fmul()1132 final public void fmul() {
1133 	if (DEBUG) System.out.println(position + "\t\tfmul"); //$NON-NLS-1$
1134 	countLabels = 0;
1135 	stackDepth--;
1136 	if (classFileOffset >= bCodeStream.length) {
1137 		resizeByteArray();
1138 	}
1139 	position++;
1140 	bCodeStream[classFileOffset++] = OPC_fmul;
1141 }
fneg()1142 final public void fneg() {
1143 	if (DEBUG) System.out.println(position + "\t\tfneg"); //$NON-NLS-1$
1144 	countLabels = 0;
1145 	if (classFileOffset >= bCodeStream.length) {
1146 		resizeByteArray();
1147 	}
1148 	position++;
1149 	bCodeStream[classFileOffset++] = OPC_fneg;
1150 }
frem()1151 final public void frem() {
1152 	if (DEBUG) System.out.println(position + "\t\tfrem"); //$NON-NLS-1$
1153 	countLabels = 0;
1154 	stackDepth--;
1155 	if (classFileOffset >= bCodeStream.length) {
1156 		resizeByteArray();
1157 	}
1158 	position++;
1159 	bCodeStream[classFileOffset++] = OPC_frem;
1160 }
freturn()1161 final public void freturn() {
1162 	if (DEBUG) System.out.println(position + "\t\tfreturn"); //$NON-NLS-1$
1163 	countLabels = 0;
1164 	stackDepth--;
1165 	// the stackDepth should be equal to 0
1166 	if (classFileOffset >= bCodeStream.length) {
1167 		resizeByteArray();
1168 	}
1169 	position++;
1170 	bCodeStream[classFileOffset++] = OPC_freturn;
1171 }
fstore(int iArg)1172 final public void fstore(int iArg) {
1173 	if (DEBUG) System.out.println(position + "\t\tfstore:"+iArg); //$NON-NLS-1$
1174 	countLabels = 0;
1175 	stackDepth--;
1176 	if (maxLocals <= iArg) {
1177 		maxLocals = iArg + 1;
1178 	}
1179 	if (iArg > 255) { // Widen
1180 		if (classFileOffset + 3 >= bCodeStream.length) {
1181 			resizeByteArray();
1182 		}
1183 		position += 2;
1184 		bCodeStream[classFileOffset++] = OPC_wide;
1185 		bCodeStream[classFileOffset++] = OPC_fstore;
1186 		writeUnsignedShort(iArg);
1187 	} else {
1188 		if (classFileOffset + 1 >= bCodeStream.length) {
1189 			resizeByteArray();
1190 		}
1191 		position += 2;
1192 		bCodeStream[classFileOffset++] = OPC_fstore;
1193 		bCodeStream[classFileOffset++] = (byte) iArg;
1194 	}
1195 }
fstore_0()1196 final public void fstore_0() {
1197 	if (DEBUG) System.out.println(position + "\t\tfstore_0"); //$NON-NLS-1$
1198 	countLabels = 0;
1199 	stackDepth--;
1200 	if (maxLocals == 0) {
1201 		maxLocals = 1;
1202 	}
1203 	if (classFileOffset >= bCodeStream.length) {
1204 		resizeByteArray();
1205 	}
1206 	position++;
1207 	bCodeStream[classFileOffset++] = OPC_fstore_0;
1208 }
fstore_1()1209 final public void fstore_1() {
1210 	if (DEBUG) System.out.println(position + "\t\tfstore_1"); //$NON-NLS-1$
1211 	countLabels = 0;
1212 	stackDepth--;
1213 	if (maxLocals <= 1) {
1214 		maxLocals = 2;
1215 	}
1216 	if (classFileOffset >= bCodeStream.length) {
1217 		resizeByteArray();
1218 	}
1219 	position++;
1220 	bCodeStream[classFileOffset++] = OPC_fstore_1;
1221 }
fstore_2()1222 final public void fstore_2() {
1223 	if (DEBUG) System.out.println(position + "\t\tfstore_2"); //$NON-NLS-1$
1224 	countLabels = 0;
1225 	stackDepth--;
1226 	if (maxLocals <= 2) {
1227 		maxLocals = 3;
1228 	}
1229 	if (classFileOffset >= bCodeStream.length) {
1230 		resizeByteArray();
1231 	}
1232 	position++;
1233 	bCodeStream[classFileOffset++] = OPC_fstore_2;
1234 }
fstore_3()1235 final public void fstore_3() {
1236 	if (DEBUG) System.out.println(position + "\t\tfstore_3"); //$NON-NLS-1$
1237 	countLabels = 0;
1238 	stackDepth--;
1239 	if (maxLocals <= 3) {
1240 		maxLocals = 4;
1241 	}
1242 	if (classFileOffset >= bCodeStream.length) {
1243 		resizeByteArray();
1244 	}
1245 	position++;
1246 	bCodeStream[classFileOffset++] = OPC_fstore_3;
1247 }
fsub()1248 final public void fsub() {
1249 	if (DEBUG) System.out.println(position + "\t\tfsub"); //$NON-NLS-1$
1250 	countLabels = 0;
1251 	stackDepth--;
1252 	if (classFileOffset >= bCodeStream.length) {
1253 		resizeByteArray();
1254 	}
1255 	position++;
1256 	bCodeStream[classFileOffset++] = OPC_fsub;
1257 }
1258 /**
1259  * Macro for building a class descriptor object
1260  */
generateClassLiteralAccessForType(TypeBinding accessedType, FieldBinding syntheticFieldBinding)1261 public void generateClassLiteralAccessForType(TypeBinding accessedType, FieldBinding syntheticFieldBinding) {
1262 	Label endLabel;
1263 	ExceptionLabel anyExceptionHandler;
1264 	int saveStackSize;
1265 	if (accessedType.isBaseType() && accessedType != NullBinding) {
1266 		this.getTYPE(accessedType.id);
1267 		return;
1268 	}
1269 
1270 	if (this.targetLevel >= ClassFileConstants.JDK1_5) {
1271 		// generation using the new ldc_w bytecode
1272 		this.ldc(accessedType);
1273 	} else {
1274 		endLabel = new Label(this);
1275 		if (syntheticFieldBinding != null) { // non interface case
1276 			this.getstatic(syntheticFieldBinding);
1277 			this.dup();
1278 			this.ifnonnull(endLabel);
1279 			this.pop();
1280 		}
1281 
1282 		/* Macro for building a class descriptor object... using or not a field cache to store it into...
1283 		this sequence is responsible for building the actual class descriptor.
1284 
1285 		If the fieldCache is set, then it is supposed to be the body of a synthetic access method
1286 		factoring the actual descriptor creation out of the invocation site (saving space).
1287 		If the fieldCache is nil, then we are dumping the bytecode on the invocation site, since
1288 		we have no way to get a hand on the field cache to do better. */
1289 
1290 
1291 		// Wrap the code in an exception handler to convert a ClassNotFoundException into a NoClassDefError
1292 
1293 		anyExceptionHandler = new ExceptionLabel(this, BaseTypes.NullBinding /* represents ClassNotFoundException*/);
1294 		this.ldc(accessedType == BaseTypes.NullBinding ? "java.lang.Object" : String.valueOf(accessedType.constantPoolName()).replace('/', '.')); //$NON-NLS-1$
1295 		this.invokeClassForName();
1296 
1297 		/* See https://bugs.eclipse.org/bugs/show_bug.cgi?id=37565
1298 		if (accessedType == BaseTypes.NullBinding) {
1299 			this.ldc("java.lang.Object"); //$NON-NLS-1$
1300 		} else if (accessedType.isArrayType()) {
1301 			this.ldc(String.valueOf(accessedType.constantPoolName()).replace('/', '.'));
1302 		} else {
1303 			// we make it an array type (to avoid class initialization)
1304 			this.ldc("[L" + String.valueOf(accessedType.constantPoolName()).replace('/', '.') + ";"); //$NON-NLS-1$//$NON-NLS-2$
1305 		}
1306 		this.invokeClassForName();
1307 		if (!accessedType.isArrayType()) { // extract the component type, which doesn't initialize the class
1308 			this.invokeJavaLangClassGetComponentType();
1309 		}
1310 		*/
1311 		/* We need to protect the runtime code from binary inconsistencies
1312 		in case the accessedType is missing, the ClassNotFoundException has to be converted
1313 		into a NoClassDefError(old ex message), we thus need to build an exception handler for this one. */
1314 		anyExceptionHandler.placeEnd();
1315 
1316 		if (syntheticFieldBinding != null) { // non interface case
1317 			this.dup();
1318 			this.putstatic(syntheticFieldBinding);
1319 		}
1320 		this.goto_(endLabel);
1321 
1322 
1323 		// Generate the body of the exception handler
1324 		saveStackSize = stackDepth;
1325 		stackDepth = 1;
1326 		/* ClassNotFoundException on stack -- the class literal could be doing more things
1327 		on the stack, which means that the stack may not be empty at this point in the
1328 		above code gen. So we save its state and restart it from 1. */
1329 
1330 		anyExceptionHandler.place();
1331 
1332 		// Transform the current exception, and repush and throw a
1333 		// NoClassDefFoundError(ClassNotFound.getMessage())
1334 
1335 		this.newNoClassDefFoundError();
1336 		this.dup_x1();
1337 		this.swap();
1338 
1339 		// Retrieve the message from the old exception
1340 		this.invokeThrowableGetMessage();
1341 
1342 		// Send the constructor taking a message string as an argument
1343 		this.invokeNoClassDefFoundErrorStringConstructor();
1344 		this.athrow();
1345 		stackDepth = saveStackSize;
1346 		endLabel.place();
1347 	}
1348 }
1349 /**
1350  * This method generates the code attribute bytecode
1351  */
generateCodeAttributeForProblemMethod(String problemMessage)1352 final public void generateCodeAttributeForProblemMethod(String problemMessage) {
1353 	newJavaLangError();
1354 	dup();
1355 	ldc(problemMessage);
1356 	invokeJavaLangErrorConstructor();
1357 	athrow();
1358 }
generateConstant(Constant constant, int implicitConversionCode)1359 public void generateConstant(Constant constant, int implicitConversionCode) {
1360 	int targetTypeID = implicitConversionCode >> 4;
1361 	switch (targetTypeID) {
1362 		case T_boolean :
1363 			generateInlinedValue(constant.booleanValue());
1364 			break;
1365 		case T_char :
1366 			generateInlinedValue(constant.charValue());
1367 			break;
1368 		case T_byte :
1369 			generateInlinedValue(constant.byteValue());
1370 			break;
1371 		case T_short :
1372 			generateInlinedValue(constant.shortValue());
1373 			break;
1374 		case T_int :
1375 			generateInlinedValue(constant.intValue());
1376 			break;
1377 		case T_long :
1378 			generateInlinedValue(constant.longValue());
1379 			break;
1380 		case T_float :
1381 			generateInlinedValue(constant.floatValue());
1382 			break;
1383 		case T_double :
1384 			generateInlinedValue(constant.doubleValue());
1385 			break;
1386 		default : //String or Object
1387 			ldc(constant.stringValue());
1388 	}
1389 }
1390 /**
1391  * Generates the sequence of instructions which will perform the conversion of the expression
1392  * on the stack into a different type (e.g. long l = someInt; --> i2l must be inserted).
1393  * @param implicitConversionCode int
1394  */
generateImplicitConversion(int implicitConversionCode)1395 public void generateImplicitConversion(int implicitConversionCode) {
1396 	switch (implicitConversionCode) {
1397 		case Float2Char :
1398 			this.f2i();
1399 			this.i2c();
1400 			break;
1401 		case Double2Char :
1402 			this.d2i();
1403 			this.i2c();
1404 			break;
1405 		case Int2Char :
1406 		case Short2Char :
1407 		case Byte2Char :
1408 			this.i2c();
1409 			break;
1410 		case Long2Char :
1411 			this.l2i();
1412 			this.i2c();
1413 			break;
1414 		case Char2Float :
1415 		case Short2Float :
1416 		case Int2Float :
1417 		case Byte2Float :
1418 			this.i2f();
1419 			break;
1420 		case Double2Float :
1421 			this.d2f();
1422 			break;
1423 		case Long2Float :
1424 			this.l2f();
1425 			break;
1426 		case Float2Byte :
1427 			this.f2i();
1428 			this.i2b();
1429 			break;
1430 		case Double2Byte :
1431 			this.d2i();
1432 			this.i2b();
1433 			break;
1434 		case Int2Byte :
1435 		case Short2Byte :
1436 		case Char2Byte :
1437 			this.i2b();
1438 			break;
1439 		case Long2Byte :
1440 			this.l2i();
1441 			this.i2b();
1442 			break;
1443 		case Byte2Double :
1444 		case Char2Double :
1445 		case Short2Double :
1446 		case Int2Double :
1447 			this.i2d();
1448 			break;
1449 		case Float2Double :
1450 			this.f2d();
1451 			break;
1452 		case Long2Double :
1453 			this.l2d();
1454 			break;
1455 		case Byte2Short :
1456 		case Char2Short :
1457 		case Int2Short :
1458 			this.i2s();
1459 			break;
1460 		case Double2Short :
1461 			this.d2i();
1462 			this.i2s();
1463 			break;
1464 		case Long2Short :
1465 			this.l2i();
1466 			this.i2s();
1467 			break;
1468 		case Float2Short :
1469 			this.f2i();
1470 			this.i2s();
1471 			break;
1472 		case Double2Int :
1473 			this.d2i();
1474 			break;
1475 		case Float2Int :
1476 			this.f2i();
1477 			break;
1478 		case Long2Int :
1479 			this.l2i();
1480 			break;
1481 		case Int2Long :
1482 		case Char2Long :
1483 		case Byte2Long :
1484 		case Short2Long :
1485 			this.i2l();
1486 			break;
1487 		case Double2Long :
1488 			this.d2l();
1489 			break;
1490 		case Float2Long :
1491 			this.f2l();
1492 	}
1493 }
generateInlinedValue(byte inlinedValue)1494 public void generateInlinedValue(byte inlinedValue) {
1495 	switch (inlinedValue) {
1496 		case -1 :
1497 			this.iconst_m1();
1498 			break;
1499 		case 0 :
1500 			this.iconst_0();
1501 			break;
1502 		case 1 :
1503 			this.iconst_1();
1504 			break;
1505 		case 2 :
1506 			this.iconst_2();
1507 			break;
1508 		case 3 :
1509 			this.iconst_3();
1510 			break;
1511 		case 4 :
1512 			this.iconst_4();
1513 			break;
1514 		case 5 :
1515 			this.iconst_5();
1516 			break;
1517 		default :
1518 			if ((-128 <= inlinedValue) && (inlinedValue <= 127)) {
1519 				this.bipush(inlinedValue);
1520 				return;
1521 			}
1522 	}
1523 }
generateInlinedValue(char inlinedValue)1524 public void generateInlinedValue(char inlinedValue) {
1525 	switch (inlinedValue) {
1526 		case 0 :
1527 			this.iconst_0();
1528 			break;
1529 		case 1 :
1530 			this.iconst_1();
1531 			break;
1532 		case 2 :
1533 			this.iconst_2();
1534 			break;
1535 		case 3 :
1536 			this.iconst_3();
1537 			break;
1538 		case 4 :
1539 			this.iconst_4();
1540 			break;
1541 		case 5 :
1542 			this.iconst_5();
1543 			break;
1544 		default :
1545 			if ((6 <= inlinedValue) && (inlinedValue <= 127)) {
1546 				this.bipush((byte) inlinedValue);
1547 				return;
1548 			}
1549 			if ((128 <= inlinedValue) && (inlinedValue <= 32767)) {
1550 				this.sipush(inlinedValue);
1551 				return;
1552 			}
1553 			this.ldc(inlinedValue);
1554 	}
1555 }
generateInlinedValue(double inlinedValue)1556 public void generateInlinedValue(double inlinedValue) {
1557 	if (inlinedValue == 0.0) {
1558 		if (Double.doubleToLongBits(inlinedValue) != 0L)
1559 			this.ldc2_w(inlinedValue);
1560 		else
1561 			this.dconst_0();
1562 		return;
1563 	}
1564 	if (inlinedValue == 1.0) {
1565 		this.dconst_1();
1566 		return;
1567 	}
1568 	this.ldc2_w(inlinedValue);
1569 }
generateInlinedValue(float inlinedValue)1570 public void generateInlinedValue(float inlinedValue) {
1571 	if (inlinedValue == 0.0f) {
1572 		if (Float.floatToIntBits(inlinedValue) != 0)
1573 			this.ldc(inlinedValue);
1574 		else
1575 			this.fconst_0();
1576 		return;
1577 	}
1578 	if (inlinedValue == 1.0f) {
1579 		this.fconst_1();
1580 		return;
1581 	}
1582 	if (inlinedValue == 2.0f) {
1583 		this.fconst_2();
1584 		return;
1585 	}
1586 	this.ldc(inlinedValue);
1587 }
generateInlinedValue(int inlinedValue)1588 public void generateInlinedValue(int inlinedValue) {
1589 	switch (inlinedValue) {
1590 		case -1 :
1591 			this.iconst_m1();
1592 			break;
1593 		case 0 :
1594 			this.iconst_0();
1595 			break;
1596 		case 1 :
1597 			this.iconst_1();
1598 			break;
1599 		case 2 :
1600 			this.iconst_2();
1601 			break;
1602 		case 3 :
1603 			this.iconst_3();
1604 			break;
1605 		case 4 :
1606 			this.iconst_4();
1607 			break;
1608 		case 5 :
1609 			this.iconst_5();
1610 			break;
1611 		default :
1612 			if ((-128 <= inlinedValue) && (inlinedValue <= 127)) {
1613 				this.bipush((byte) inlinedValue);
1614 				return;
1615 			}
1616 			if ((-32768 <= inlinedValue) && (inlinedValue <= 32767)) {
1617 				this.sipush(inlinedValue);
1618 				return;
1619 			}
1620 			this.ldc(inlinedValue);
1621 	}
1622 }
generateInlinedValue(long inlinedValue)1623 public void generateInlinedValue(long inlinedValue) {
1624 	if (inlinedValue == 0) {
1625 		this.lconst_0();
1626 		return;
1627 	}
1628 	if (inlinedValue == 1) {
1629 		this.lconst_1();
1630 		return;
1631 	}
1632 	this.ldc2_w(inlinedValue);
1633 }
generateInlinedValue(short inlinedValue)1634 public void generateInlinedValue(short inlinedValue) {
1635 	switch (inlinedValue) {
1636 		case -1 :
1637 			this.iconst_m1();
1638 			break;
1639 		case 0 :
1640 			this.iconst_0();
1641 			break;
1642 		case 1 :
1643 			this.iconst_1();
1644 			break;
1645 		case 2 :
1646 			this.iconst_2();
1647 			break;
1648 		case 3 :
1649 			this.iconst_3();
1650 			break;
1651 		case 4 :
1652 			this.iconst_4();
1653 			break;
1654 		case 5 :
1655 			this.iconst_5();
1656 			break;
1657 		default :
1658 			if ((-128 <= inlinedValue) && (inlinedValue <= 127)) {
1659 				this.bipush((byte) inlinedValue);
1660 				return;
1661 			}
1662 			this.sipush(inlinedValue);
1663 	}
1664 }
generateInlinedValue(boolean inlinedValue)1665 public void generateInlinedValue(boolean inlinedValue) {
1666 	if (inlinedValue)
1667 		this.iconst_1();
1668 	else
1669 		this.iconst_0();
1670 }
generateOuterAccess(Object[] mappingSequence, ASTNode invocationSite, Binding target, Scope scope)1671 public void generateOuterAccess(Object[] mappingSequence, ASTNode invocationSite, Binding target, Scope scope) {
1672 	if (mappingSequence == null) {
1673 		if (target instanceof LocalVariableBinding) {
1674 			scope.problemReporter().needImplementation(); //TODO (philippe) should improve local emulation failure reporting
1675 		} else {
1676 			scope.problemReporter().noSuchEnclosingInstance((ReferenceBinding)target, invocationSite, false);
1677 		}
1678 		return;
1679 	}
1680 	if (mappingSequence == BlockScope.NoEnclosingInstanceInConstructorCall) {
1681 		scope.problemReporter().noSuchEnclosingInstance((ReferenceBinding)target, invocationSite, true);
1682 		return;
1683 	} else if (mappingSequence == BlockScope.NoEnclosingInstanceInStaticContext) {
1684 		scope.problemReporter().noSuchEnclosingInstance((ReferenceBinding)target, invocationSite, false);
1685 		return;
1686 	}
1687 
1688 	if (mappingSequence == BlockScope.EmulationPathToImplicitThis) {
1689 		this.aload_0();
1690 		return;
1691 	} else if (mappingSequence[0] instanceof FieldBinding) {
1692 		FieldBinding fieldBinding = (FieldBinding) mappingSequence[0];
1693 		this.aload_0();
1694 		this.getfield(fieldBinding);
1695 	} else {
1696 		load((LocalVariableBinding) mappingSequence[0]);
1697 	}
1698 	for (int i = 1, length = mappingSequence.length; i < length; i++) {
1699 		if (mappingSequence[i] instanceof FieldBinding) {
1700 			FieldBinding fieldBinding = (FieldBinding) mappingSequence[i];
1701 			this.getfield(fieldBinding);
1702 		} else {
1703 			this.invokestatic((MethodBinding) mappingSequence[i]);
1704 		}
1705 	}
1706 }
1707 
1708 /**
1709  * The equivalent code performs a string conversion:
1710  *
1711  * @param blockScope the given blockScope
1712  * @param oper1 the first expression
1713  * @param oper2 the second expression
1714  */
generateStringConcatenationAppend(BlockScope blockScope, Expression oper1, Expression oper2)1715 public void generateStringConcatenationAppend(BlockScope blockScope, Expression oper1, Expression oper2) {
1716 	int pc;
1717 	if (oper1 == null) {
1718 		/* Operand is already on the stack, and maybe nil:
1719 		note type1 is always to  java.lang.String here.*/
1720 		this.newStringContatenation();
1721 		this.dup_x1();
1722 		this.swap();
1723 		// If argument is reference type, need to transform it
1724 		// into a string (handles null case)
1725 		this.invokeStringValueOf(T_Object);
1726 		this.invokeStringConcatenationStringConstructor();
1727 	} else {
1728 		pc = position;
1729 		oper1.generateOptimizedStringConcatenationCreation(blockScope, this, oper1.implicitConversion & 0xF);
1730 		this.recordPositionsFrom(pc, oper1.sourceStart);
1731 	}
1732 	pc = position;
1733 	oper2.generateOptimizedStringConcatenation(blockScope, this, oper2.implicitConversion & 0xF);
1734 	this.recordPositionsFrom(pc, oper2.sourceStart);
1735 	this.invokeStringConcatenationToString();
1736 }
1737 /**
1738  * Code responsible to generate the suitable code to supply values for the synthetic enclosing
1739  * instance arguments of a constructor invocation of a nested type.
1740  */
generateSyntheticEnclosingInstanceValues( BlockScope currentScope, ReferenceBinding targetType, Expression enclosingInstance, ASTNode invocationSite)1741 public void generateSyntheticEnclosingInstanceValues(
1742 		BlockScope currentScope,
1743 		ReferenceBinding targetType,
1744 		Expression enclosingInstance,
1745 		ASTNode invocationSite) {
1746 
1747 	// supplying enclosing instance for the anonymous type's superclass
1748 	ReferenceBinding checkedTargetType = targetType.isAnonymousType() ? targetType.superclass() : targetType;
1749 	boolean hasExtraEnclosingInstance = enclosingInstance != null;
1750 	if (hasExtraEnclosingInstance
1751 			&& (!checkedTargetType.isNestedType() || checkedTargetType.isStatic())) {
1752 		currentScope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, checkedTargetType);
1753 		return;
1754 	}
1755 
1756 	// perform some emulation work in case there is some and we are inside a local type only
1757 	ReferenceBinding[] syntheticArgumentTypes;
1758 	if ((syntheticArgumentTypes = targetType.syntheticEnclosingInstanceTypes()) != null) {
1759 
1760 		ReferenceBinding targetEnclosingType = checkedTargetType.enclosingType();
1761 		boolean complyTo14 = currentScope.environment().options.complianceLevel >= ClassFileConstants.JDK1_4;
1762 		// deny access to enclosing instance argument for allocation and super constructor call (if 1.4)
1763 		boolean ignoreEnclosingArgInConstructorCall = invocationSite instanceof AllocationExpression
1764 					|| (complyTo14 && ((invocationSite instanceof ExplicitConstructorCall && ((ExplicitConstructorCall)invocationSite).isSuperAccess())));
1765 
1766 		for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) {
1767 			ReferenceBinding syntheticArgType = syntheticArgumentTypes[i];
1768 			if (hasExtraEnclosingInstance && syntheticArgType == targetEnclosingType) {
1769 				hasExtraEnclosingInstance = false;
1770 				enclosingInstance.generateCode(currentScope, this, true);
1771 				if (complyTo14){
1772 					dup();
1773 					invokeObjectGetClass(); // will perform null check
1774 					pop();
1775 				}
1776 			} else {
1777 				Object[] emulationPath = currentScope.getEmulationPath(
1778 						syntheticArgType,
1779 						false /*not only exact match (that is, allow compatible)*/,
1780 						ignoreEnclosingArgInConstructorCall);
1781 				this.generateOuterAccess(emulationPath, invocationSite, syntheticArgType, currentScope);
1782 			}
1783 		}
1784 		if (hasExtraEnclosingInstance){
1785 			currentScope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, checkedTargetType);
1786 		}
1787 	}
1788 }
1789 
1790 /**
1791  * Code responsible to generate the suitable code to supply values for the synthetic outer local
1792  * variable arguments of a constructor invocation of a nested type.
1793  * (bug 26122) - synthetic values for outer locals must be passed after user arguments, e.g. new X(i = 1){}
1794  */
generateSyntheticOuterArgumentValues(BlockScope currentScope, ReferenceBinding targetType, ASTNode invocationSite)1795 public void generateSyntheticOuterArgumentValues(BlockScope currentScope, ReferenceBinding targetType, ASTNode invocationSite) {
1796 
1797 	// generate the synthetic outer arguments then
1798 	SyntheticArgumentBinding syntheticArguments[];
1799 	if ((syntheticArguments = targetType.syntheticOuterLocalVariables()) != null) {
1800 		for (int i = 0, max = syntheticArguments.length; i < max; i++) {
1801 			LocalVariableBinding targetVariable = syntheticArguments[i].actualOuterLocalVariable;
1802 			VariableBinding[] emulationPath = currentScope.getEmulationPath(targetVariable);
1803 			this.generateOuterAccess(emulationPath, invocationSite, targetVariable, currentScope);
1804 		}
1805 	}
1806 }
1807 
1808 /**
1809  * @param accessBinding the access method binding to generate
1810  */
generateSyntheticBodyForConstructorAccess(SyntheticAccessMethodBinding accessBinding)1811 public void generateSyntheticBodyForConstructorAccess(SyntheticAccessMethodBinding accessBinding) {
1812 
1813 	initializeMaxLocals(accessBinding);
1814 
1815 	MethodBinding constructorBinding = accessBinding.targetMethod;
1816 	TypeBinding[] parameters = constructorBinding.parameters;
1817 	int length = parameters.length;
1818 	int resolvedPosition = 1;
1819 	this.aload_0();
1820 	if (constructorBinding.declaringClass.isNestedType()) {
1821 		NestedTypeBinding nestedType = (NestedTypeBinding) constructorBinding.declaringClass;
1822 		SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticEnclosingInstances();
1823 		for (int i = 0; i < (syntheticArguments == null ? 0 : syntheticArguments.length); i++) {
1824 			TypeBinding type;
1825 			load((type = syntheticArguments[i].type), resolvedPosition);
1826 			if ((type == DoubleBinding) || (type == LongBinding))
1827 				resolvedPosition += 2;
1828 			else
1829 				resolvedPosition++;
1830 		}
1831 	}
1832 	for (int i = 0; i < length; i++) {
1833 		load(parameters[i], resolvedPosition);
1834 		if ((parameters[i] == DoubleBinding) || (parameters[i] == LongBinding))
1835 			resolvedPosition += 2;
1836 		else
1837 			resolvedPosition++;
1838 	}
1839 
1840 	if (constructorBinding.declaringClass.isNestedType()) {
1841 		NestedTypeBinding nestedType = (NestedTypeBinding) constructorBinding.declaringClass;
1842 		SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticOuterLocalVariables();
1843 		for (int i = 0; i < (syntheticArguments == null ? 0 : syntheticArguments.length); i++) {
1844 			TypeBinding type;
1845 			load((type = syntheticArguments[i].type), resolvedPosition);
1846 			if ((type == DoubleBinding) || (type == LongBinding))
1847 				resolvedPosition += 2;
1848 			else
1849 				resolvedPosition++;
1850 		}
1851 	}
1852 	this.invokespecial(constructorBinding);
1853 	this.return_();
1854 }
generateSyntheticBodyForFieldReadAccess(SyntheticAccessMethodBinding accessBinding)1855 public void generateSyntheticBodyForFieldReadAccess(SyntheticAccessMethodBinding accessBinding) {
1856 	initializeMaxLocals(accessBinding);
1857 	FieldBinding fieldBinding = accessBinding.targetReadField;
1858 	TypeBinding type;
1859 	if (fieldBinding.isStatic())
1860 		this.getstatic(fieldBinding);
1861 	else {
1862 		this.aload_0();
1863 		this.getfield(fieldBinding);
1864 	}
1865 	if ((type = fieldBinding.type).isBaseType()) {
1866 		if (type == IntBinding)
1867 			this.ireturn();
1868 		else
1869 			if (type == FloatBinding)
1870 				this.freturn();
1871 			else
1872 				if (type == LongBinding)
1873 					this.lreturn();
1874 				else
1875 					if (type == DoubleBinding)
1876 						this.dreturn();
1877 					else
1878 						this.ireturn();
1879 	} else
1880 		this.areturn();
1881 }
generateSyntheticBodyForFieldWriteAccess(SyntheticAccessMethodBinding accessBinding)1882 public void generateSyntheticBodyForFieldWriteAccess(SyntheticAccessMethodBinding accessBinding) {
1883 	initializeMaxLocals(accessBinding);
1884 	FieldBinding fieldBinding = accessBinding.targetWriteField;
1885 	if (fieldBinding.isStatic()) {
1886 		load(fieldBinding.type, 0);
1887 		this.putstatic(fieldBinding);
1888 	} else {
1889 		this.aload_0();
1890 		load(fieldBinding.type, 1);
1891 		this.putfield(fieldBinding);
1892 	}
1893 	this.return_();
1894 }
generateSyntheticBodyForMethodAccess(SyntheticAccessMethodBinding accessBinding)1895 public void generateSyntheticBodyForMethodAccess(SyntheticAccessMethodBinding accessBinding) {
1896 
1897 	initializeMaxLocals(accessBinding);
1898 	MethodBinding methodBinding = accessBinding.targetMethod;
1899 	TypeBinding[] parameters = methodBinding.parameters;
1900 	int length = parameters.length;
1901 	TypeBinding[] arguments = accessBinding.accessType == SyntheticAccessMethodBinding.BridgeMethodAccess
1902 													? accessBinding.parameters
1903 													: null;
1904 	int resolvedPosition;
1905 	if (methodBinding.isStatic())
1906 		resolvedPosition = 0;
1907 	else {
1908 		this.aload_0();
1909 		resolvedPosition = 1;
1910 	}
1911 	for (int i = 0; i < length; i++) {
1912 	    TypeBinding parameter = parameters[i];
1913 	    if (arguments != null) { // for bridge methods
1914 		    TypeBinding argument = arguments[i];
1915 			load(argument, resolvedPosition);
1916 			if (argument != parameter)
1917 			    checkcast(parameter);
1918 	    } else {
1919 			load(parameter, resolvedPosition);
1920 		}
1921 		if ((parameter == DoubleBinding) || (parameter == LongBinding))
1922 			resolvedPosition += 2;
1923 		else
1924 			resolvedPosition++;
1925 	}
1926 	TypeBinding type;
1927 	if (methodBinding.isStatic())
1928 		this.invokestatic(methodBinding);
1929 	else {
1930 		if (methodBinding.isConstructor()
1931 			|| methodBinding.isPrivate()
1932 			// qualified super "X.super.foo()" targets methods from superclass
1933 			|| accessBinding.accessType == SyntheticAccessMethodBinding.SuperMethodAccess){
1934 			this.invokespecial(methodBinding);
1935 		} else {
1936 			if (methodBinding.declaringClass.isInterface()){
1937 				this.invokeinterface(methodBinding);
1938 			} else {
1939 				this.invokevirtual(methodBinding);
1940 			}
1941 		}
1942 	}
1943 	if ((type = methodBinding.returnType).isBaseType())
1944 		if (type == VoidBinding)
1945 			this.return_();
1946 		else
1947 			if (type == IntBinding)
1948 				this.ireturn();
1949 			else
1950 				if (type == FloatBinding)
1951 					this.freturn();
1952 				else
1953 					if (type == LongBinding)
1954 						this.lreturn();
1955 					else
1956 						if (type == DoubleBinding)
1957 							this.dreturn();
1958 						else
1959 							this.ireturn();
1960 	else
1961 		this.areturn();
1962 }
getContents()1963 final public byte[] getContents() {
1964 	byte[] contents;
1965 	System.arraycopy(bCodeStream, 0, contents = new byte[position], 0, position);
1966 	return contents;
1967 }
getfield(FieldBinding fieldBinding)1968 final public void getfield(FieldBinding fieldBinding) {
1969 	if (DEBUG) System.out.println(position + "\t\tgetfield:"+fieldBinding); //$NON-NLS-1$
1970 	countLabels = 0;
1971 	if ((fieldBinding.type.id == T_double) || (fieldBinding.type.id == T_long)) {
1972 		if (++stackDepth > stackMax)
1973 			stackMax = stackDepth;
1974 	}
1975 	if (classFileOffset + 2 >= bCodeStream.length) {
1976 		resizeByteArray();
1977 	}
1978 	position++;
1979 	bCodeStream[classFileOffset++] = OPC_getfield;
1980 	writeUnsignedShort(constantPool.literalIndex(fieldBinding));
1981 }
getstatic(FieldBinding fieldBinding)1982 final public void getstatic(FieldBinding fieldBinding) {
1983 	if (DEBUG) System.out.println(position + "\t\tgetstatic:"+fieldBinding); //$NON-NLS-1$
1984 	countLabels = 0;
1985 	if ((fieldBinding.type.id == T_double) || (fieldBinding.type.id == T_long))
1986 		stackDepth += 2;
1987 	else
1988 		stackDepth += 1;
1989 	if (stackDepth > stackMax)
1990 		stackMax = stackDepth;
1991 	if (classFileOffset + 2 >= bCodeStream.length) {
1992 		resizeByteArray();
1993 	}
1994 	position++;
1995 	bCodeStream[classFileOffset++] = OPC_getstatic;
1996 	writeUnsignedShort(constantPool.literalIndex(fieldBinding));
1997 }
getTYPE(int baseTypeID)1998 public void getTYPE(int baseTypeID) {
1999 	countLabels = 0;
2000 	if (++stackDepth > stackMax)
2001 		stackMax = stackDepth;
2002 	if (classFileOffset + 2 >= bCodeStream.length) {
2003 		resizeByteArray();
2004 	}
2005 	position++;
2006 	bCodeStream[classFileOffset++] = OPC_getstatic;
2007 	switch (baseTypeID) {
2008 		case T_byte :
2009 			// getstatic: java.lang.Byte.TYPE
2010 			if (DEBUG) System.out.println(position + "\t\tgetstatic: java.lang.Byte.TYPE"); //$NON-NLS-1$
2011 			writeUnsignedShort(constantPool.literalIndexForJavaLangByteTYPE());
2012 			break;
2013 		case T_short :
2014 			// getstatic: java.lang.Short.TYPE
2015 			if (DEBUG) System.out.println(position + "\t\tgetstatic: java.lang.Short.TYPE"); //$NON-NLS-1$
2016 			writeUnsignedShort(constantPool.literalIndexForJavaLangShortTYPE());
2017 			break;
2018 		case T_char :
2019 			// getstatic: java.lang.Character.TYPE
2020 			if (DEBUG) System.out.println(position + "\t\tgetstatic: java.lang.Character.TYPE"); //$NON-NLS-1$
2021 			writeUnsignedShort(constantPool.literalIndexForJavaLangCharacterTYPE());
2022 			break;
2023 		case T_int :
2024 			// getstatic: java.lang.Integer.TYPE
2025 			if (DEBUG) System.out.println(position + "\t\tgetstatic: java.lang.Integer.TYPE"); //$NON-NLS-1$
2026 			writeUnsignedShort(constantPool.literalIndexForJavaLangIntegerTYPE());
2027 			break;
2028 		case T_long :
2029 			// getstatic: java.lang.Long.TYPE
2030 			if (DEBUG) System.out.println(position + "\t\tgetstatic: java.lang.Long.TYPE"); //$NON-NLS-1$
2031 			writeUnsignedShort(constantPool.literalIndexForJavaLangLongTYPE());
2032 			break;
2033 		case T_float :
2034 			// getstatic: java.lang.Float.TYPE
2035 			if (DEBUG) System.out.println(position + "\t\tgetstatic: java.lang.Float.TYPE"); //$NON-NLS-1$
2036 			writeUnsignedShort(constantPool.literalIndexForJavaLangFloatTYPE());
2037 			break;
2038 		case T_double :
2039 			// getstatic: java.lang.Double.TYPE
2040 			if (DEBUG) System.out.println(position + "\t\tgetstatic: java.lang.Double.TYPE"); //$NON-NLS-1$
2041 			writeUnsignedShort(constantPool.literalIndexForJavaLangDoubleTYPE());
2042 			break;
2043 		case T_boolean :
2044 			// getstatic: java.lang.Boolean.TYPE
2045 			if (DEBUG) System.out.println(position + "\t\tgetstatic: java.lang.Boolean.TYPE"); //$NON-NLS-1$
2046 			writeUnsignedShort(constantPool.literalIndexForJavaLangBooleanTYPE());
2047 			break;
2048 		case T_void :
2049 			// getstatic: java.lang.Void.TYPE
2050 			if (DEBUG) System.out.println(position + "\t\tgetstatic: java.lang.Void.TYPE"); //$NON-NLS-1$
2051 			writeUnsignedShort(constantPool.literalIndexForJavaLangVoidTYPE());
2052 			break;
2053 	}
2054 }
2055 /**
2056  * We didn't call it goto, because there is a conflit with the goto keyword
2057  */
goto_(Label label)2058 final public void goto_(Label label) {
2059 	if (this.wideMode) {
2060 		this.goto_w(label);
2061 		return;
2062 	}
2063 	if (DEBUG) System.out.println(position + "\t\tgoto:"+label); //$NON-NLS-1$
2064 	if (classFileOffset >= bCodeStream.length) {
2065 		resizeByteArray();
2066 	}
2067 	label.inlineForwardReferencesFromLabelsTargeting(position);
2068 	/*
2069 	 Possible optimization for code such as:
2070 	 public Object foo() {
2071 		boolean b = true;
2072 		if (b) {
2073 			if (b)
2074 				return null;
2075 		} else {
2076 			if (b) {
2077 				return null;
2078 			}
2079 		}
2080 		return null;
2081 	}
2082 	The goto around the else block for the first if will
2083 	be unreachable, because the thenClause of the second if
2084 	returns.
2085 	See inlineForwardReferencesFromLabelsTargeting defined
2086 	on the Label class for the remaining part of this
2087 	optimization.
2088 	 if (!lbl.isBranchTarget(position)) {
2089 		switch(bCodeStream[classFileOffset-1]) {
2090 			case OPC_return :
2091 			case OPC_areturn:
2092 				return;
2093 		}
2094 	}*/
2095 	position++;
2096 	bCodeStream[classFileOffset++] = OPC_goto;
2097 	label.branch();
2098 }
2099 
goto_w(Label lbl)2100 final public void goto_w(Label lbl) {
2101 	if (DEBUG) System.out.println(position + "\t\tgotow:"+lbl); //$NON-NLS-1$
2102 	if (classFileOffset >= bCodeStream.length) {
2103 		resizeByteArray();
2104 	}
2105 	position++;
2106 	bCodeStream[classFileOffset++] = OPC_goto_w;
2107 	lbl.branchWide();
2108 }
i2b()2109 final public void i2b() {
2110 	if (DEBUG) System.out.println(position + "\t\ti2b"); //$NON-NLS-1$
2111 	countLabels = 0;
2112 	if (classFileOffset >= bCodeStream.length) {
2113 		resizeByteArray();
2114 	}
2115 	position++;
2116 	bCodeStream[classFileOffset++] = OPC_i2b;
2117 }
i2c()2118 final public void i2c() {
2119 	if (DEBUG) System.out.println(position + "\t\ti2c"); //$NON-NLS-1$
2120 	countLabels = 0;
2121 	if (classFileOffset >= bCodeStream.length) {
2122 		resizeByteArray();
2123 	}
2124 	position++;
2125 	bCodeStream[classFileOffset++] = OPC_i2c;
2126 }
i2d()2127 final public void i2d() {
2128 	if (DEBUG) System.out.println(position + "\t\ti2d"); //$NON-NLS-1$
2129 	countLabels = 0;
2130 	stackDepth++;
2131 	if (stackDepth > stackMax)
2132 		stackMax = stackDepth;
2133 	if (classFileOffset >= bCodeStream.length) {
2134 		resizeByteArray();
2135 	}
2136 	position++;
2137 	bCodeStream[classFileOffset++] = OPC_i2d;
2138 }
i2f()2139 final public void i2f() {
2140 	if (DEBUG) System.out.println(position + "\t\ti2f"); //$NON-NLS-1$
2141 	countLabels = 0;
2142 	if (classFileOffset >= bCodeStream.length) {
2143 		resizeByteArray();
2144 	}
2145 	position++;
2146 	bCodeStream[classFileOffset++] = OPC_i2f;
2147 }
i2l()2148 final public void i2l() {
2149 	if (DEBUG) System.out.println(position + "\t\ti2l"); //$NON-NLS-1$
2150 	countLabels = 0;
2151 	stackDepth++;
2152 	if (stackDepth > stackMax)
2153 		stackMax = stackDepth;
2154 	if (classFileOffset >= bCodeStream.length) {
2155 		resizeByteArray();
2156 	}
2157 	position++;
2158 	bCodeStream[classFileOffset++] = OPC_i2l;
2159 }
i2s()2160 final public void i2s() {
2161 	if (DEBUG) System.out.println(position + "\t\ti2s"); //$NON-NLS-1$
2162 	countLabels = 0;
2163 	if (classFileOffset >= bCodeStream.length) {
2164 		resizeByteArray();
2165 	}
2166 	position++;
2167 	bCodeStream[classFileOffset++] = OPC_i2s;
2168 }
iadd()2169 final public void iadd() {
2170 	if (DEBUG) System.out.println(position + "\t\tiadd"); //$NON-NLS-1$
2171 	countLabels = 0;
2172 	stackDepth--;
2173 	if (classFileOffset >= bCodeStream.length) {
2174 		resizeByteArray();
2175 	}
2176 	position++;
2177 	bCodeStream[classFileOffset++] = OPC_iadd;
2178 }
iaload()2179 final public void iaload() {
2180 	if (DEBUG) System.out.println(position + "\t\tiaload"); //$NON-NLS-1$
2181 	countLabels = 0;
2182 	stackDepth--;
2183 	if (classFileOffset >= bCodeStream.length) {
2184 		resizeByteArray();
2185 	}
2186 	position++;
2187 	bCodeStream[classFileOffset++] = OPC_iaload;
2188 }
iand()2189 final public void iand() {
2190 	if (DEBUG) System.out.println(position + "\t\tiand"); //$NON-NLS-1$
2191 	countLabels = 0;
2192 	stackDepth--;
2193 	if (classFileOffset >= bCodeStream.length) {
2194 		resizeByteArray();
2195 	}
2196 	position++;
2197 	bCodeStream[classFileOffset++] = OPC_iand;
2198 }
iastore()2199 final public void iastore() {
2200 	if (DEBUG) System.out.println(position + "\t\tiastore"); //$NON-NLS-1$
2201 	countLabels = 0;
2202 	stackDepth -= 3;
2203 	if (classFileOffset >= bCodeStream.length) {
2204 		resizeByteArray();
2205 	}
2206 	position++;
2207 	bCodeStream[classFileOffset++] = OPC_iastore;
2208 }
iconst_0()2209 final public void iconst_0() {
2210 	if (DEBUG) System.out.println(position + "\t\ticonst_0"); //$NON-NLS-1$
2211 	countLabels = 0;
2212 	stackDepth++;
2213 	if (stackDepth > stackMax)
2214 		stackMax = stackDepth;
2215 	if (classFileOffset >= bCodeStream.length) {
2216 		resizeByteArray();
2217 	}
2218 	position++;
2219 	bCodeStream[classFileOffset++] = OPC_iconst_0;
2220 }
iconst_1()2221 final public void iconst_1() {
2222 	if (DEBUG) System.out.println(position + "\t\ticonst_1"); //$NON-NLS-1$
2223 	countLabels = 0;
2224 	stackDepth++;
2225 	if (stackDepth > stackMax)
2226 		stackMax = stackDepth;
2227 	if (classFileOffset >= bCodeStream.length) {
2228 		resizeByteArray();
2229 	}
2230 	position++;
2231 	bCodeStream[classFileOffset++] = OPC_iconst_1;
2232 }
iconst_2()2233 final public void iconst_2() {
2234 	if (DEBUG) System.out.println(position + "\t\ticonst_2"); //$NON-NLS-1$
2235 	countLabels = 0;
2236 	stackDepth++;
2237 	if (stackDepth > stackMax)
2238 		stackMax = stackDepth;
2239 	if (classFileOffset >= bCodeStream.length) {
2240 		resizeByteArray();
2241 	}
2242 	position++;
2243 	bCodeStream[classFileOffset++] = OPC_iconst_2;
2244 }
iconst_3()2245 final public void iconst_3() {
2246 	if (DEBUG) System.out.println(position + "\t\ticonst_3"); //$NON-NLS-1$
2247 	countLabels = 0;
2248 	stackDepth++;
2249 	if (stackDepth > stackMax)
2250 		stackMax = stackDepth;
2251 	if (classFileOffset >= bCodeStream.length) {
2252 		resizeByteArray();
2253 	}
2254 	position++;
2255 	bCodeStream[classFileOffset++] = OPC_iconst_3;
2256 }
iconst_4()2257 final public void iconst_4() {
2258 	if (DEBUG) System.out.println(position + "\t\ticonst_4"); //$NON-NLS-1$
2259 	countLabels = 0;
2260 	stackDepth++;
2261 	if (stackDepth > stackMax)
2262 		stackMax = stackDepth;
2263 	if (classFileOffset >= bCodeStream.length) {
2264 		resizeByteArray();
2265 	}
2266 	position++;
2267 	bCodeStream[classFileOffset++] = OPC_iconst_4;
2268 }
iconst_5()2269 final public void iconst_5() {
2270 	if (DEBUG) System.out.println(position + "\t\ticonst_5"); //$NON-NLS-1$
2271 	countLabels = 0;
2272 	stackDepth++;
2273 	if (stackDepth > stackMax)
2274 		stackMax = stackDepth;
2275 	if (classFileOffset >= bCodeStream.length) {
2276 		resizeByteArray();
2277 	}
2278 	position++;
2279 	bCodeStream[classFileOffset++] = OPC_iconst_5;
2280 }
iconst_m1()2281 final public void iconst_m1() {
2282 	if (DEBUG) System.out.println(position + "\t\ticonst_m1"); //$NON-NLS-1$
2283 	countLabels = 0;
2284 	stackDepth++;
2285 	if (stackDepth > stackMax)
2286 		stackMax = stackDepth;
2287 	if (classFileOffset >= bCodeStream.length) {
2288 		resizeByteArray();
2289 	}
2290 	position++;
2291 	bCodeStream[classFileOffset++] = OPC_iconst_m1;
2292 }
idiv()2293 final public void idiv() {
2294 	if (DEBUG) System.out.println(position + "\t\tidiv"); //$NON-NLS-1$
2295 	countLabels = 0;
2296 	stackDepth--;
2297 	if (classFileOffset >= bCodeStream.length) {
2298 		resizeByteArray();
2299 	}
2300 	position++;
2301 	bCodeStream[classFileOffset++] = OPC_idiv;
2302 }
if_acmpeq(Label lbl)2303 final public void if_acmpeq(Label lbl) {
2304 	if (DEBUG) System.out.println(position + "\t\tif_acmpeq:"+lbl); //$NON-NLS-1$
2305 	countLabels = 0;
2306 	stackDepth-=2;
2307 	if (this.wideMode) {
2308 		generateWideRevertedConditionalBranch(OPC_if_acmpne, lbl);
2309 	} else {
2310 		if (classFileOffset >= bCodeStream.length) {
2311 			resizeByteArray();
2312 		}
2313 		position++;
2314 		bCodeStream[classFileOffset++] = OPC_if_acmpeq;
2315 		lbl.branch();
2316 	}
2317 }
if_acmpne(Label lbl)2318 final public void if_acmpne(Label lbl) {
2319 	if (DEBUG) System.out.println(position + "\t\tif_acmpne:"+lbl); //$NON-NLS-1$
2320 	countLabels = 0;
2321 	stackDepth-=2;
2322 	if (this.wideMode) {
2323 		generateWideRevertedConditionalBranch(OPC_if_acmpeq, lbl);
2324 	} else {
2325 		if (classFileOffset >= bCodeStream.length) {
2326 			resizeByteArray();
2327 		}
2328 		position++;
2329 		bCodeStream[classFileOffset++] = OPC_if_acmpne;
2330 		lbl.branch();
2331 	}
2332 }
if_icmpeq(Label lbl)2333 final public void if_icmpeq(Label lbl) {
2334 	if (DEBUG) System.out.println(position + "\t\tif_cmpeq:"+lbl); //$NON-NLS-1$
2335 	countLabels = 0;
2336 	stackDepth -= 2;
2337 	if (this.wideMode) {
2338 		generateWideRevertedConditionalBranch(OPC_if_icmpne, lbl);
2339 	} else {
2340 		if (classFileOffset >= bCodeStream.length) {
2341 			resizeByteArray();
2342 		}
2343 		position++;
2344 		bCodeStream[classFileOffset++] = OPC_if_icmpeq;
2345 		lbl.branch();
2346 	}
2347 }
if_icmpge(Label lbl)2348 final public void if_icmpge(Label lbl) {
2349 	if (DEBUG) System.out.println(position + "\t\tif_iacmpge:"+lbl); //$NON-NLS-1$
2350 	countLabels = 0;
2351 	stackDepth -= 2;
2352 	if (this.wideMode) {
2353 		generateWideRevertedConditionalBranch(OPC_if_icmplt, lbl);
2354 	} else {
2355 		if (classFileOffset >= bCodeStream.length) {
2356 			resizeByteArray();
2357 		}
2358 		position++;
2359 		bCodeStream[classFileOffset++] = OPC_if_icmpge;
2360 		lbl.branch();
2361 	}
2362 }
if_icmpgt(Label lbl)2363 final public void if_icmpgt(Label lbl) {
2364 	if (DEBUG) System.out.println(position + "\t\tif_iacmpgt:"+lbl); //$NON-NLS-1$
2365 	countLabels = 0;
2366 	stackDepth -= 2;
2367 	if (this.wideMode) {
2368 		generateWideRevertedConditionalBranch(OPC_if_icmple, lbl);
2369 	} else {
2370 		if (classFileOffset >= bCodeStream.length) {
2371 			resizeByteArray();
2372 		}
2373 		position++;
2374 		bCodeStream[classFileOffset++] = OPC_if_icmpgt;
2375 		lbl.branch();
2376 	}
2377 }
if_icmple(Label lbl)2378 final public void if_icmple(Label lbl) {
2379 	if (DEBUG) System.out.println(position + "\t\tif_iacmple:"+lbl); //$NON-NLS-1$
2380 	countLabels = 0;
2381 	stackDepth -= 2;
2382 	if (this.wideMode) {
2383 		generateWideRevertedConditionalBranch(OPC_if_icmpgt, lbl);
2384 	} else {
2385 		if (classFileOffset >= bCodeStream.length) {
2386 			resizeByteArray();
2387 		}
2388 		position++;
2389 		bCodeStream[classFileOffset++] = OPC_if_icmple;
2390 		lbl.branch();
2391 	}
2392 }
if_icmplt(Label lbl)2393 final public void if_icmplt(Label lbl) {
2394 	if (DEBUG) System.out.println(position + "\t\tif_iacmplt:"+lbl); //$NON-NLS-1$
2395 	countLabels = 0;
2396 	stackDepth -= 2;
2397 	if (this.wideMode) {
2398 		generateWideRevertedConditionalBranch(OPC_if_icmpge, lbl);
2399 	} else {
2400 		if (classFileOffset >= bCodeStream.length) {
2401 			resizeByteArray();
2402 		}
2403 		position++;
2404 		bCodeStream[classFileOffset++] = OPC_if_icmplt;
2405 		lbl.branch();
2406 	}
2407 }
if_icmpne(Label lbl)2408 final public void if_icmpne(Label lbl) {
2409 	if (DEBUG) System.out.println(position + "\t\tif_iacmpne:"+lbl); //$NON-NLS-1$
2410 	countLabels = 0;
2411 	stackDepth -= 2;
2412 	if (this.wideMode) {
2413 		generateWideRevertedConditionalBranch(OPC_if_icmpeq, lbl);
2414 	} else {
2415 		if (classFileOffset >= bCodeStream.length) {
2416 			resizeByteArray();
2417 		}
2418 		position++;
2419 		bCodeStream[classFileOffset++] = OPC_if_icmpne;
2420 		lbl.branch();
2421 	}
2422 }
ifeq(Label lbl)2423 final public void ifeq(Label lbl) {
2424 	if (DEBUG) System.out.println(position + "\t\tifeq:"+lbl); //$NON-NLS-1$
2425 	countLabels = 0;
2426 	stackDepth--;
2427 	if (this.wideMode) {
2428 		generateWideRevertedConditionalBranch(OPC_ifne, lbl);
2429 	} else {
2430 		if (classFileOffset >= bCodeStream.length) {
2431 			resizeByteArray();
2432 		}
2433 		position++;
2434 		bCodeStream[classFileOffset++] = OPC_ifeq;
2435 		lbl.branch();
2436 	}
2437 }
ifge(Label lbl)2438 final public void ifge(Label lbl) {
2439 	if (DEBUG) System.out.println(position + "\t\tifge:"+lbl); //$NON-NLS-1$
2440 	countLabels = 0;
2441 	stackDepth--;
2442 	if (this.wideMode) {
2443 		generateWideRevertedConditionalBranch(OPC_iflt, lbl);
2444 	} else {
2445 		if (classFileOffset >= bCodeStream.length) {
2446 			resizeByteArray();
2447 		}
2448 		position++;
2449 		bCodeStream[classFileOffset++] = OPC_ifge;
2450 		lbl.branch();
2451 	}
2452 }
ifgt(Label lbl)2453 final public void ifgt(Label lbl) {
2454 	if (DEBUG) System.out.println(position + "\t\tifgt:"+lbl); //$NON-NLS-1$
2455 	countLabels = 0;
2456 	stackDepth--;
2457 	if (this.wideMode) {
2458 		generateWideRevertedConditionalBranch(OPC_ifle, lbl);
2459 	} else {
2460 		if (classFileOffset >= bCodeStream.length) {
2461 			resizeByteArray();
2462 		}
2463 		position++;
2464 		bCodeStream[classFileOffset++] = OPC_ifgt;
2465 		lbl.branch();
2466 	}
2467 }
ifle(Label lbl)2468 final public void ifle(Label lbl) {
2469 	if (DEBUG) System.out.println(position + "\t\tifle:"+lbl); //$NON-NLS-1$
2470 	countLabels = 0;
2471 	stackDepth--;
2472 	if (this.wideMode) {
2473 		generateWideRevertedConditionalBranch(OPC_ifgt, lbl);
2474 	} else {
2475 		if (classFileOffset >= bCodeStream.length) {
2476 			resizeByteArray();
2477 		}
2478 		position++;
2479 		bCodeStream[classFileOffset++] = OPC_ifle;
2480 		lbl.branch();
2481 	}
2482 }
iflt(Label lbl)2483 final public void iflt(Label lbl) {
2484 	if (DEBUG) System.out.println(position + "\t\tiflt:"+lbl); //$NON-NLS-1$
2485 	countLabels = 0;
2486 	stackDepth--;
2487 	if (this.wideMode) {
2488 		generateWideRevertedConditionalBranch(OPC_ifge, lbl);
2489 	} else {
2490 		if (classFileOffset >= bCodeStream.length) {
2491 			resizeByteArray();
2492 		}
2493 		position++;
2494 		bCodeStream[classFileOffset++] = OPC_iflt;
2495 		lbl.branch();
2496 	}
2497 }
ifne(Label lbl)2498 final public void ifne(Label lbl) {
2499 	if (DEBUG) System.out.println(position + "\t\tifne:"+lbl); //$NON-NLS-1$
2500 	countLabels = 0;
2501 	stackDepth--;
2502 	if (this.wideMode) {
2503 		generateWideRevertedConditionalBranch(OPC_ifeq, lbl);
2504 	} else {
2505 		if (classFileOffset >= bCodeStream.length) {
2506 			resizeByteArray();
2507 		}
2508 		position++;
2509 		bCodeStream[classFileOffset++] = OPC_ifne;
2510 		lbl.branch();
2511 	}
2512 }
ifnonnull(Label lbl)2513 final public void ifnonnull(Label lbl) {
2514 	if (DEBUG) System.out.println(position + "\t\tifnonnull:"+lbl); //$NON-NLS-1$
2515 	countLabels = 0;
2516 	stackDepth--;
2517 	if (this.wideMode) {
2518 		generateWideRevertedConditionalBranch(OPC_ifnull, lbl);
2519 	} else {
2520 		if (classFileOffset >= bCodeStream.length) {
2521 			resizeByteArray();
2522 		}
2523 		position++;
2524 		bCodeStream[classFileOffset++] = OPC_ifnonnull;
2525 		lbl.branch();
2526 	}
2527 }
ifnull(Label lbl)2528 final public void ifnull(Label lbl) {
2529 	if (DEBUG) System.out.println(position + "\t\tifnull:"+lbl); //$NON-NLS-1$
2530 	countLabels = 0;
2531 	stackDepth--;
2532 	if (this.wideMode) {
2533 		generateWideRevertedConditionalBranch(OPC_ifnonnull, lbl);
2534 	} else {
2535 		if (classFileOffset >= bCodeStream.length) {
2536 			resizeByteArray();
2537 		}
2538 		position++;
2539 		bCodeStream[classFileOffset++] = OPC_ifnull;
2540 		lbl.branch();
2541 	}
2542 }
iinc(int index, int value)2543 final public void iinc(int index, int value) {
2544 	if (DEBUG) System.out.println(position + "\t\tiinc:"+index+","+value); //$NON-NLS-1$ //$NON-NLS-2$
2545 	countLabels = 0;
2546 	if ((index > 255) || (value < -128 || value > 127)) { // have to widen
2547 		if (classFileOffset + 3 >= bCodeStream.length) {
2548 			resizeByteArray();
2549 		}
2550 		position += 2;
2551 		bCodeStream[classFileOffset++] = OPC_wide;
2552 		bCodeStream[classFileOffset++] = OPC_iinc;
2553 		writeUnsignedShort(index);
2554 		writeSignedShort(value);
2555 	} else {
2556 		if (classFileOffset + 2 >= bCodeStream.length) {
2557 			resizeByteArray();
2558 		}
2559 		position += 3;
2560 		bCodeStream[classFileOffset++] = OPC_iinc;
2561 		bCodeStream[classFileOffset++] = (byte) index;
2562 		bCodeStream[classFileOffset++] = (byte) value;
2563 	}
2564 }
iload(int iArg)2565 final public void iload(int iArg) {
2566 	if (DEBUG) System.out.println(position + "\t\tiload:"+iArg); //$NON-NLS-1$
2567 	countLabels = 0;
2568 	stackDepth++;
2569 	if (maxLocals <= iArg) {
2570 		maxLocals = iArg + 1;
2571 	}
2572 	if (stackDepth > stackMax)
2573 		stackMax = stackDepth;
2574 	if (iArg > 255) { // Widen
2575 		if (classFileOffset + 3 >= bCodeStream.length) {
2576 			resizeByteArray();
2577 		}
2578 		position += 2;
2579 		bCodeStream[classFileOffset++] = OPC_wide;
2580 		bCodeStream[classFileOffset++] = OPC_iload;
2581 		writeUnsignedShort(iArg);
2582 	} else {
2583 		if (classFileOffset + 1 >= bCodeStream.length) {
2584 			resizeByteArray();
2585 		}
2586 		position += 2;
2587 		bCodeStream[classFileOffset++] = OPC_iload;
2588 		bCodeStream[classFileOffset++] = (byte) iArg;
2589 	}
2590 }
iload_0()2591 final public void iload_0() {
2592 	if (DEBUG) System.out.println(position + "\t\tiload_0"); //$NON-NLS-1$
2593 	countLabels = 0;
2594 	stackDepth++;
2595 	if (maxLocals <= 0) {
2596 		maxLocals = 1;
2597 	}
2598 	if (stackDepth > stackMax)
2599 		stackMax = stackDepth;
2600 	if (classFileOffset >= bCodeStream.length) {
2601 		resizeByteArray();
2602 	}
2603 	position++;
2604 	bCodeStream[classFileOffset++] = OPC_iload_0;
2605 }
iload_1()2606 final public void iload_1() {
2607 	if (DEBUG) System.out.println(position + "\t\tiload_1"); //$NON-NLS-1$
2608 	countLabels = 0;
2609 	stackDepth++;
2610 	if (maxLocals <= 1) {
2611 		maxLocals = 2;
2612 	}
2613 	if (stackDepth > stackMax)
2614 		stackMax = stackDepth;
2615 	if (classFileOffset >= bCodeStream.length) {
2616 		resizeByteArray();
2617 	}
2618 	position++;
2619 	bCodeStream[classFileOffset++] = OPC_iload_1;
2620 }
iload_2()2621 final public void iload_2() {
2622 	if (DEBUG) System.out.println(position + "\t\tiload_2"); //$NON-NLS-1$
2623 	countLabels = 0;
2624 	stackDepth++;
2625 	if (maxLocals <= 2) {
2626 		maxLocals = 3;
2627 	}
2628 	if (stackDepth > stackMax)
2629 		stackMax = stackDepth;
2630 	if (classFileOffset >= bCodeStream.length) {
2631 		resizeByteArray();
2632 	}
2633 	position++;
2634 	bCodeStream[classFileOffset++] = OPC_iload_2;
2635 }
iload_3()2636 final public void iload_3() {
2637 	if (DEBUG) System.out.println(position + "\t\tiload_3"); //$NON-NLS-1$
2638 	countLabels = 0;
2639 	stackDepth++;
2640 	if (maxLocals <= 3) {
2641 		maxLocals = 4;
2642 	}
2643 	if (stackDepth > stackMax)
2644 		stackMax = stackDepth;
2645 	if (classFileOffset >= bCodeStream.length) {
2646 		resizeByteArray();
2647 	}
2648 	position++;
2649 	bCodeStream[classFileOffset++] = OPC_iload_3;
2650 }
imul()2651 final public void imul() {
2652 	if (DEBUG) System.out.println(position + "\t\timul"); //$NON-NLS-1$
2653 	countLabels = 0;
2654 	stackDepth--;
2655 	if (classFileOffset >= bCodeStream.length) {
2656 		resizeByteArray();
2657 	}
2658 	position++;
2659 	bCodeStream[classFileOffset++] = OPC_imul;
2660 }
incrementTemp(LocalVariableBinding localBinding, int value)2661 public void incrementTemp(LocalVariableBinding localBinding, int value) {
2662 	if (value == (short) value) {
2663 		this.iinc(localBinding.resolvedPosition, value);
2664 		return;
2665 	}
2666 	load(localBinding);
2667 	this.ldc(value);
2668 	this.iadd();
2669 	store(localBinding, false);
2670 }
incrStackSize(int offset)2671 public void incrStackSize(int offset) {
2672 	if ((stackDepth += offset) > stackMax)
2673 		stackMax = stackDepth;
2674 }
indexOfSameLineEntrySincePC(int pc, int line)2675 public int indexOfSameLineEntrySincePC(int pc, int line) {
2676 	for (int index = pc, max = pcToSourceMapSize; index < max; index+=2) {
2677 		if (pcToSourceMap[index+1] == line)
2678 			return index;
2679 	}
2680 	return -1;
2681 }
ineg()2682 final public void ineg() {
2683 	if (DEBUG) System.out.println(position + "\t\tineg"); //$NON-NLS-1$
2684 	countLabels = 0;
2685 	if (classFileOffset >= bCodeStream.length) {
2686 		resizeByteArray();
2687 	}
2688 	position++;
2689 	bCodeStream[classFileOffset++] = OPC_ineg;
2690 }
init(ClassFile targetClassFile)2691 public void init(ClassFile targetClassFile) {
2692 	this.classFile = targetClassFile;
2693 	this.constantPool = targetClassFile.constantPool;
2694 	this.bCodeStream = targetClassFile.contents;
2695 	this.classFileOffset = targetClassFile.contentsOffset;
2696 	this.startingClassFileOffset = this.classFileOffset;
2697 	pcToSourceMapSize = 0;
2698 	lastEntryPC = 0;
2699 	int length = visibleLocals.length;
2700 	if (noVisibleLocals.length < length) {
2701 		noVisibleLocals = new LocalVariableBinding[length];
2702 	}
2703 	System.arraycopy(noVisibleLocals, 0, visibleLocals, 0, length);
2704 	visibleLocalsCount = 0;
2705 
2706 	length = locals.length;
2707 	if (noLocals.length < length) {
2708 		noLocals = new LocalVariableBinding[length];
2709 	}
2710 	System.arraycopy(noLocals, 0, locals, 0, length);
2711 	allLocalsCounter = 0;
2712 
2713 	length = exceptionHandlers.length;
2714 	if (noExceptionHandlers.length < length) {
2715 		noExceptionHandlers = new ExceptionLabel[length];
2716 	}
2717 	System.arraycopy(noExceptionHandlers, 0, exceptionHandlers, 0, length);
2718 	exceptionHandlersIndex = 0;
2719 	exceptionHandlersCounter = 0;
2720 
2721 	length = labels.length;
2722 	if (noLabels.length < length) {
2723 		noLabels = new Label[length];
2724 	}
2725 	System.arraycopy(noLabels, 0, labels, 0, length);
2726 	countLabels = 0;
2727 
2728 	stackMax = 0;
2729 	stackDepth = 0;
2730 	maxLocals = 0;
2731 	position = 0;
2732 }
2733 /**
2734  * @param methodBinding the given method binding to initialize the max locals
2735  */
initializeMaxLocals(MethodBinding methodBinding)2736 public void initializeMaxLocals(MethodBinding methodBinding) {
2737 
2738 	maxLocals = (methodBinding == null || methodBinding.isStatic()) ? 0 : 1;
2739 	// take into account the synthetic parameters
2740 	if (methodBinding != null) {
2741 		if (methodBinding.isConstructor() && methodBinding.declaringClass.isNestedType()) {
2742 			ReferenceBinding enclosingInstanceTypes[];
2743 			if ((enclosingInstanceTypes = methodBinding.declaringClass.syntheticEnclosingInstanceTypes()) != null) {
2744 				for (int i = 0, max = enclosingInstanceTypes.length; i < max; i++) {
2745 					maxLocals++; // an enclosingInstanceType can only be a reference binding. It cannot be
2746 					// LongBinding or DoubleBinding
2747 				}
2748 			}
2749 			SyntheticArgumentBinding syntheticArguments[];
2750 			if ((syntheticArguments = methodBinding.declaringClass.syntheticOuterLocalVariables()) != null) {
2751 				for (int i = 0, max = syntheticArguments.length; i < max; i++) {
2752 					TypeBinding argType;
2753 					if (((argType = syntheticArguments[i].type) == LongBinding) || (argType == DoubleBinding)) {
2754 						maxLocals += 2;
2755 					} else {
2756 						maxLocals++;
2757 					}
2758 				}
2759 			}
2760 		}
2761 		TypeBinding[] arguments;
2762 		if ((arguments = methodBinding.parameters) != null) {
2763 			for (int i = 0, max = arguments.length; i < max; i++) {
2764 				TypeBinding argType;
2765 				if (((argType = arguments[i]) == LongBinding) || (argType == DoubleBinding)) {
2766 					maxLocals += 2;
2767 				} else {
2768 					maxLocals++;
2769 				}
2770 			}
2771 		}
2772 	}
2773 }
2774 /**
2775  * This methods searches for an existing entry inside the pcToSourceMap table with a pc equals to @pc.
2776  * If there is an existing entry it returns -1 (no insertion required).
2777  * Otherwise it returns the index where the entry for the pc has to be inserted.
2778  * This is based on the fact that the pcToSourceMap table is sorted according to the pc.
2779  *
2780  * @param pcToSourceMap the given pcToSourceMap array
2781  * @param length the given length
2782  * @param pc the given pc
2783  * @return int
2784  */
insertionIndex(int[] pcToSourceMap, int length, int pc)2785 public static int insertionIndex(int[] pcToSourceMap, int length, int pc) {
2786 	int g = 0;
2787 	int d = length - 2;
2788 	int m = 0;
2789 	while (g <= d) {
2790 		m = (g + d) / 2;
2791 		// we search only on even indexes
2792 		if ((m % 2) != 0)
2793 			m--;
2794 		int currentPC = pcToSourceMap[m];
2795 		if (pc < currentPC) {
2796 			d = m - 2;
2797 		} else
2798 			if (pc > currentPC) {
2799 				g = m + 2;
2800 			} else {
2801 				return -1;
2802 			}
2803 	}
2804 	if (pc < pcToSourceMap[m])
2805 		return m;
2806 	return m + 2;
2807 }
2808 /**
2809  * We didn't call it instanceof because there is a conflit with the
2810  * instanceof keyword
2811  */
instance_of(TypeBinding typeBinding)2812 final public void instance_of(TypeBinding typeBinding) {
2813 	if (DEBUG) System.out.println(position + "\t\tinstance_of:"+typeBinding); //$NON-NLS-1$
2814 	countLabels = 0;
2815 	if (classFileOffset + 2 >= bCodeStream.length) {
2816 		resizeByteArray();
2817 	}
2818 	position++;
2819 	bCodeStream[classFileOffset++] = OPC_instanceof;
2820 	writeUnsignedShort(constantPool.literalIndex(typeBinding));
2821 }
invokeClassForName()2822 public void invokeClassForName() {
2823 	// invokestatic: java.lang.Class.forName(Ljava.lang.String;)Ljava.lang.Class;
2824 	if (DEBUG) System.out.println(position + "\t\tinvokestatic: java.lang.Class.forName(Ljava.lang.String;)Ljava.lang.Class;"); //$NON-NLS-1$
2825 	countLabels = 0;
2826 	if (classFileOffset + 2 >= bCodeStream.length) {
2827 		resizeByteArray();
2828 	}
2829 	position++;
2830 	bCodeStream[classFileOffset++] = OPC_invokestatic;
2831 	writeUnsignedShort(constantPool.literalIndexForJavaLangClassForName());
2832 }
invokeJavaLangClassDesiredAssertionStatus()2833 public void invokeJavaLangClassDesiredAssertionStatus() {
2834 	// invokevirtual: java.lang.Class.desiredAssertionStatus()Z;
2835 	if (DEBUG) System.out.println(position + "\t\tinvokevirtual: java.lang.Class.desiredAssertionStatus()Z;"); //$NON-NLS-1$
2836 	countLabels = 0;
2837 	stackDepth--;
2838 	if (classFileOffset + 2 >= bCodeStream.length) {
2839 		resizeByteArray();
2840 	}
2841 	position++;
2842 	bCodeStream[classFileOffset++] = OPC_invokevirtual;
2843 	writeUnsignedShort(constantPool.literalIndexForJavaLangClassDesiredAssertionStatus());
2844 }
2845 
invokeJavaLangClassGetComponentType()2846 public void invokeJavaLangClassGetComponentType() {
2847 	// invokevirtual: java.lang.Class.getComponentType()java.lang.Class;
2848 	if (DEBUG) System.out.println(position + "\t\tinvokevirtual: java.lang.Class.getComponentType()java.lang.Class;"); //$NON-NLS-1$
2849 	countLabels = 0;
2850 	if (classFileOffset + 2 >= bCodeStream.length) {
2851 		resizeByteArray();
2852 	}
2853 	position++;
2854 	bCodeStream[classFileOffset++] = OPC_invokevirtual;
2855 	writeUnsignedShort(constantPool.literalIndexForJavaLangClassGetComponentType());
2856 }
2857 
invokeinterface(MethodBinding methodBinding)2858 final public void invokeinterface(MethodBinding methodBinding) {
2859 	// initialized to 1 to take into account this  immediately
2860 	if (DEBUG) System.out.println(position + "\t\tinvokeinterface: " + methodBinding); //$NON-NLS-1$
2861 	countLabels = 0;
2862 	int argCount = 1;
2863 	int id;
2864 	if (classFileOffset + 4 >= bCodeStream.length) {
2865 		resizeByteArray();
2866 	}
2867 	position += 3;
2868 	bCodeStream[classFileOffset++] = OPC_invokeinterface;
2869 	writeUnsignedShort(constantPool.literalIndex(methodBinding));
2870 	for (int i = methodBinding.parameters.length - 1; i >= 0; i--)
2871 		if (((id = methodBinding.parameters[i].id) == T_double) || (id == T_long))
2872 			argCount += 2;
2873 		else
2874 			argCount += 1;
2875 	bCodeStream[classFileOffset++] = (byte) argCount;
2876 	// Generate a  0 into the byte array. Like the array is already fill with 0, we just need to increment
2877 	// the number of bytes.
2878 	bCodeStream[classFileOffset++] = 0;
2879 	if (((id = methodBinding.returnType.id) == T_double) || (id == T_long)) {
2880 		stackDepth += (2 - argCount);
2881 	} else {
2882 		if (id == T_void) {
2883 			stackDepth -= argCount;
2884 		} else {
2885 			stackDepth += (1 - argCount);
2886 		}
2887 	}
2888 	if (stackDepth > stackMax) {
2889 		stackMax = stackDepth;
2890 	}
2891 }
invokeJavaLangErrorConstructor()2892 public void invokeJavaLangErrorConstructor() {
2893 	// invokespecial: java.lang.Error<init>(Ljava.lang.String;)V
2894 	if (DEBUG) System.out.println(position + "\t\tinvokespecial: java.lang.Error<init>(Ljava.lang.String;)V"); //$NON-NLS-1$
2895 	countLabels = 0;
2896 	if (classFileOffset + 2 >= bCodeStream.length) {
2897 		resizeByteArray();
2898 	}
2899 	position++;
2900 	bCodeStream[classFileOffset++] = OPC_invokespecial;
2901 	stackDepth -= 2;
2902 	writeUnsignedShort(constantPool.literalIndexForJavaLangErrorConstructor());
2903 }
invokeNoClassDefFoundErrorStringConstructor()2904 public void invokeNoClassDefFoundErrorStringConstructor() {
2905 	// invokespecial: java.lang.NoClassDefFoundError.<init>(Ljava.lang.String;)V
2906 	if (DEBUG) System.out.println(position + "\t\tinvokespecial: java.lang.NoClassDefFoundError.<init>(Ljava.lang.String;)V"); //$NON-NLS-1$
2907 	countLabels = 0;
2908 	if (classFileOffset + 2 >= bCodeStream.length) {
2909 		resizeByteArray();
2910 	}
2911 	position++;
2912 	bCodeStream[classFileOffset++] = OPC_invokespecial;
2913 	stackDepth -= 2;
2914 	writeUnsignedShort(constantPool.literalIndexForJavaLangNoClassDefFoundErrorStringConstructor());
2915 }
invokeObjectGetClass()2916 public void invokeObjectGetClass() {
2917 	// invokevirtual: java.lang.Object.getClass()Ljava.lang.Class;
2918 	if (DEBUG) System.out.println(position + "\t\tinvokevirtual: java.lang.Object.getClass()Ljava.lang.Class;"); //$NON-NLS-1$
2919 	countLabels = 0;
2920 	if (classFileOffset + 2 >= bCodeStream.length) {
2921 		resizeByteArray();
2922 	}
2923 	position++;
2924 	bCodeStream[classFileOffset++] = OPC_invokevirtual;
2925 	writeUnsignedShort(constantPool.literalIndexForJavaLangObjectGetClass());
2926 }
2927 
invokespecial(MethodBinding methodBinding)2928 final public void invokespecial(MethodBinding methodBinding) {
2929 	if (DEBUG) System.out.println(position + "\t\tinvokespecial:"+methodBinding); //$NON-NLS-1$
2930 	// initialized to 1 to take into account this  immediately
2931 	countLabels = 0;
2932 	int argCount = 1;
2933 	int id;
2934 	if (classFileOffset + 2 >= bCodeStream.length) {
2935 		resizeByteArray();
2936 	}
2937 	position++;
2938 	bCodeStream[classFileOffset++] = OPC_invokespecial;
2939 	writeUnsignedShort(constantPool.literalIndex(methodBinding));
2940 	if (methodBinding.isConstructor() && methodBinding.declaringClass.isNestedType()) {
2941 		// enclosing instances
2942 		TypeBinding[] syntheticArgumentTypes = methodBinding.declaringClass.syntheticEnclosingInstanceTypes();
2943 		if (syntheticArgumentTypes != null) {
2944 			for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) {
2945 				if (((id = syntheticArgumentTypes[i].id) == T_double) || (id == T_long)) {
2946 					argCount += 2;
2947 				} else {
2948 					argCount++;
2949 				}
2950 			}
2951 		}
2952 		// outer local variables
2953 		SyntheticArgumentBinding[] syntheticArguments = methodBinding.declaringClass.syntheticOuterLocalVariables();
2954 		if (syntheticArguments != null) {
2955 			for (int i = 0, max = syntheticArguments.length; i < max; i++) {
2956 				if (((id = syntheticArguments[i].type.id) == T_double) || (id == T_long)) {
2957 					argCount += 2;
2958 				} else {
2959 					argCount++;
2960 				}
2961 			}
2962 		}
2963 	}
2964 	for (int i = methodBinding.parameters.length - 1; i >= 0; i--)
2965 		if (((id = methodBinding.parameters[i].id) == T_double) || (id == T_long))
2966 			argCount += 2;
2967 		else
2968 			argCount++;
2969 	if (((id = methodBinding.returnType.id) == T_double) || (id == T_long))
2970 		stackDepth += (2 - argCount);
2971 	else
2972 		if (id == T_void)
2973 			stackDepth -= argCount;
2974 		else
2975 			stackDepth += (1 - argCount);
2976 	if (stackDepth > stackMax)
2977 		stackMax = stackDepth;
2978 }
invokestatic(MethodBinding methodBinding)2979 final public void invokestatic(MethodBinding methodBinding) {
2980 	if (DEBUG) System.out.println(position + "\t\tinvokestatic:"+methodBinding); //$NON-NLS-1$
2981 	// initialized to 0 to take into account that there is no this for
2982 	// a static method
2983 	countLabels = 0;
2984 	int argCount = 0;
2985 	int id;
2986 	if (classFileOffset + 2 >= bCodeStream.length) {
2987 		resizeByteArray();
2988 	}
2989 	position++;
2990 	bCodeStream[classFileOffset++] = OPC_invokestatic;
2991 	writeUnsignedShort(constantPool.literalIndex(methodBinding));
2992 	for (int i = methodBinding.parameters.length - 1; i >= 0; i--)
2993 		if (((id = methodBinding.parameters[i].id) == T_double) || (id == T_long))
2994 			argCount += 2;
2995 		else
2996 			argCount += 1;
2997 	if (((id = methodBinding.returnType.id) == T_double) || (id == T_long))
2998 		stackDepth += (2 - argCount);
2999 	else
3000 		if (id == T_void)
3001 			stackDepth -= argCount;
3002 		else
3003 			stackDepth += (1 - argCount);
3004 	if (stackDepth > stackMax)
3005 		stackMax = stackDepth;
3006 }
3007 /**
3008  * The equivalent code performs a string conversion of the TOS
3009  * @param typeID <CODE>int</CODE>
3010  */
invokeStringConcatenationAppendForType(int typeID)3011 public void invokeStringConcatenationAppendForType(int typeID) {
3012 	if (DEBUG) {
3013 		if (this.targetLevel >= JDK1_5) {
3014 			System.out.println(position + "\t\tinvokevirtual: java.lang.StringBuilder.append(...)"); //$NON-NLS-1$
3015 		} else {
3016 			System.out.println(position + "\t\tinvokevirtual: java.lang.StringBuffer.append(...)"); //$NON-NLS-1$
3017 		}
3018 	}
3019 	countLabels = 0;
3020 	int usedTypeID;
3021 	if (typeID == T_null) {
3022 		usedTypeID = T_String;
3023 	} else {
3024 		usedTypeID = typeID;
3025 	}
3026 	// invokevirtual
3027 	if (classFileOffset + 2 >= bCodeStream.length) {
3028 		resizeByteArray();
3029 	}
3030 	position++;
3031 	bCodeStream[classFileOffset++] = OPC_invokevirtual;
3032 	if (this.targetLevel >= JDK1_5) {
3033 		writeUnsignedShort(constantPool.literalIndexForJavaLangStringBuilderAppend(typeID));
3034 	} else {
3035 		writeUnsignedShort(constantPool.literalIndexForJavaLangStringBufferAppend(typeID));
3036 	}
3037 	if ((usedTypeID == T_long) || (usedTypeID == T_double)) {
3038 		stackDepth -= 2;
3039 	} else {
3040 		stackDepth--;
3041 	}
3042 }
3043 
invokeJavaLangAssertionErrorConstructor(int typeBindingID)3044 public void invokeJavaLangAssertionErrorConstructor(int typeBindingID) {
3045 	// invokespecial: java.lang.AssertionError.<init>(typeBindingID)V
3046 	if (DEBUG) System.out.println(position + "\t\tinvokespecial: java.lang.AssertionError.<init>(typeBindingID)V"); //$NON-NLS-1$
3047 	countLabels = 0;
3048 	if (classFileOffset + 2 >= bCodeStream.length) {
3049 		resizeByteArray();
3050 	}
3051 	position++;
3052 	bCodeStream[classFileOffset++] = OPC_invokespecial;
3053 	writeUnsignedShort(constantPool.literalIndexForJavaLangAssertionErrorConstructor(typeBindingID));
3054 	stackDepth -= 2;
3055 }
3056 
invokeJavaLangAssertionErrorDefaultConstructor()3057 public void invokeJavaLangAssertionErrorDefaultConstructor() {
3058 	// invokespecial: java.lang.AssertionError.<init>()V
3059 	if (DEBUG) System.out.println(position + "\t\tinvokespecial: java.lang.AssertionError.<init>()V"); //$NON-NLS-1$
3060 	countLabels = 0;
3061 	if (classFileOffset + 2 >= bCodeStream.length) {
3062 		resizeByteArray();
3063 	}
3064 	position++;
3065 	bCodeStream[classFileOffset++] = OPC_invokespecial;
3066 	writeUnsignedShort(constantPool.literalIndexForJavaLangAssertionErrorDefaultConstructor());
3067 	stackDepth --;
3068 }
invokeJavaUtilIteratorHasNext()3069 public void invokeJavaUtilIteratorHasNext() {
3070 	// invokeinterface java.util.Iterator.hasNext()Z
3071 	if (DEBUG) System.out.println(position + "\t\tinvokeinterface: java.util.Iterator.hasNext()Z"); //$NON-NLS-1$
3072 	countLabels = 0;
3073 	if (classFileOffset + 4 >= bCodeStream.length) {
3074 		resizeByteArray();
3075 	}
3076 	position += 3;
3077 	bCodeStream[classFileOffset++] = OPC_invokeinterface;
3078 	writeUnsignedShort(constantPool.literalIndexForJavaUtilIteratorHasNext());
3079 	bCodeStream[classFileOffset++] = 1;
3080 	// Generate a  0 into the byte array. Like the array is already fill with 0, we just need to increment
3081 	// the number of bytes.
3082 	bCodeStream[classFileOffset++] = 0;
3083 }
invokeJavaUtilIteratorNext()3084 public void invokeJavaUtilIteratorNext() {
3085 	// invokeinterface java.util.Iterator.next()java.lang.Object
3086 	if (DEBUG) System.out.println(position + "\t\tinvokeinterface: java.util.Iterator.next()java.lang.Object"); //$NON-NLS-1$
3087 	countLabels = 0;
3088 	if (classFileOffset + 4 >= bCodeStream.length) {
3089 		resizeByteArray();
3090 	}
3091 	position += 3;
3092 	bCodeStream[classFileOffset++] = OPC_invokeinterface;
3093 	writeUnsignedShort(constantPool.literalIndexForJavaUtilIteratorNext());
3094 	bCodeStream[classFileOffset++] = 1;
3095 	// Generate a  0 into the byte array. Like the array is already fill with 0, we just need to increment
3096 	// the number of bytes.
3097 	bCodeStream[classFileOffset++] = 0;
3098 }
invokeStringConcatenationDefaultConstructor()3099 public void invokeStringConcatenationDefaultConstructor() {
3100 	// invokespecial: java.lang.StringBuffer.<init>()V
3101 	if (DEBUG) {
3102 		if (this.targetLevel >= JDK1_5) {
3103 			System.out.println(position + "\t\tinvokespecial: java.lang.StringBuilder.<init>()V"); //$NON-NLS-1$
3104 		} else {
3105 			System.out.println(position + "\t\tinvokespecial: java.lang.StringBuffer.<init>()V"); //$NON-NLS-1$
3106 		}
3107 	}
3108 	countLabels = 0;
3109 	if (classFileOffset + 2 >= bCodeStream.length) {
3110 		resizeByteArray();
3111 	}
3112 	position++;
3113 	bCodeStream[classFileOffset++] = OPC_invokespecial;
3114 	if (this.targetLevel >= JDK1_5) {
3115 		writeUnsignedShort(constantPool.literalIndexForJavaLangStringBuilderDefaultConstructor());
3116 	} else {
3117 		writeUnsignedShort(constantPool.literalIndexForJavaLangStringBufferDefaultConstructor());
3118 	}
3119 	stackDepth--;
3120 }
invokeStringConcatenationStringConstructor()3121 public void invokeStringConcatenationStringConstructor() {
3122 	if (DEBUG) {
3123 		if (this.targetLevel >= JDK1_5) {
3124 			System.out.println(position + "\t\tjava.lang.StringBuilder.<init>(Ljava.lang.String;)V"); //$NON-NLS-1$
3125 		} else {
3126 			System.out.println(position + "\t\tjava.lang.StringBuffer.<init>(Ljava.lang.String;)V"); //$NON-NLS-1$
3127 		}
3128 	}
3129 	countLabels = 0;
3130 	if (classFileOffset + 2 >= bCodeStream.length) {
3131 		resizeByteArray();
3132 	}
3133 	position++;
3134 	bCodeStream[classFileOffset++] = OPC_invokespecial;
3135 	if (this.targetLevel >= JDK1_5) {
3136 		writeUnsignedShort(constantPool.literalIndexForJavaLangStringBuilderConstructor());
3137 	} else {
3138 		writeUnsignedShort(constantPool.literalIndexForJavaLangStringBufferConstructor());
3139 	}
3140 	stackDepth -= 2;
3141 }
3142 
invokeStringConcatenationToString()3143 public void invokeStringConcatenationToString() {
3144 	if (DEBUG) {
3145 		if (this.targetLevel >= JDK1_5) {
3146 			System.out.println(position + "\t\tinvokevirtual: StringBuilder.toString()Ljava.lang.String;"); //$NON-NLS-1$
3147 		} else {
3148 			System.out.println(position + "\t\tinvokevirtual: StringBuffer.toString()Ljava.lang.String;"); //$NON-NLS-1$
3149 		}
3150 	}
3151 	countLabels = 0;
3152 	if (classFileOffset + 2 >= bCodeStream.length) {
3153 		resizeByteArray();
3154 	}
3155 	position++;
3156 	bCodeStream[classFileOffset++] = OPC_invokevirtual;
3157 	if (this.targetLevel >= JDK1_5) {
3158 		writeUnsignedShort(constantPool.literalIndexForJavaLangStringBuilderToString());
3159 	} else {
3160 		writeUnsignedShort(constantPool.literalIndexForJavaLangStringBufferToString());
3161 	}
3162 }
invokeStringIntern()3163 public void invokeStringIntern() {
3164 	// invokevirtual: java.lang.String.intern()
3165 	if (DEBUG) System.out.println(position + "\t\tinvokevirtual: java.lang.String.intern()"); //$NON-NLS-1$
3166 	countLabels = 0;
3167 	if (classFileOffset + 2 >= bCodeStream.length) {
3168 		resizeByteArray();
3169 	}
3170 	position++;
3171 	bCodeStream[classFileOffset++] = OPC_invokevirtual;
3172 	writeUnsignedShort(constantPool.literalIndexForJavaLangStringIntern());
3173 }
invokeStringValueOf(int typeID)3174 public void invokeStringValueOf(int typeID) {
3175 	// invokestatic: java.lang.String.valueOf(argumentType)
3176 	if (DEBUG) System.out.println(position + "\t\tinvokestatic: java.lang.String.valueOf(...)"); //$NON-NLS-1$
3177 	countLabels = 0;
3178 	if (classFileOffset + 2 >= bCodeStream.length) {
3179 		resizeByteArray();
3180 	}
3181 	position++;
3182 	bCodeStream[classFileOffset++] = OPC_invokestatic;
3183 	writeUnsignedShort(constantPool.literalIndexForJavaLangStringValueOf(typeID));
3184 }
invokeThrowableGetMessage()3185 public void invokeThrowableGetMessage() {
3186 	// invokevirtual: java.lang.Throwable.getMessage()Ljava.lang.String;
3187 	if (DEBUG) System.out.println(position + "\t\tinvokevirtual: java.lang.Throwable.getMessage()Ljava.lang.String;"); //$NON-NLS-1$
3188 	countLabels = 0;
3189 	if (classFileOffset + 2 >= bCodeStream.length) {
3190 		resizeByteArray();
3191 	}
3192 	position++;
3193 	bCodeStream[classFileOffset++] = OPC_invokevirtual;
3194 	writeUnsignedShort(constantPool.literalIndexForJavaLangThrowableGetMessage());
3195 }
invokevirtual(MethodBinding methodBinding)3196 final public void invokevirtual(MethodBinding methodBinding) {
3197 	if (DEBUG) System.out.println(position + "\t\tinvokevirtual:"+methodBinding); //$NON-NLS-1$
3198 	// initialized to 1 to take into account this  immediately
3199 	countLabels = 0;
3200 	int argCount = 1;
3201 	int id;
3202 	if (classFileOffset + 2 >= bCodeStream.length) {
3203 		resizeByteArray();
3204 	}
3205 	position++;
3206 	bCodeStream[classFileOffset++] = OPC_invokevirtual;
3207 	writeUnsignedShort(constantPool.literalIndex(methodBinding));
3208 	for (int i = methodBinding.parameters.length - 1; i >= 0; i--)
3209 		if (((id = methodBinding.parameters[i].id) == T_double) || (id == T_long))
3210 			argCount += 2;
3211 		else
3212 			argCount++;
3213 	if (((id = methodBinding.returnType.id) == T_double) || (id == T_long))
3214 		stackDepth += (2 - argCount);
3215 	else
3216 		if (id == T_void)
3217 			stackDepth -= argCount;
3218 		else
3219 			stackDepth += (1 - argCount);
3220 	if (stackDepth > stackMax)
3221 		stackMax = stackDepth;
3222 }
ior()3223 final public void ior() {
3224 	if (DEBUG) System.out.println(position + "\t\tior"); //$NON-NLS-1$
3225 	countLabels = 0;
3226 	stackDepth--;
3227 	if (classFileOffset >= bCodeStream.length) {
3228 		resizeByteArray();
3229 	}
3230 	position++;
3231 	bCodeStream[classFileOffset++] = OPC_ior;
3232 }
irem()3233 final public void irem() {
3234 	if (DEBUG) System.out.println(position + "\t\tirem"); //$NON-NLS-1$
3235 	countLabels = 0;
3236 	stackDepth--;
3237 	if (classFileOffset >= bCodeStream.length) {
3238 		resizeByteArray();
3239 	}
3240 	position++;
3241 	bCodeStream[classFileOffset++] = OPC_irem;
3242 }
ireturn()3243 final public void ireturn() {
3244 	if (DEBUG) System.out.println(position + "\t\tireturn"); //$NON-NLS-1$
3245 	countLabels = 0;
3246 	stackDepth--;
3247 	// the stackDepth should be equal to 0
3248 	if (classFileOffset >= bCodeStream.length) {
3249 		resizeByteArray();
3250 	}
3251 	position++;
3252 	bCodeStream[classFileOffset++] = OPC_ireturn;
3253 }
isDefinitelyAssigned(Scope scope, int initStateIndex, LocalVariableBinding local)3254 public boolean isDefinitelyAssigned(Scope scope, int initStateIndex, LocalVariableBinding local) {
3255 	// Dependant of UnconditionalFlowInfo.isDefinitelyAssigned(..)
3256 	if (initStateIndex == -1)
3257 		return false;
3258 	if (local.isArgument) {
3259 		return true;
3260 	}
3261 	int localPosition = local.id + maxFieldCount;
3262 	MethodScope methodScope = scope.methodScope();
3263 	// id is zero-based
3264 	if (localPosition < UnconditionalFlowInfo.BitCacheSize) {
3265 		return (methodScope.definiteInits[initStateIndex] & (1L << localPosition)) != 0; // use bits
3266 	}
3267 	// use extra vector
3268 	long[] extraInits = methodScope.extraDefiniteInits[initStateIndex];
3269 	if (extraInits == null)
3270 		return false; // if vector not yet allocated, then not initialized
3271 	int vectorIndex;
3272 	if ((vectorIndex = (localPosition / UnconditionalFlowInfo.BitCacheSize) - 1) >= extraInits.length)
3273 		return false; // if not enough room in vector, then not initialized
3274 	return ((extraInits[vectorIndex]) & (1L << (localPosition % UnconditionalFlowInfo.BitCacheSize))) != 0;
3275 }
ishl()3276 final public void ishl() {
3277 	if (DEBUG) System.out.println(position + "\t\tishl"); //$NON-NLS-1$
3278 	countLabels = 0;
3279 	stackDepth--;
3280 	if (classFileOffset >= bCodeStream.length) {
3281 		resizeByteArray();
3282 	}
3283 	position++;
3284 	bCodeStream[classFileOffset++] = OPC_ishl;
3285 }
ishr()3286 final public void ishr() {
3287 	if (DEBUG) System.out.println(position + "\t\tishr"); //$NON-NLS-1$
3288 	countLabels = 0;
3289 	stackDepth--;
3290 	if (classFileOffset >= bCodeStream.length) {
3291 		resizeByteArray();
3292 	}
3293 	position++;
3294 	bCodeStream[classFileOffset++] = OPC_ishr;
3295 }
istore(int iArg)3296 final public void istore(int iArg) {
3297 	if (DEBUG) System.out.println(position + "\t\tistore:"+iArg); //$NON-NLS-1$
3298 	countLabels = 0;
3299 	stackDepth--;
3300 	if (maxLocals <= iArg) {
3301 		maxLocals = iArg + 1;
3302 	}
3303 	if (iArg > 255) { // Widen
3304 		if (classFileOffset + 3 >= bCodeStream.length) {
3305 			resizeByteArray();
3306 		}
3307 		position += 2;
3308 		bCodeStream[classFileOffset++] = OPC_wide;
3309 		bCodeStream[classFileOffset++] = OPC_istore;
3310 		writeUnsignedShort(iArg);
3311 	} else {
3312 		if (classFileOffset + 1 >= bCodeStream.length) {
3313 			resizeByteArray();
3314 		}
3315 		position += 2;
3316 		bCodeStream[classFileOffset++] = OPC_istore;
3317 		bCodeStream[classFileOffset++] = (byte) iArg;
3318 	}
3319 }
istore_0()3320 final public void istore_0() {
3321 	if (DEBUG) System.out.println(position + "\t\tistore_0"); //$NON-NLS-1$
3322 	countLabels = 0;
3323 	stackDepth--;
3324 	if (maxLocals == 0) {
3325 		maxLocals = 1;
3326 	}
3327 	if (classFileOffset >= bCodeStream.length) {
3328 		resizeByteArray();
3329 	}
3330 	position++;
3331 	bCodeStream[classFileOffset++] = OPC_istore_0;
3332 }
istore_1()3333 final public void istore_1() {
3334 	if (DEBUG) System.out.println(position + "\t\tistore_1"); //$NON-NLS-1$
3335 	countLabels = 0;
3336 	stackDepth--;
3337 	if (maxLocals <= 1) {
3338 		maxLocals = 2;
3339 	}
3340 	if (classFileOffset >= bCodeStream.length) {
3341 		resizeByteArray();
3342 	}
3343 	position++;
3344 	bCodeStream[classFileOffset++] = OPC_istore_1;
3345 }
istore_2()3346 final public void istore_2() {
3347 	if (DEBUG) System.out.println(position + "\t\tistore_2"); //$NON-NLS-1$
3348 	countLabels = 0;
3349 	stackDepth--;
3350 	if (maxLocals <= 2) {
3351 		maxLocals = 3;
3352 	}
3353 	if (classFileOffset >= bCodeStream.length) {
3354 		resizeByteArray();
3355 	}
3356 	position++;
3357 	bCodeStream[classFileOffset++] = OPC_istore_2;
3358 }
istore_3()3359 final public void istore_3() {
3360 	if (DEBUG) System.out.println(position + "\t\tistore_3"); //$NON-NLS-1$
3361 	countLabels = 0;
3362 	stackDepth--;
3363 	if (maxLocals <= 3) {
3364 		maxLocals = 4;
3365 	}
3366 	if (classFileOffset >= bCodeStream.length) {
3367 		resizeByteArray();
3368 	}
3369 	position++;
3370 	bCodeStream[classFileOffset++] = OPC_istore_3;
3371 }
isub()3372 final public void isub() {
3373 	if (DEBUG) System.out.println(position + "\t\tisub"); //$NON-NLS-1$
3374 	countLabels = 0;
3375 	stackDepth--;
3376 	if (classFileOffset >= bCodeStream.length) {
3377 		resizeByteArray();
3378 	}
3379 	position++;
3380 	bCodeStream[classFileOffset++] = OPC_isub;
3381 }
iushr()3382 final public void iushr() {
3383 	if (DEBUG) System.out.println(position + "\t\tiushr"); //$NON-NLS-1$
3384 	countLabels = 0;
3385 	stackDepth--;
3386 	if (classFileOffset >= bCodeStream.length) {
3387 		resizeByteArray();
3388 	}
3389 	position++;
3390 	bCodeStream[classFileOffset++] = OPC_iushr;
3391 }
ixor()3392 final public void ixor() {
3393 	if (DEBUG) System.out.println(position + "\t\tixor"); //$NON-NLS-1$
3394 	countLabels = 0;
3395 	stackDepth--;
3396 	if (classFileOffset >= bCodeStream.length) {
3397 		resizeByteArray();
3398 	}
3399 	position++;
3400 	bCodeStream[classFileOffset++] = OPC_ixor;
3401 }
jsr(Label lbl)3402 final public void jsr(Label lbl) {
3403 	if (this.wideMode) {
3404 		this.jsr_w(lbl);
3405 		return;
3406 	}
3407 	if (DEBUG) System.out.println(position + "\t\tjsr"+lbl); //$NON-NLS-1$
3408 	countLabels = 0;
3409 	if (classFileOffset >= bCodeStream.length) {
3410 		resizeByteArray();
3411 	}
3412 	position++;
3413 	bCodeStream[classFileOffset++] = OPC_jsr;
3414 	lbl.branch();
3415 }
jsr_w(Label lbl)3416 final public void jsr_w(Label lbl) {
3417 	if (DEBUG) System.out.println(position + "\t\tjsr_w"+lbl); //$NON-NLS-1$
3418 	countLabels = 0;
3419 	if (classFileOffset >= bCodeStream.length) {
3420 		resizeByteArray();
3421 	}
3422 	position++;
3423 	bCodeStream[classFileOffset++] = OPC_jsr_w;
3424 	lbl.branchWide();
3425 }
l2d()3426 final public void l2d() {
3427 	if (DEBUG) System.out.println(position + "\t\tl2d"); //$NON-NLS-1$
3428 	countLabels = 0;
3429 	if (classFileOffset >= bCodeStream.length) {
3430 		resizeByteArray();
3431 	}
3432 	position++;
3433 	bCodeStream[classFileOffset++] = OPC_l2d;
3434 }
l2f()3435 final public void l2f() {
3436 	if (DEBUG) System.out.println(position + "\t\tl2f"); //$NON-NLS-1$
3437 	countLabels = 0;
3438 	stackDepth--;
3439 	if (classFileOffset >= bCodeStream.length) {
3440 		resizeByteArray();
3441 	}
3442 	position++;
3443 	bCodeStream[classFileOffset++] = OPC_l2f;
3444 }
l2i()3445 final public void l2i() {
3446 	if (DEBUG) System.out.println(position + "\t\tl2i"); //$NON-NLS-1$
3447 	countLabels = 0;
3448 	stackDepth--;
3449 	if (classFileOffset >= bCodeStream.length) {
3450 		resizeByteArray();
3451 	}
3452 	position++;
3453 	bCodeStream[classFileOffset++] = OPC_l2i;
3454 }
ladd()3455 final public void ladd() {
3456 	if (DEBUG) System.out.println(position + "\t\tladd"); //$NON-NLS-1$
3457 	countLabels = 0;
3458 	stackDepth -= 2;
3459 	if (classFileOffset >= bCodeStream.length) {
3460 		resizeByteArray();
3461 	}
3462 	position++;
3463 	bCodeStream[classFileOffset++] = OPC_ladd;
3464 }
laload()3465 final public void laload() {
3466 	if (DEBUG) System.out.println(position + "\t\tlaload"); //$NON-NLS-1$
3467 	countLabels = 0;
3468 	if (classFileOffset >= bCodeStream.length) {
3469 		resizeByteArray();
3470 	}
3471 	position++;
3472 	bCodeStream[classFileOffset++] = OPC_laload;
3473 }
land()3474 final public void land() {
3475 	if (DEBUG) System.out.println(position + "\t\tland"); //$NON-NLS-1$
3476 	countLabels = 0;
3477 	stackDepth -= 2;
3478 	if (classFileOffset >= bCodeStream.length) {
3479 		resizeByteArray();
3480 	}
3481 	position++;
3482 	bCodeStream[classFileOffset++] = OPC_land;
3483 }
lastore()3484 final public void lastore() {
3485 	if (DEBUG) System.out.println(position + "\t\tlastore"); //$NON-NLS-1$
3486 	countLabels = 0;
3487 	stackDepth -= 4;
3488 	if (classFileOffset >= bCodeStream.length) {
3489 		resizeByteArray();
3490 	}
3491 	position++;
3492 	bCodeStream[classFileOffset++] = OPC_lastore;
3493 }
lcmp()3494 final public void lcmp() {
3495 	if (DEBUG) System.out.println(position + "\t\tlcmp"); //$NON-NLS-1$
3496 	countLabels = 0;
3497 	stackDepth -= 3;
3498 	if (classFileOffset >= bCodeStream.length) {
3499 		resizeByteArray();
3500 	}
3501 	position++;
3502 	bCodeStream[classFileOffset++] = OPC_lcmp;
3503 }
lconst_0()3504 final public void lconst_0() {
3505 	if (DEBUG) System.out.println(position + "\t\tlconst_0"); //$NON-NLS-1$
3506 	countLabels = 0;
3507 	stackDepth += 2;
3508 	if (stackDepth > stackMax)
3509 		stackMax = stackDepth;
3510 	if (classFileOffset >= bCodeStream.length) {
3511 		resizeByteArray();
3512 	}
3513 	position++;
3514 	bCodeStream[classFileOffset++] = OPC_lconst_0;
3515 }
lconst_1()3516 final public void lconst_1() {
3517 	if (DEBUG) System.out.println(position + "\t\tlconst_1"); //$NON-NLS-1$
3518 	countLabels = 0;
3519 	stackDepth += 2;
3520 	if (stackDepth > stackMax)
3521 		stackMax = stackDepth;
3522 	if (classFileOffset >= bCodeStream.length) {
3523 		resizeByteArray();
3524 	}
3525 	position++;
3526 	bCodeStream[classFileOffset++] = OPC_lconst_1;
3527 }
ldc(float constant)3528 final public void ldc(float constant) {
3529 	countLabels = 0;
3530 	int index = constantPool.literalIndex(constant);
3531 	stackDepth++;
3532 	if (stackDepth > stackMax)
3533 		stackMax = stackDepth;
3534 	if (index > 255) {
3535 		if (DEBUG) System.out.println(position + "\t\tldc_w:"+constant); //$NON-NLS-1$
3536 		// Generate a ldc_w
3537 		if (classFileOffset + 2 >= bCodeStream.length) {
3538 			resizeByteArray();
3539 		}
3540 		position++;
3541 		bCodeStream[classFileOffset++] = OPC_ldc_w;
3542 		writeUnsignedShort(index);
3543 	} else {
3544 		if (DEBUG) System.out.println(position + "\t\tldc:"+constant); //$NON-NLS-1$
3545 		// Generate a ldc
3546 		if (classFileOffset + 1 >= bCodeStream.length) {
3547 			resizeByteArray();
3548 		}
3549 		position += 2;
3550 		bCodeStream[classFileOffset++] = OPC_ldc;
3551 		bCodeStream[classFileOffset++] = (byte) index;
3552 	}
3553 }
ldc(int constant)3554 final public void ldc(int constant) {
3555 	countLabels = 0;
3556 	int index = constantPool.literalIndex(constant);
3557 	stackDepth++;
3558 	if (stackDepth > stackMax)
3559 		stackMax = stackDepth;
3560 	if (index > 255) {
3561 		if (DEBUG) System.out.println(position + "\t\tldc_w:"+constant); //$NON-NLS-1$
3562 		// Generate a ldc_w
3563 		if (classFileOffset + 2 >= bCodeStream.length) {
3564 			resizeByteArray();
3565 		}
3566 		position++;
3567 		bCodeStream[classFileOffset++] = OPC_ldc_w;
3568 		writeUnsignedShort(index);
3569 	} else {
3570 		if (DEBUG) System.out.println(position + "\t\tldc:"+constant); //$NON-NLS-1$
3571 		// Generate a ldc
3572 		if (classFileOffset + 1 >= bCodeStream.length) {
3573 			resizeByteArray();
3574 		}
3575 		position += 2;
3576 		bCodeStream[classFileOffset++] = OPC_ldc;
3577 		bCodeStream[classFileOffset++] = (byte) index;
3578 	}
3579 }
ldc(String constant)3580 final public void ldc(String constant) {
3581 	countLabels = 0;
3582 	int currentConstantPoolIndex = constantPool.currentIndex;
3583 	int currentConstantPoolOffset = constantPool.currentOffset;
3584 	int currentCodeStreamPosition = position;
3585 	int index = constantPool.literalIndexForLdc(constant.toCharArray());
3586 	if (index > 0) {
3587 		// the string already exists inside the constant pool
3588 		// we reuse the same index
3589 		stackDepth++;
3590 		if (stackDepth > stackMax)
3591 			stackMax = stackDepth;
3592 		if (index > 255) {
3593 			if (DEBUG) System.out.println(position + "\t\tldc_w:"+constant); //$NON-NLS-1$
3594 			// Generate a ldc_w
3595 			if (classFileOffset + 2 >= bCodeStream.length) {
3596 				resizeByteArray();
3597 			}
3598 			position++;
3599 			bCodeStream[classFileOffset++] = OPC_ldc_w;
3600 			writeUnsignedShort(index);
3601 		} else {
3602 			if (DEBUG) System.out.println(position + "\t\tldc:"+constant); //$NON-NLS-1$
3603 			// Generate a ldc
3604 			if (classFileOffset + 1 >= bCodeStream.length) {
3605 				resizeByteArray();
3606 			}
3607 			position += 2;
3608 			bCodeStream[classFileOffset++] = OPC_ldc;
3609 			bCodeStream[classFileOffset++] = (byte) index;
3610 		}
3611 	} else {
3612 		// the string is too big to be utf8-encoded in one pass.
3613 		// we have to split it into different pieces.
3614 		// first we clean all side-effects due to the code above
3615 		// this case is very rare, so we can afford to lose time to handle it
3616 		char[] constantChars = constant.toCharArray();
3617 		position = currentCodeStreamPosition;
3618 		constantPool.currentIndex = currentConstantPoolIndex;
3619 		constantPool.currentOffset = currentConstantPoolOffset;
3620 		constantPool.stringCache.remove(constantChars);
3621 		constantPool.UTF8Cache.remove(constantChars);
3622 		int i = 0;
3623 		int length = 0;
3624 		int constantLength = constant.length();
3625 		byte[] utf8encoding = new byte[Math.min(constantLength + 100, 65535)];
3626 		int utf8encodingLength = 0;
3627 		while ((length < 65532) && (i < constantLength)) {
3628 			char current = constantChars[i];
3629 			// we resize the byte array immediately if necessary
3630 			if (length + 3 > (utf8encodingLength = utf8encoding.length)) {
3631 				System.arraycopy(utf8encoding, 0, utf8encoding = new byte[Math.min(utf8encodingLength + 100, 65535)], 0, length);
3632 			}
3633 			if ((current >= 0x0001) && (current <= 0x007F)) {
3634 				// we only need one byte: ASCII table
3635 				utf8encoding[length++] = (byte) current;
3636 			} else {
3637 				if (current > 0x07FF) {
3638 					// we need 3 bytes
3639 					utf8encoding[length++] = (byte) (0xE0 | ((current >> 12) & 0x0F)); // 0xE0 = 1110 0000
3640 					utf8encoding[length++] = (byte) (0x80 | ((current >> 6) & 0x3F)); // 0x80 = 1000 0000
3641 					utf8encoding[length++] = (byte) (0x80 | (current & 0x3F)); // 0x80 = 1000 0000
3642 				} else {
3643 					// we can be 0 or between 0x0080 and 0x07FF
3644 					// In that case we only need 2 bytes
3645 					utf8encoding[length++] = (byte) (0xC0 | ((current >> 6) & 0x1F)); // 0xC0 = 1100 0000
3646 					utf8encoding[length++] = (byte) (0x80 | (current & 0x3F)); // 0x80 = 1000 0000
3647 				}
3648 			}
3649 			i++;
3650 		}
3651 		// check if all the string is encoded (PR 1PR2DWJ)
3652 		// the string is too big to be encoded in one pass
3653 		newStringContatenation();
3654 		dup();
3655 		// write the first part
3656 		char[] subChars = new char[i];
3657 		System.arraycopy(constantChars, 0, subChars, 0, i);
3658 		System.arraycopy(utf8encoding, 0, utf8encoding = new byte[length], 0, length);
3659 		index = constantPool.literalIndex(subChars, utf8encoding);
3660 		stackDepth++;
3661 		if (stackDepth > stackMax)
3662 			stackMax = stackDepth;
3663 		if (index > 255) {
3664 			// Generate a ldc_w
3665 			if (classFileOffset + 2 >= bCodeStream.length) {
3666 				resizeByteArray();
3667 			}
3668 			position++;
3669 			bCodeStream[classFileOffset++] = OPC_ldc_w;
3670 			writeUnsignedShort(index);
3671 		} else {
3672 			// Generate a ldc
3673 			if (classFileOffset + 1 >= bCodeStream.length) {
3674 				resizeByteArray();
3675 			}
3676 			position += 2;
3677 			bCodeStream[classFileOffset++] = OPC_ldc;
3678 			bCodeStream[classFileOffset++] = (byte) index;
3679 		}
3680 		// write the remaining part
3681 		invokeStringConcatenationStringConstructor();
3682 		while (i < constantLength) {
3683 			length = 0;
3684 			utf8encoding = new byte[Math.min(constantLength - i + 100, 65535)];
3685 			int startIndex = i;
3686 			while ((length < 65532) && (i < constantLength)) {
3687 				char current = constantChars[i];
3688 				// we resize the byte array immediately if necessary
3689 				if (constantLength + 2 > (utf8encodingLength = utf8encoding.length)) {
3690 					System.arraycopy(utf8encoding, 0, utf8encoding = new byte[Math.min(utf8encodingLength + 100, 65535)], 0, length);
3691 				}
3692 				if ((current >= 0x0001) && (current <= 0x007F)) {
3693 					// we only need one byte: ASCII table
3694 					utf8encoding[length++] = (byte) current;
3695 				} else {
3696 					if (current > 0x07FF) {
3697 						// we need 3 bytes
3698 						utf8encoding[length++] = (byte) (0xE0 | ((current >> 12) & 0x0F)); // 0xE0 = 1110 0000
3699 						utf8encoding[length++] = (byte) (0x80 | ((current >> 6) & 0x3F)); // 0x80 = 1000 0000
3700 						utf8encoding[length++] = (byte) (0x80 | (current & 0x3F)); // 0x80 = 1000 0000
3701 					} else {
3702 						// we can be 0 or between 0x0080 and 0x07FF
3703 						// In that case we only need 2 bytes
3704 						utf8encoding[length++] = (byte) (0xC0 | ((current >> 6) & 0x1F)); // 0xC0 = 1100 0000
3705 						utf8encoding[length++] = (byte) (0x80 | (current & 0x3F)); // 0x80 = 1000 0000
3706 					}
3707 				}
3708 				i++;
3709 			}
3710 			// the next part is done
3711 			subChars = new char[i - startIndex];
3712 			System.arraycopy(constantChars, startIndex, subChars, 0, i - startIndex);
3713 			System.arraycopy(utf8encoding, 0, utf8encoding = new byte[length], 0, length);
3714 			index = constantPool.literalIndex(subChars, utf8encoding);
3715 			stackDepth++;
3716 			if (stackDepth > stackMax)
3717 				stackMax = stackDepth;
3718 			if (index > 255) {
3719 				// Generate a ldc_w
3720 				if (classFileOffset + 2 >= bCodeStream.length) {
3721 					resizeByteArray();
3722 				}
3723 				position++;
3724 				bCodeStream[classFileOffset++] = OPC_ldc_w;
3725 				writeUnsignedShort(index);
3726 			} else {
3727 				// Generate a ldc
3728 				if (classFileOffset + 1 >= bCodeStream.length) {
3729 					resizeByteArray();
3730 				}
3731 				position += 2;
3732 				bCodeStream[classFileOffset++] = OPC_ldc;
3733 				bCodeStream[classFileOffset++] = (byte) index;
3734 			}
3735 			// now on the stack it should be a StringBuffer and a string.
3736 			invokeStringConcatenationAppendForType(T_String);
3737 		}
3738 		invokeStringConcatenationToString();
3739 		invokeStringIntern();
3740 	}
3741 }
ldc(TypeBinding typeBinding)3742 final public void ldc(TypeBinding typeBinding) {
3743 	countLabels = 0;
3744 	int index = constantPool.literalIndex(typeBinding);
3745 	stackDepth++;
3746 	if (stackDepth > stackMax)
3747 		stackMax = stackDepth;
3748 	if (index > 255) {
3749 		if (DEBUG) System.out.println(position + "\t\tldc_w:"+ typeBinding); //$NON-NLS-1$
3750 		// Generate a ldc_w
3751 		if (classFileOffset + 2 >= bCodeStream.length) {
3752 			resizeByteArray();
3753 		}
3754 		position++;
3755 		bCodeStream[classFileOffset++] = OPC_ldc_w;
3756 		writeUnsignedShort(index);
3757 	} else {
3758 		if (DEBUG) System.out.println(position + "\t\tldw:"+ typeBinding); //$NON-NLS-1$
3759 		// Generate a ldc
3760 		if (classFileOffset + 1 >= bCodeStream.length) {
3761 			resizeByteArray();
3762 		}
3763 		position += 2;
3764 		bCodeStream[classFileOffset++] = OPC_ldc;
3765 		bCodeStream[classFileOffset++] = (byte) index;
3766 	}
3767 }
ldc2_w(double constant)3768 final public void ldc2_w(double constant) {
3769 	if (DEBUG) System.out.println(position + "\t\tldc2_w:"+constant); //$NON-NLS-1$
3770 	countLabels = 0;
3771 	int index = constantPool.literalIndex(constant);
3772 	stackDepth += 2;
3773 	if (stackDepth > stackMax)
3774 		stackMax = stackDepth;
3775 	// Generate a ldc2_w
3776 	if (classFileOffset + 2 >= bCodeStream.length) {
3777 		resizeByteArray();
3778 	}
3779 	position++;
3780 	bCodeStream[classFileOffset++] = OPC_ldc2_w;
3781 	writeUnsignedShort(index);
3782 }
ldc2_w(long constant)3783 final public void ldc2_w(long constant) {
3784 	if (DEBUG) System.out.println(position + "\t\tldc2_w:"+constant); //$NON-NLS-1$
3785 	countLabels = 0;
3786 	int index = constantPool.literalIndex(constant);
3787 	stackDepth += 2;
3788 	if (stackDepth > stackMax)
3789 		stackMax = stackDepth;
3790 	// Generate a ldc2_w
3791 	if (classFileOffset + 2 >= bCodeStream.length) {
3792 		resizeByteArray();
3793 	}
3794 	position++;
3795 	bCodeStream[classFileOffset++] = OPC_ldc2_w;
3796 	writeUnsignedShort(index);
3797 }
ldiv()3798 final public void ldiv() {
3799 	if (DEBUG) System.out.println(position + "\t\tldiv"); //$NON-NLS-1$
3800 	countLabels = 0;
3801 	stackDepth -= 2;
3802 	if (classFileOffset >= bCodeStream.length) {
3803 		resizeByteArray();
3804 	}
3805 	position++;
3806 	bCodeStream[classFileOffset++] = OPC_ldiv;
3807 }
lload(int iArg)3808 final public void lload(int iArg) {
3809 	if (DEBUG) System.out.println(position + "\t\tlload:"+iArg); //$NON-NLS-1$
3810 	countLabels = 0;
3811 	stackDepth += 2;
3812 	if (maxLocals <= iArg + 1) {
3813 		maxLocals = iArg + 2;
3814 	}
3815 	if (stackDepth > stackMax)
3816 		stackMax = stackDepth;
3817 	if (iArg > 255) { // Widen
3818 		if (classFileOffset + 3 >= bCodeStream.length) {
3819 			resizeByteArray();
3820 		}
3821 		position += 2;
3822 		bCodeStream[classFileOffset++] = OPC_wide;
3823 		bCodeStream[classFileOffset++] = OPC_lload;
3824 		writeUnsignedShort(iArg);
3825 	} else {
3826 		if (classFileOffset + 1 >= bCodeStream.length) {
3827 			resizeByteArray();
3828 		}
3829 		position += 2;
3830 		bCodeStream[classFileOffset++] = OPC_lload;
3831 		bCodeStream[classFileOffset++] = (byte) iArg;
3832 	}
3833 }
lload_0()3834 final public void lload_0() {
3835 	if (DEBUG) System.out.println(position + "\t\tlload_0"); //$NON-NLS-1$
3836 	countLabels = 0;
3837 	stackDepth += 2;
3838 	if (maxLocals < 2) {
3839 		maxLocals = 2;
3840 	}
3841 	if (stackDepth > stackMax)
3842 		stackMax = stackDepth;
3843 	if (classFileOffset >= bCodeStream.length) {
3844 		resizeByteArray();
3845 	}
3846 	position++;
3847 	bCodeStream[classFileOffset++] = OPC_lload_0;
3848 }
lload_1()3849 final public void lload_1() {
3850 	if (DEBUG) System.out.println(position + "\t\tlload_1"); //$NON-NLS-1$
3851 	countLabels = 0;
3852 	stackDepth += 2;
3853 	if (maxLocals < 3) {
3854 		maxLocals = 3;
3855 	}
3856 	if (stackDepth > stackMax)
3857 		stackMax = stackDepth;
3858 	if (classFileOffset >= bCodeStream.length) {
3859 		resizeByteArray();
3860 	}
3861 	position++;
3862 	bCodeStream[classFileOffset++] = OPC_lload_1;
3863 }
lload_2()3864 final public void lload_2() {
3865 	if (DEBUG) System.out.println(position + "\t\tlload_2"); //$NON-NLS-1$
3866 	countLabels = 0;
3867 	stackDepth += 2;
3868 	if (maxLocals < 4) {
3869 		maxLocals = 4;
3870 	}
3871 	if (stackDepth > stackMax)
3872 		stackMax = stackDepth;
3873 	if (classFileOffset >= bCodeStream.length) {
3874 		resizeByteArray();
3875 	}
3876 	position++;
3877 	bCodeStream[classFileOffset++] = OPC_lload_2;
3878 }
lload_3()3879 final public void lload_3() {
3880 	if (DEBUG) System.out.println(position + "\t\tlload_3"); //$NON-NLS-1$
3881 	countLabels = 0;
3882 	stackDepth += 2;
3883 	if (maxLocals < 5) {
3884 		maxLocals = 5;
3885 	}
3886 	if (stackDepth > stackMax)
3887 		stackMax = stackDepth;
3888 	if (classFileOffset >= bCodeStream.length) {
3889 		resizeByteArray();
3890 	}
3891 	position++;
3892 	bCodeStream[classFileOffset++] = OPC_lload_3;
3893 }
lmul()3894 final public void lmul() {
3895 	if (DEBUG) System.out.println(position + "\t\tlmul"); //$NON-NLS-1$
3896 	countLabels = 0;
3897 	stackDepth -= 2;
3898 	if (classFileOffset >= bCodeStream.length) {
3899 		resizeByteArray();
3900 	}
3901 	position++;
3902 	bCodeStream[classFileOffset++] = OPC_lmul;
3903 }
lneg()3904 final public void lneg() {
3905 	if (DEBUG) System.out.println(position + "\t\tlneg"); //$NON-NLS-1$
3906 	countLabels = 0;
3907 	if (classFileOffset >= bCodeStream.length) {
3908 		resizeByteArray();
3909 	}
3910 	position++;
3911 	bCodeStream[classFileOffset++] = OPC_lneg;
3912 }
load(LocalVariableBinding localBinding)3913 public final void load(LocalVariableBinding localBinding) {
3914 	countLabels = 0;
3915 	TypeBinding typeBinding = localBinding.type;
3916 	int resolvedPosition = localBinding.resolvedPosition;
3917 	// Using dedicated int bytecode
3918 	if (typeBinding == IntBinding) {
3919 		switch (resolvedPosition) {
3920 			case 0 :
3921 				this.iload_0();
3922 				break;
3923 			case 1 :
3924 				this.iload_1();
3925 				break;
3926 			case 2 :
3927 				this.iload_2();
3928 				break;
3929 			case 3 :
3930 				this.iload_3();
3931 				break;
3932 			//case -1 :
3933 			// internal failure: trying to load variable not supposed to be generated
3934 			//	break;
3935 			default :
3936 				this.iload(resolvedPosition);
3937 		}
3938 		return;
3939 	}
3940 	// Using dedicated float bytecode
3941 	if (typeBinding == FloatBinding) {
3942 		switch (resolvedPosition) {
3943 			case 0 :
3944 				this.fload_0();
3945 				break;
3946 			case 1 :
3947 				this.fload_1();
3948 				break;
3949 			case 2 :
3950 				this.fload_2();
3951 				break;
3952 			case 3 :
3953 				this.fload_3();
3954 				break;
3955 			default :
3956 				this.fload(resolvedPosition);
3957 		}
3958 		return;
3959 	}
3960 	// Using dedicated long bytecode
3961 	if (typeBinding == LongBinding) {
3962 		switch (resolvedPosition) {
3963 			case 0 :
3964 				this.lload_0();
3965 				break;
3966 			case 1 :
3967 				this.lload_1();
3968 				break;
3969 			case 2 :
3970 				this.lload_2();
3971 				break;
3972 			case 3 :
3973 				this.lload_3();
3974 				break;
3975 			default :
3976 				this.lload(resolvedPosition);
3977 		}
3978 		return;
3979 	}
3980 	// Using dedicated double bytecode
3981 	if (typeBinding == DoubleBinding) {
3982 		switch (resolvedPosition) {
3983 			case 0 :
3984 				this.dload_0();
3985 				break;
3986 			case 1 :
3987 				this.dload_1();
3988 				break;
3989 			case 2 :
3990 				this.dload_2();
3991 				break;
3992 			case 3 :
3993 				this.dload_3();
3994 				break;
3995 			default :
3996 				this.dload(resolvedPosition);
3997 		}
3998 		return;
3999 	}
4000 	// boolean, byte, char and short are handled as int
4001 	if ((typeBinding == ByteBinding) || (typeBinding == CharBinding) || (typeBinding == BooleanBinding) || (typeBinding == ShortBinding)) {
4002 		switch (resolvedPosition) {
4003 			case 0 :
4004 				this.iload_0();
4005 				break;
4006 			case 1 :
4007 				this.iload_1();
4008 				break;
4009 			case 2 :
4010 				this.iload_2();
4011 				break;
4012 			case 3 :
4013 				this.iload_3();
4014 				break;
4015 			default :
4016 				this.iload(resolvedPosition);
4017 		}
4018 		return;
4019 	}
4020 
4021 	// Reference object
4022 	switch (resolvedPosition) {
4023 		case 0 :
4024 			this.aload_0();
4025 			break;
4026 		case 1 :
4027 			this.aload_1();
4028 			break;
4029 		case 2 :
4030 			this.aload_2();
4031 			break;
4032 		case 3 :
4033 			this.aload_3();
4034 			break;
4035 		default :
4036 			this.aload(resolvedPosition);
4037 	}
4038 }
load(TypeBinding typeBinding, int resolvedPosition)4039 public final void load(TypeBinding typeBinding, int resolvedPosition) {
4040 	countLabels = 0;
4041 	// Using dedicated int bytecode
4042 	if (typeBinding == IntBinding) {
4043 		switch (resolvedPosition) {
4044 			case 0 :
4045 				this.iload_0();
4046 				break;
4047 			case 1 :
4048 				this.iload_1();
4049 				break;
4050 			case 2 :
4051 				this.iload_2();
4052 				break;
4053 			case 3 :
4054 				this.iload_3();
4055 				break;
4056 			default :
4057 				this.iload(resolvedPosition);
4058 		}
4059 		return;
4060 	}
4061 	// Using dedicated float bytecode
4062 	if (typeBinding == FloatBinding) {
4063 		switch (resolvedPosition) {
4064 			case 0 :
4065 				this.fload_0();
4066 				break;
4067 			case 1 :
4068 				this.fload_1();
4069 				break;
4070 			case 2 :
4071 				this.fload_2();
4072 				break;
4073 			case 3 :
4074 				this.fload_3();
4075 				break;
4076 			default :
4077 				this.fload(resolvedPosition);
4078 		}
4079 		return;
4080 	}
4081 	// Using dedicated long bytecode
4082 	if (typeBinding == LongBinding) {
4083 		switch (resolvedPosition) {
4084 			case 0 :
4085 				this.lload_0();
4086 				break;
4087 			case 1 :
4088 				this.lload_1();
4089 				break;
4090 			case 2 :
4091 				this.lload_2();
4092 				break;
4093 			case 3 :
4094 				this.lload_3();
4095 				break;
4096 			default :
4097 				this.lload(resolvedPosition);
4098 		}
4099 		return;
4100 	}
4101 	// Using dedicated double bytecode
4102 	if (typeBinding == DoubleBinding) {
4103 		switch (resolvedPosition) {
4104 			case 0 :
4105 				this.dload_0();
4106 				break;
4107 			case 1 :
4108 				this.dload_1();
4109 				break;
4110 			case 2 :
4111 				this.dload_2();
4112 				break;
4113 			case 3 :
4114 				this.dload_3();
4115 				break;
4116 			default :
4117 				this.dload(resolvedPosition);
4118 		}
4119 		return;
4120 	}
4121 	// boolean, byte, char and short are handled as int
4122 	if ((typeBinding == ByteBinding) || (typeBinding == CharBinding) || (typeBinding == BooleanBinding) || (typeBinding == ShortBinding)) {
4123 		switch (resolvedPosition) {
4124 			case 0 :
4125 				this.iload_0();
4126 				break;
4127 			case 1 :
4128 				this.iload_1();
4129 				break;
4130 			case 2 :
4131 				this.iload_2();
4132 				break;
4133 			case 3 :
4134 				this.iload_3();
4135 				break;
4136 			default :
4137 				this.iload(resolvedPosition);
4138 		}
4139 		return;
4140 	}
4141 
4142 	// Reference object
4143 	switch (resolvedPosition) {
4144 		case 0 :
4145 			this.aload_0();
4146 			break;
4147 		case 1 :
4148 			this.aload_1();
4149 			break;
4150 		case 2 :
4151 			this.aload_2();
4152 			break;
4153 		case 3 :
4154 			this.aload_3();
4155 			break;
4156 		default :
4157 			this.aload(resolvedPosition);
4158 	}
4159 }
loadInt(int resolvedPosition)4160 public final void loadInt(int resolvedPosition) {
4161 	// Using dedicated int bytecode
4162 	switch (resolvedPosition) {
4163 		case 0 :
4164 			this.iload_0();
4165 			break;
4166 		case 1 :
4167 			this.iload_1();
4168 			break;
4169 		case 2 :
4170 			this.iload_2();
4171 			break;
4172 		case 3 :
4173 			this.iload_3();
4174 			break;
4175 		default :
4176 			this.iload(resolvedPosition);
4177 	}
4178 }
loadObject(int resolvedPosition)4179 public final void loadObject(int resolvedPosition) {
4180 	switch (resolvedPosition) {
4181 		case 0 :
4182 			this.aload_0();
4183 			break;
4184 		case 1 :
4185 			this.aload_1();
4186 			break;
4187 		case 2 :
4188 			this.aload_2();
4189 			break;
4190 		case 3 :
4191 			this.aload_3();
4192 			break;
4193 		default :
4194 			this.aload(resolvedPosition);
4195 	}
4196 }
lookupswitch(CaseLabel defaultLabel, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel)4197 final public void lookupswitch(CaseLabel defaultLabel, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel) {
4198 	if (DEBUG) System.out.println(position + "\t\tlookupswitch"); //$NON-NLS-1$
4199 	countLabels = 0;
4200 	stackDepth--;
4201 	int length = keys.length;
4202 	int pos = position;
4203 	defaultLabel.placeInstruction();
4204 	for (int i = 0; i < length; i++) {
4205 		casesLabel[i].placeInstruction();
4206 	}
4207 	if (classFileOffset >= bCodeStream.length) {
4208 		resizeByteArray();
4209 	}
4210 	position++;
4211 	bCodeStream[classFileOffset++] = OPC_lookupswitch;
4212 	for (int i = (3 - (pos % 4)); i > 0; i--) {
4213 		if (classFileOffset >= bCodeStream.length) {
4214 			resizeByteArray();
4215 		}
4216 		position++;
4217 		bCodeStream[classFileOffset++] = 0;
4218 	}
4219 	defaultLabel.branch();
4220 	writeSignedWord(length);
4221 	for (int i = 0; i < length; i++) {
4222 		writeSignedWord(keys[sortedIndexes[i]]);
4223 		casesLabel[sortedIndexes[i]].branch();
4224 	}
4225 }
lor()4226 final public void lor() {
4227 	if (DEBUG) System.out.println(position + "\t\tlor"); //$NON-NLS-1$
4228 	countLabels = 0;
4229 	stackDepth -= 2;
4230 	if (classFileOffset >= bCodeStream.length) {
4231 		resizeByteArray();
4232 	}
4233 	position++;
4234 	bCodeStream[classFileOffset++] = OPC_lor;
4235 }
lrem()4236 final public void lrem() {
4237 	if (DEBUG) System.out.println(position + "\t\tlrem"); //$NON-NLS-1$
4238 	countLabels = 0;
4239 	stackDepth -= 2;
4240 	if (classFileOffset >= bCodeStream.length) {
4241 		resizeByteArray();
4242 	}
4243 	position++;
4244 	bCodeStream[classFileOffset++] = OPC_lrem;
4245 }
lreturn()4246 final public void lreturn() {
4247 	if (DEBUG) System.out.println(position + "\t\tlreturn"); //$NON-NLS-1$
4248 	countLabels = 0;
4249 	stackDepth -= 2;
4250 	// the stackDepth should be equal to 0
4251 	if (classFileOffset >= bCodeStream.length) {
4252 		resizeByteArray();
4253 	}
4254 	position++;
4255 	bCodeStream[classFileOffset++] = OPC_lreturn;
4256 }
lshl()4257 final public void lshl() {
4258 	if (DEBUG) System.out.println(position + "\t\tlshl"); //$NON-NLS-1$
4259 	countLabels = 0;
4260 	stackDepth--;
4261 	if (classFileOffset >= bCodeStream.length) {
4262 		resizeByteArray();
4263 	}
4264 	position++;
4265 	bCodeStream[classFileOffset++] = OPC_lshl;
4266 }
lshr()4267 final public void lshr() {
4268 	if (DEBUG) System.out.println(position + "\t\tlshr"); //$NON-NLS-1$
4269 	countLabels = 0;
4270 	stackDepth--;
4271 	if (classFileOffset >= bCodeStream.length) {
4272 		resizeByteArray();
4273 	}
4274 	position++;
4275 	bCodeStream[classFileOffset++] = OPC_lshr;
4276 }
lstore(int iArg)4277 final public void lstore(int iArg) {
4278 	if (DEBUG) System.out.println(position + "\t\tlstore:"+iArg); //$NON-NLS-1$
4279 	countLabels = 0;
4280 	stackDepth -= 2;
4281 	if (maxLocals <= iArg + 1) {
4282 		maxLocals = iArg + 2;
4283 	}
4284 	if (iArg > 255) { // Widen
4285 		if (classFileOffset + 3 >= bCodeStream.length) {
4286 			resizeByteArray();
4287 		}
4288 		position += 2;
4289 		bCodeStream[classFileOffset++] = OPC_wide;
4290 		bCodeStream[classFileOffset++] = OPC_lstore;
4291 		writeUnsignedShort(iArg);
4292 	} else {
4293 		if (classFileOffset + 1 >= bCodeStream.length) {
4294 			resizeByteArray();
4295 		}
4296 		position += 2;
4297 		bCodeStream[classFileOffset++] = OPC_lstore;
4298 		bCodeStream[classFileOffset++] = (byte) iArg;
4299 	}
4300 }
lstore_0()4301 final public void lstore_0() {
4302 	if (DEBUG) System.out.println(position + "\t\tlstore_0"); //$NON-NLS-1$
4303 	countLabels = 0;
4304 	stackDepth -= 2;
4305 	if (maxLocals < 2) {
4306 		maxLocals = 2;
4307 	}
4308 	if (classFileOffset >= bCodeStream.length) {
4309 		resizeByteArray();
4310 	}
4311 	position++;
4312 	bCodeStream[classFileOffset++] = OPC_lstore_0;
4313 }
lstore_1()4314 final public void lstore_1() {
4315 	if (DEBUG) System.out.println(position + "\t\tlstore_1"); //$NON-NLS-1$
4316 	countLabels = 0;
4317 	stackDepth -= 2;
4318 	if (maxLocals < 3) {
4319 		maxLocals = 3;
4320 	}
4321 	if (classFileOffset >= bCodeStream.length) {
4322 		resizeByteArray();
4323 	}
4324 	position++;
4325 	bCodeStream[classFileOffset++] = OPC_lstore_1;
4326 }
lstore_2()4327 final public void lstore_2() {
4328 	if (DEBUG) System.out.println(position + "\t\tlstore_2"); //$NON-NLS-1$
4329 	countLabels = 0;
4330 	stackDepth -= 2;
4331 	if (maxLocals < 4) {
4332 		maxLocals = 4;
4333 	}
4334 	if (classFileOffset >= bCodeStream.length) {
4335 		resizeByteArray();
4336 	}
4337 	position++;
4338 	bCodeStream[classFileOffset++] = OPC_lstore_2;
4339 }
lstore_3()4340 final public void lstore_3() {
4341 	if (DEBUG) System.out.println(position + "\t\tlstore_3"); //$NON-NLS-1$
4342 	countLabels = 0;
4343 	stackDepth -= 2;
4344 	if (maxLocals < 5) {
4345 		maxLocals = 5;
4346 	}
4347 	if (classFileOffset >= bCodeStream.length) {
4348 		resizeByteArray();
4349 	}
4350 	position++;
4351 	bCodeStream[classFileOffset++] = OPC_lstore_3;
4352 }
lsub()4353 final public void lsub() {
4354 	if (DEBUG) System.out.println(position + "\t\tlsub"); //$NON-NLS-1$
4355 	countLabels = 0;
4356 	stackDepth -= 2;
4357 	if (classFileOffset >= bCodeStream.length) {
4358 		resizeByteArray();
4359 	}
4360 	position++;
4361 	bCodeStream[classFileOffset++] = OPC_lsub;
4362 }
lushr()4363 final public void lushr() {
4364 	if (DEBUG) System.out.println(position + "\t\tlushr"); //$NON-NLS-1$
4365 	countLabels = 0;
4366 	stackDepth--;
4367 	if (classFileOffset >= bCodeStream.length) {
4368 		resizeByteArray();
4369 	}
4370 	position++;
4371 	bCodeStream[classFileOffset++] = OPC_lushr;
4372 }
lxor()4373 final public void lxor() {
4374 	if (DEBUG) System.out.println(position + "\t\tlxor"); //$NON-NLS-1$
4375 	countLabels = 0;
4376 	stackDepth -= 2;
4377 	if (classFileOffset >= bCodeStream.length) {
4378 		resizeByteArray();
4379 	}
4380 	position++;
4381 	bCodeStream[classFileOffset++] = OPC_lxor;
4382 }
monitorenter()4383 final public void monitorenter() {
4384 	if (DEBUG) System.out.println(position + "\t\tmonitorenter"); //$NON-NLS-1$
4385 	countLabels = 0;
4386 	stackDepth--;
4387 	if (classFileOffset >= bCodeStream.length) {
4388 		resizeByteArray();
4389 	}
4390 	position++;
4391 	bCodeStream[classFileOffset++] = OPC_monitorenter;
4392 }
monitorexit()4393 final public void monitorexit() {
4394 	if (DEBUG) System.out.println(position + "\t\tmonitorexit"); //$NON-NLS-1$
4395 	countLabels = 0;
4396 	stackDepth--;
4397 	if (classFileOffset >= bCodeStream.length) {
4398 		resizeByteArray();
4399 	}
4400 	position++;
4401 	bCodeStream[classFileOffset++] = OPC_monitorexit;
4402 }
multianewarray(TypeBinding typeBinding, int dimensions)4403 final public void multianewarray(TypeBinding typeBinding, int dimensions) {
4404 	if (DEBUG) System.out.println(position + "\t\tmultinewarray:"+typeBinding+","+dimensions); //$NON-NLS-1$ //$NON-NLS-2$
4405 	countLabels = 0;
4406 	stackDepth += (1 - dimensions);
4407 	if (classFileOffset + 3 >= bCodeStream.length) {
4408 		resizeByteArray();
4409 	}
4410 	position += 2;
4411 	bCodeStream[classFileOffset++] = OPC_multianewarray;
4412 	writeUnsignedShort(constantPool.literalIndex(typeBinding));
4413 	bCodeStream[classFileOffset++] = (byte) dimensions;
4414 }
4415 /**
4416  * We didn't call it new, because there is a conflit with the new keyword
4417  */
new_(TypeBinding typeBinding)4418 final public void new_(TypeBinding typeBinding) {
4419 	if (DEBUG) System.out.println(position + "\t\tnew:"+typeBinding); //$NON-NLS-1$
4420 	countLabels = 0;
4421 	stackDepth++;
4422 	if (stackDepth > stackMax)
4423 		stackMax = stackDepth;
4424 	if (classFileOffset + 2 >= bCodeStream.length) {
4425 		resizeByteArray();
4426 	}
4427 	position++;
4428 	bCodeStream[classFileOffset++] = OPC_new;
4429 	writeUnsignedShort(constantPool.literalIndex(typeBinding));
4430 }
newarray(int array_Type)4431 final public void newarray(int array_Type) {
4432 	if (DEBUG) System.out.println(position + "\t\tnewarray:"+array_Type); //$NON-NLS-1$
4433 	countLabels = 0;
4434 	if (classFileOffset + 1 >= bCodeStream.length) {
4435 		resizeByteArray();
4436 	}
4437 	position += 2;
4438 	bCodeStream[classFileOffset++] = OPC_newarray;
4439 	bCodeStream[classFileOffset++] = (byte) array_Type;
4440 }
newArray(Scope scope, ArrayBinding arrayBinding)4441 public void newArray(Scope scope, ArrayBinding arrayBinding) {
4442 	TypeBinding component = arrayBinding.elementsType();
4443 	switch (component.id) {
4444 		case T_int :
4445 			this.newarray(INT_ARRAY);
4446 			break;
4447 		case T_byte :
4448 			this.newarray(BYTE_ARRAY);
4449 			break;
4450 		case T_boolean :
4451 			this.newarray(BOOLEAN_ARRAY);
4452 			break;
4453 		case T_short :
4454 			this.newarray(SHORT_ARRAY);
4455 			break;
4456 		case T_char :
4457 			this.newarray(CHAR_ARRAY);
4458 			break;
4459 		case T_long :
4460 			this.newarray(LONG_ARRAY);
4461 			break;
4462 		case T_float :
4463 			this.newarray(FLOAT_ARRAY);
4464 			break;
4465 		case T_double :
4466 			this.newarray(DOUBLE_ARRAY);
4467 			break;
4468 		default :
4469 			this.anewarray(component);
4470 	}
4471 }
newJavaLangError()4472 public void newJavaLangError() {
4473 	// new: java.lang.Error
4474 	if (DEBUG) System.out.println(position + "\t\tnew: java.lang.Error"); //$NON-NLS-1$
4475 	countLabels = 0;
4476 	stackDepth++;
4477 	if (stackDepth > stackMax)
4478 		stackMax = stackDepth;
4479 	if (classFileOffset + 2 >= bCodeStream.length) {
4480 		resizeByteArray();
4481 	}
4482 	position++;
4483 	bCodeStream[classFileOffset++] = OPC_new;
4484 	writeUnsignedShort(constantPool.literalIndexForJavaLangError());
4485 }
4486 
newJavaLangAssertionError()4487 public void newJavaLangAssertionError() {
4488 	// new: java.lang.AssertionError
4489 	if (DEBUG) System.out.println(position + "\t\tnew: java.lang.AssertionError"); //$NON-NLS-1$
4490 	countLabels = 0;
4491 	stackDepth++;
4492 	if (stackDepth > stackMax)
4493 		stackMax = stackDepth;
4494 	if (classFileOffset + 2 >= bCodeStream.length) {
4495 		resizeByteArray();
4496 	}
4497 	position++;
4498 	bCodeStream[classFileOffset++] = OPC_new;
4499 	writeUnsignedShort(constantPool.literalIndexForJavaLangAssertionError());
4500 }
4501 
newNoClassDefFoundError()4502 public void newNoClassDefFoundError() {
4503 	// new: java.lang.NoClassDefFoundError
4504 	if (DEBUG) System.out.println(position + "\t\tnew: java.lang.NoClassDefFoundError"); //$NON-NLS-1$
4505 	countLabels = 0;
4506 	stackDepth++;
4507 	if (stackDepth > stackMax)
4508 		stackMax = stackDepth;
4509 	if (classFileOffset + 2 >= bCodeStream.length) {
4510 		resizeByteArray();
4511 	}
4512 	position++;
4513 	bCodeStream[classFileOffset++] = OPC_new;
4514 	writeUnsignedShort(constantPool.literalIndexForJavaLangNoClassDefFoundError());
4515 }
newStringContatenation()4516 public void newStringContatenation() {
4517 	// new: java.lang.StringBuffer
4518 	// new: java.lang.StringBuilder
4519 	if (DEBUG) {
4520 		if (this.targetLevel >= JDK1_5) {
4521 			System.out.println(position + "\t\tnew: java.lang.StringBuilder"); //$NON-NLS-1$
4522 		} else {
4523 			System.out.println(position + "\t\tnew: java.lang.StringBuffer"); //$NON-NLS-1$
4524 		}
4525 	}
4526 	countLabels = 0;
4527 	stackDepth++;
4528 	if (stackDepth > stackMax) {
4529 		stackMax = stackDepth;
4530 	}
4531 	if (classFileOffset + 2 >= bCodeStream.length) {
4532 		resizeByteArray();
4533 	}
4534 	position++;
4535 	bCodeStream[classFileOffset++] = OPC_new;
4536 	if (this.targetLevel >= JDK1_5) {
4537 		writeUnsignedShort(constantPool.literalIndexForJavaLangStringBuilder());
4538 	} else {
4539 		writeUnsignedShort(constantPool.literalIndexForJavaLangStringBuffer());
4540 	}
4541 }
newWrapperFor(int typeID)4542 public void newWrapperFor(int typeID) {
4543 	countLabels = 0;
4544 	stackDepth++;
4545 	if (stackDepth > stackMax)
4546 		stackMax = stackDepth;
4547 	if (classFileOffset + 2 >= bCodeStream.length) {
4548 		resizeByteArray();
4549 	}
4550 	position++;
4551 	bCodeStream[classFileOffset++] = OPC_new;
4552 	switch (typeID) {
4553 		case T_int : // new: java.lang.Integer
4554 			if (DEBUG) System.out.println(position + "\t\tnew: java.lang.Integer"); //$NON-NLS-1$
4555 			writeUnsignedShort(constantPool.literalIndexForJavaLangInteger());
4556 			break;
4557 		case T_boolean : // new: java.lang.Boolean
4558 			if (DEBUG) System.out.println(position + "\t\tnew: java.lang.Boolean"); //$NON-NLS-1$
4559 			writeUnsignedShort(constantPool.literalIndexForJavaLangBoolean());
4560 			break;
4561 		case T_byte : // new: java.lang.Byte
4562 			if (DEBUG) System.out.println(position + "\t\tnew: java.lang.Byte"); //$NON-NLS-1$
4563 			writeUnsignedShort(constantPool.literalIndexForJavaLangByte());
4564 			break;
4565 		case T_char : // new: java.lang.Character
4566 			if (DEBUG) System.out.println(position + "\t\tnew: java.lang.Character"); //$NON-NLS-1$
4567 			writeUnsignedShort(constantPool.literalIndexForJavaLangCharacter());
4568 			break;
4569 		case T_float : // new: java.lang.Float
4570 			if (DEBUG) System.out.println(position + "\t\tnew: java.lang.Float"); //$NON-NLS-1$
4571 			writeUnsignedShort(constantPool.literalIndexForJavaLangFloat());
4572 			break;
4573 		case T_double : // new: java.lang.Double
4574 			if (DEBUG) System.out.println(position + "\t\tnew: java.lang.Double"); //$NON-NLS-1$
4575 			writeUnsignedShort(constantPool.literalIndexForJavaLangDouble());
4576 			break;
4577 		case T_short : // new: java.lang.Short
4578 			if (DEBUG) System.out.println(position + "\t\tnew: java.lang.Short"); //$NON-NLS-1$
4579 			writeUnsignedShort(constantPool.literalIndexForJavaLangShort());
4580 			break;
4581 		case T_long : // new: java.lang.Long
4582 			if (DEBUG) System.out.println(position + "\t\tnew: java.lang.Long"); //$NON-NLS-1$
4583 			writeUnsignedShort(constantPool.literalIndexForJavaLangLong());
4584 			break;
4585 		case T_void : // new: java.lang.Void
4586 			if (DEBUG) System.out.println(position + "\t\tnew: java.lang.Void"); //$NON-NLS-1$
4587 			writeUnsignedShort(constantPool.literalIndexForJavaLangVoid());
4588 	}
4589 }
nop()4590 final public void nop() {
4591 	if (DEBUG) System.out.println(position + "\t\tnop"); //$NON-NLS-1$
4592 	countLabels = 0;
4593 	if (classFileOffset >= bCodeStream.length) {
4594 		resizeByteArray();
4595 	}
4596 	position++;
4597 	bCodeStream[classFileOffset++] = OPC_nop;
4598 }
pop()4599 final public void pop() {
4600 	if (DEBUG) System.out.println(position + "\t\tpop"); //$NON-NLS-1$
4601 	countLabels = 0;
4602 	stackDepth--;
4603 	if (classFileOffset >= bCodeStream.length) {
4604 		resizeByteArray();
4605 	}
4606 	position++;
4607 	bCodeStream[classFileOffset++] = OPC_pop;
4608 }
pop2()4609 final public void pop2() {
4610 	if (DEBUG) System.out.println(position + "\t\tpop2"); //$NON-NLS-1$
4611 	countLabels = 0;
4612 	stackDepth -= 2;
4613 	if (classFileOffset >= bCodeStream.length) {
4614 		resizeByteArray();
4615 	}
4616 	position++;
4617 	bCodeStream[classFileOffset++] = OPC_pop2;
4618 }
putfield(FieldBinding fieldBinding)4619 final public void putfield(FieldBinding fieldBinding) {
4620 	if (DEBUG) System.out.println(position + "\t\tputfield:"+fieldBinding); //$NON-NLS-1$
4621 	countLabels = 0;
4622 	int id;
4623 	if (((id = fieldBinding.type.id) == T_double) || (id == T_long))
4624 		stackDepth -= 3;
4625 	else
4626 		stackDepth -= 2;
4627 	if (stackDepth > stackMax)
4628 		stackMax = stackDepth;
4629 	if (classFileOffset + 2 >= bCodeStream.length) {
4630 		resizeByteArray();
4631 	}
4632 	position++;
4633 	bCodeStream[classFileOffset++] = OPC_putfield;
4634 	writeUnsignedShort(constantPool.literalIndex(fieldBinding));
4635 }
putstatic(FieldBinding fieldBinding)4636 final public void putstatic(FieldBinding fieldBinding) {
4637 	if (DEBUG) System.out.println(position + "\t\tputstatic:"+fieldBinding); //$NON-NLS-1$
4638 	countLabels = 0;
4639 	int id;
4640 	if (((id = fieldBinding.type.id) == T_double) || (id == T_long))
4641 		stackDepth -= 2;
4642 	else
4643 		stackDepth -= 1;
4644 	if (stackDepth > stackMax)
4645 		stackMax = stackDepth;
4646 	if (classFileOffset + 2 >= bCodeStream.length) {
4647 		resizeByteArray();
4648 	}
4649 	position++;
4650 	bCodeStream[classFileOffset++] = OPC_putstatic;
4651 	writeUnsignedShort(constantPool.literalIndex(fieldBinding));
4652 }
record(LocalVariableBinding local)4653 public void record(LocalVariableBinding local) {
4654 	if (!generateLocalVariableTableAttributes)
4655 		return;
4656 	if (allLocalsCounter == locals.length) {
4657 		// resize the collection
4658 		System.arraycopy(locals, 0, locals = new LocalVariableBinding[allLocalsCounter + LOCALS_INCREMENT], 0, allLocalsCounter);
4659 	}
4660 	locals[allLocalsCounter++] = local;
4661 	local.initializationPCs = new int[4];
4662 	local.initializationCount = 0;
4663 }
recordPositionsFrom(int startPC, int sourcePos)4664 public void recordPositionsFrom(int startPC, int sourcePos) {
4665 
4666 	/* Record positions in the table, only if nothing has
4667 	 * already been recorded. Since we output them on the way
4668 	 * up (children first for more specific info)
4669 	 * The pcToSourceMap table is always sorted.
4670 	 */
4671 
4672 	if (!generateLineNumberAttributes)
4673 		return;
4674 	if (sourcePos == 0)
4675 		return;
4676 
4677 	// no code generated for this node. e.g. field without any initialization
4678 	if (position == startPC)
4679 		return;
4680 
4681 	// Widening an existing entry that already has the same source positions
4682 	if (pcToSourceMapSize + 4 > pcToSourceMap.length) {
4683 		// resize the array pcToSourceMap
4684 		System.arraycopy(pcToSourceMap, 0, pcToSourceMap = new int[pcToSourceMapSize << 1], 0, pcToSourceMapSize);
4685 	}
4686 	int newLine = ClassFile.searchLineNumber(lineSeparatorPositions, sourcePos);
4687 	// lastEntryPC represents the endPC of the lastEntry.
4688 	if (pcToSourceMapSize > 0) {
4689 		// in this case there is already an entry in the table
4690 		if (pcToSourceMap[pcToSourceMapSize - 1] != newLine) {
4691 			if (startPC < lastEntryPC) {
4692 				// we forgot to add an entry.
4693 				// search if an existing entry exists for startPC
4694 				int insertionIndex = insertionIndex(pcToSourceMap, pcToSourceMapSize, startPC);
4695 				if (insertionIndex != -1) {
4696 					// there is no existing entry starting with startPC.
4697 					int existingEntryIndex = indexOfSameLineEntrySincePC(startPC, newLine); // index for PC
4698 					/* the existingEntryIndex corresponds to en entry with the same line and a PC >= startPC.
4699 						in this case it is relevant to widen this entry instead of creating a new one.
4700 						line1: this(a,
4701 						  b,
4702 						  c);
4703 						with this code we generate each argument. We generate a aload0 to invoke the constructor. There is no entry for this
4704 						aload0 bytecode. The first entry is the one for the argument a.
4705 						But we want the constructor call to start at the aload0 pc and not just at the pc of the first argument.
4706 						So we widen the existing entry (if there is one) or we create a new entry with the startPC.
4707 					*/
4708 					if (existingEntryIndex != -1) {
4709 						// widen existing entry
4710 						pcToSourceMap[existingEntryIndex] = startPC;
4711 					} else if (insertionIndex < 1 || pcToSourceMap[insertionIndex - 1] != newLine) {
4712 						// we have to add an entry that won't be sorted. So we sort the pcToSourceMap.
4713 						System.arraycopy(pcToSourceMap, insertionIndex, pcToSourceMap, insertionIndex + 2, pcToSourceMapSize - insertionIndex);
4714 						pcToSourceMap[insertionIndex++] = startPC;
4715 						pcToSourceMap[insertionIndex] = newLine;
4716 						pcToSourceMapSize += 2;
4717 					}
4718 				} else if (position != lastEntryPC) { // no bytecode since last entry pc
4719 					pcToSourceMap[pcToSourceMapSize++] = lastEntryPC;
4720 					pcToSourceMap[pcToSourceMapSize++] = newLine;
4721 				}
4722 			} else {
4723 				// we can safely add the new entry. The endPC of the previous entry is not in conflit with the startPC of the new entry.
4724 				pcToSourceMap[pcToSourceMapSize++] = startPC;
4725 				pcToSourceMap[pcToSourceMapSize++] = newLine;
4726 			}
4727 		} else {
4728 			/* the last recorded entry is on the same line. But it could be relevant to widen this entry.
4729 			   we want to extend this entry forward in case we generated some bytecode before the last entry that are not related to any statement
4730 			*/
4731 			if (startPC < pcToSourceMap[pcToSourceMapSize - 2]) {
4732 				int insertionIndex = insertionIndex(pcToSourceMap, pcToSourceMapSize, startPC);
4733 				if (insertionIndex != -1) {
4734 					// widen the existing entry
4735 					// we have to figure out if we need to move the last entry at another location to keep a sorted table
4736 					/* First we need to check if at the insertion position there is not an existing entry
4737 					 * that includes the one we want to insert. This is the case if pcToSourceMap[insertionIndex - 1] == newLine.
4738 					 * In this case we don't want to change the table. If not, we want to insert a new entry. Prior to insertion
4739 					 * we want to check if it is worth doing an arraycopy. If not we simply update the recorded pc.
4740 					 */
4741 					if (!((insertionIndex > 1) && (pcToSourceMap[insertionIndex - 1] == newLine))) {
4742 						if ((pcToSourceMapSize > 4) && (pcToSourceMap[pcToSourceMapSize - 4] > startPC)) {
4743 							System.arraycopy(pcToSourceMap, insertionIndex, pcToSourceMap, insertionIndex + 2, pcToSourceMapSize - 2 - insertionIndex);
4744 							pcToSourceMap[insertionIndex++] = startPC;
4745 							pcToSourceMap[insertionIndex] = newLine;
4746 						} else {
4747 							pcToSourceMap[pcToSourceMapSize - 2] = startPC;
4748 						}
4749 					}
4750 				}
4751 			}
4752 		}
4753 		lastEntryPC = position;
4754 	} else {
4755 		// record the first entry
4756 		pcToSourceMap[pcToSourceMapSize++] = startPC;
4757 		pcToSourceMap[pcToSourceMapSize++] = newLine;
4758 		lastEntryPC = position;
4759 	}
4760 }
4761 /**
4762  * @param anExceptionLabel org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel
4763  */
registerExceptionHandler(ExceptionLabel anExceptionLabel)4764 public void registerExceptionHandler(ExceptionLabel anExceptionLabel) {
4765 	int length;
4766 	if (exceptionHandlersIndex >= (length = exceptionHandlers.length)) {
4767 		// resize the exception handlers table
4768 		System.arraycopy(exceptionHandlers, 0, exceptionHandlers = new ExceptionLabel[length + LABELS_INCREMENT], 0, length);
4769 	}
4770 	// no need to resize. So just add the new exception label
4771 	exceptionHandlers[exceptionHandlersIndex++] = anExceptionLabel;
4772 	exceptionHandlersCounter++;
4773 }
removeExceptionHandler(ExceptionLabel exceptionLabel)4774 public void removeExceptionHandler(ExceptionLabel exceptionLabel) {
4775 	for (int i = 0; i < exceptionHandlersIndex; i++) {
4776 		if (exceptionHandlers[i] == exceptionLabel) {
4777 			exceptionHandlers[i] = null;
4778 			exceptionHandlersCounter--;
4779 			return;
4780 		}
4781 	}
4782 }
removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex)4783 public final void removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex) {
4784 	// given some flow info, make sure we did not loose some variables initialization
4785 	// if this happens, then we must update their pc entries to reflect it in debug attributes
4786 	if (!generateLocalVariableTableAttributes)
4787 		return;
4788 /*	if (initStateIndex == lastInitStateIndexWhenRemovingInits)
4789 		return;
4790 
4791 	lastInitStateIndexWhenRemovingInits = initStateIndex;
4792 	if (lastInitStateIndexWhenAddingInits != initStateIndex){
4793 		lastInitStateIndexWhenAddingInits = -2;// reinitialize add index
4794 		// add(1)-remove(1)-add(1) -> ignore second add
4795 		// add(1)-remove(2)-add(1) -> perform second add
4796 	}*/
4797 	for (int i = 0; i < visibleLocalsCount; i++) {
4798 		LocalVariableBinding localBinding = visibleLocals[i];
4799 		if (localBinding != null) {
4800 			if (initStateIndex == -1 || !isDefinitelyAssigned(scope, initStateIndex, localBinding)) {
4801 				if (localBinding.initializationCount > 0) {
4802 					localBinding.recordInitializationEndPC(position);
4803 				}
4804 			}
4805 		}
4806 	}
4807 }
4808 /**
4809  * @param referenceMethod org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration
4810  * @param targetClassFile org.eclipse.jdt.internal.compiler.codegen.ClassFile
4811  */
reset(AbstractMethodDeclaration referenceMethod, ClassFile targetClassFile)4812 public void reset(AbstractMethodDeclaration referenceMethod, ClassFile targetClassFile) {
4813 	init(targetClassFile);
4814 	this.methodDeclaration = referenceMethod;
4815 	preserveUnusedLocals = referenceMethod.scope.problemReporter().options.preserveAllLocalVariables;
4816 	initializeMaxLocals(referenceMethod.binding);
4817 }
4818 /**
4819  * @param targetClassFile The given classfile to reset the code stream
4820  */
resetForProblemClinit(ClassFile targetClassFile)4821 public void resetForProblemClinit(ClassFile targetClassFile) {
4822 	init(targetClassFile);
4823 	maxLocals = 0;
4824 }
resizeByteArray()4825 private final void resizeByteArray() {
4826 	int length = bCodeStream.length;
4827 	int requiredSize = length + length;
4828 	if (classFileOffset > requiredSize) {
4829 		// must be sure to grow by enough
4830 		requiredSize = classFileOffset + length;
4831 	}
4832 	System.arraycopy(bCodeStream, 0, bCodeStream = new byte[requiredSize], 0, length);
4833 }
ret(int index)4834 final public void ret(int index) {
4835 	if (DEBUG) System.out.println(position + "\t\tret:"+index); //$NON-NLS-1$
4836 	countLabels = 0;
4837 	if (index > 255) { // Widen
4838 		if (classFileOffset + 3 >= bCodeStream.length) {
4839 			resizeByteArray();
4840 		}
4841 		position += 2;
4842 		bCodeStream[classFileOffset++] = OPC_wide;
4843 		bCodeStream[classFileOffset++] = OPC_ret;
4844 		writeUnsignedShort(index);
4845 	} else { // Don't Widen
4846 		if (classFileOffset + 1 >= bCodeStream.length) {
4847 			resizeByteArray();
4848 		}
4849 		position += 2;
4850 		bCodeStream[classFileOffset++] = OPC_ret;
4851 		bCodeStream[classFileOffset++] = (byte) index;
4852 	}
4853 }
return_()4854 final public void return_() {
4855 	if (DEBUG) System.out.println(position + "\t\treturn"); //$NON-NLS-1$
4856 	countLabels = 0;
4857 	// the stackDepth should be equal to 0
4858 	if (classFileOffset >= bCodeStream.length) {
4859 		resizeByteArray();
4860 	}
4861 	position++;
4862 	bCodeStream[classFileOffset++] = OPC_return;
4863 }
saload()4864 final public void saload() {
4865 	if (DEBUG) System.out.println(position + "\t\tsaload"); //$NON-NLS-1$
4866 	countLabels = 0;
4867 	stackDepth--;
4868 	if (classFileOffset >= bCodeStream.length) {
4869 		resizeByteArray();
4870 	}
4871 	position++;
4872 	bCodeStream[classFileOffset++] = OPC_saload;
4873 }
sastore()4874 final public void sastore() {
4875 	if (DEBUG) System.out.println(position + "\t\tsastore"); //$NON-NLS-1$
4876 	countLabels = 0;
4877 	stackDepth -= 3;
4878 	if (classFileOffset >= bCodeStream.length) {
4879 		resizeByteArray();
4880 	}
4881 	position++;
4882 	bCodeStream[classFileOffset++] = OPC_sastore;
4883 }
4884 /**
4885  * @param operatorConstant int
4886  * @param type_ID int
4887  */
sendOperator(int operatorConstant, int type_ID)4888 public void sendOperator(int operatorConstant, int type_ID) {
4889 	switch (type_ID) {
4890 		case T_int :
4891 		case T_boolean :
4892 		case T_char :
4893 		case T_byte :
4894 		case T_short :
4895 			switch (operatorConstant) {
4896 				case PLUS :
4897 					this.iadd();
4898 					break;
4899 				case MINUS :
4900 					this.isub();
4901 					break;
4902 				case MULTIPLY :
4903 					this.imul();
4904 					break;
4905 				case DIVIDE :
4906 					this.idiv();
4907 					break;
4908 				case REMAINDER :
4909 					this.irem();
4910 					break;
4911 				case LEFT_SHIFT :
4912 					this.ishl();
4913 					break;
4914 				case RIGHT_SHIFT :
4915 					this.ishr();
4916 					break;
4917 				case UNSIGNED_RIGHT_SHIFT :
4918 					this.iushr();
4919 					break;
4920 				case AND :
4921 					this.iand();
4922 					break;
4923 				case OR :
4924 					this.ior();
4925 					break;
4926 				case XOR :
4927 					this.ixor();
4928 					break;
4929 			}
4930 			break;
4931 		case T_long :
4932 			switch (operatorConstant) {
4933 				case PLUS :
4934 					this.ladd();
4935 					break;
4936 				case MINUS :
4937 					this.lsub();
4938 					break;
4939 				case MULTIPLY :
4940 					this.lmul();
4941 					break;
4942 				case DIVIDE :
4943 					this.ldiv();
4944 					break;
4945 				case REMAINDER :
4946 					this.lrem();
4947 					break;
4948 				case LEFT_SHIFT :
4949 					this.lshl();
4950 					break;
4951 				case RIGHT_SHIFT :
4952 					this.lshr();
4953 					break;
4954 				case UNSIGNED_RIGHT_SHIFT :
4955 					this.lushr();
4956 					break;
4957 				case AND :
4958 					this.land();
4959 					break;
4960 				case OR :
4961 					this.lor();
4962 					break;
4963 				case XOR :
4964 					this.lxor();
4965 					break;
4966 			}
4967 			break;
4968 		case T_float :
4969 			switch (operatorConstant) {
4970 				case PLUS :
4971 					this.fadd();
4972 					break;
4973 				case MINUS :
4974 					this.fsub();
4975 					break;
4976 				case MULTIPLY :
4977 					this.fmul();
4978 					break;
4979 				case DIVIDE :
4980 					this.fdiv();
4981 					break;
4982 				case REMAINDER :
4983 					this.frem();
4984 			}
4985 			break;
4986 		case T_double :
4987 			switch (operatorConstant) {
4988 				case PLUS :
4989 					this.dadd();
4990 					break;
4991 				case MINUS :
4992 					this.dsub();
4993 					break;
4994 				case MULTIPLY :
4995 					this.dmul();
4996 					break;
4997 				case DIVIDE :
4998 					this.ddiv();
4999 					break;
5000 				case REMAINDER :
5001 					this.drem();
5002 			}
5003 	}
5004 }
sipush(int s)5005 final public void sipush(int s) {
5006 	if (DEBUG) System.out.println(position + "\t\tsipush:"+s); //$NON-NLS-1$
5007 	countLabels = 0;
5008 	stackDepth++;
5009 	if (stackDepth > stackMax)
5010 		stackMax = stackDepth;
5011 	if (classFileOffset >= bCodeStream.length) {
5012 		resizeByteArray();
5013 	}
5014 	position++;
5015 	bCodeStream[classFileOffset++] = OPC_sipush;
5016 	writeSignedShort(s);
5017 }
sort(int[] tab, int lo0, int hi0, int[] result)5018 public static final void sort(int[] tab, int lo0, int hi0, int[] result) {
5019 	int lo = lo0;
5020 	int hi = hi0;
5021 	int mid;
5022 	if (hi0 > lo0) {
5023 		/* Arbitrarily establishing partition element as the midpoint of
5024 		  * the array.
5025 		  */
5026 		mid = tab[ (lo0 + hi0) / 2];
5027 		// loop through the array until indices cross
5028 		while (lo <= hi) {
5029 			/* find the first element that is greater than or equal to
5030 			 * the partition element starting from the left Index.
5031 			 */
5032 			while ((lo < hi0) && (tab[lo] < mid))
5033 				++lo;
5034 			/* find an element that is smaller than or equal to
5035 			 * the partition element starting from the right Index.
5036 			 */
5037 			while ((hi > lo0) && (tab[hi] > mid))
5038 				--hi;
5039 			// if the indexes have not crossed, swap
5040 			if (lo <= hi) {
5041 				swap(tab, lo, hi, result);
5042 				++lo;
5043 				--hi;
5044 			}
5045 		}
5046 		/* If the right index has not reached the left side of array
5047 		  * must now sort the left partition.
5048 		  */
5049 		if (lo0 < hi)
5050 			sort(tab, lo0, hi, result);
5051 		/* If the left index has not reached the right side of array
5052 		  * must now sort the right partition.
5053 		  */
5054 		if (lo < hi0)
5055 			sort(tab, lo, hi0, result);
5056 	}
5057 }
5058 
store(LocalVariableBinding localBinding, boolean valueRequired)5059 public final void store(LocalVariableBinding localBinding, boolean valueRequired) {
5060 	int localPosition = localBinding.resolvedPosition;
5061 	// Using dedicated int bytecode
5062 	switch(localBinding.type.id) {
5063 		case TypeIds.T_int :
5064 		case TypeIds.T_char :
5065 		case TypeIds.T_byte :
5066 		case TypeIds.T_short :
5067 		case TypeIds.T_boolean :
5068 			if (valueRequired)
5069 				this.dup();
5070 			switch (localPosition) {
5071 				case 0 :
5072 					this.istore_0();
5073 					break;
5074 				case 1 :
5075 					this.istore_1();
5076 					break;
5077 				case 2 :
5078 					this.istore_2();
5079 					break;
5080 				case 3 :
5081 					this.istore_3();
5082 					break;
5083 				//case -1 :
5084 				// internal failure: trying to store into variable not supposed to be generated
5085 				//	break;
5086 				default :
5087 					this.istore(localPosition);
5088 			}
5089 			break;
5090 		case TypeIds.T_float :
5091 			if (valueRequired)
5092 				this.dup();
5093 			switch (localPosition) {
5094 				case 0 :
5095 					this.fstore_0();
5096 					break;
5097 				case 1 :
5098 					this.fstore_1();
5099 					break;
5100 				case 2 :
5101 					this.fstore_2();
5102 					break;
5103 				case 3 :
5104 					this.fstore_3();
5105 					break;
5106 				default :
5107 					this.fstore(localPosition);
5108 			}
5109 			break;
5110 		case TypeIds.T_double :
5111 			if (valueRequired)
5112 				this.dup2();
5113 			switch (localPosition) {
5114 				case 0 :
5115 					this.dstore_0();
5116 					break;
5117 				case 1 :
5118 					this.dstore_1();
5119 					break;
5120 				case 2 :
5121 					this.dstore_2();
5122 					break;
5123 				case 3 :
5124 					this.dstore_3();
5125 					break;
5126 				default :
5127 					this.dstore(localPosition);
5128 			}
5129 			break;
5130 		case TypeIds.T_long :
5131 			if (valueRequired)
5132 				this.dup2();
5133 			switch (localPosition) {
5134 				case 0 :
5135 					this.lstore_0();
5136 					break;
5137 				case 1 :
5138 					this.lstore_1();
5139 					break;
5140 				case 2 :
5141 					this.lstore_2();
5142 					break;
5143 				case 3 :
5144 					this.lstore_3();
5145 					break;
5146 				default :
5147 					this.lstore(localPosition);
5148 			}
5149 			break;
5150 		default:
5151 			// Reference object
5152 			if (valueRequired)
5153 				this.dup();
5154 			switch (localPosition) {
5155 				case 0 :
5156 					this.astore_0();
5157 					break;
5158 				case 1 :
5159 					this.astore_1();
5160 					break;
5161 				case 2 :
5162 					this.astore_2();
5163 					break;
5164 				case 3 :
5165 					this.astore_3();
5166 					break;
5167 				default :
5168 					this.astore(localPosition);
5169 			}
5170 	}
5171 }
store(TypeBinding type, int localPosition)5172 public final void store(TypeBinding type, int localPosition) {
5173 	// Using dedicated int bytecode
5174 	if ((type == IntBinding) || (type == CharBinding) || (type == ByteBinding) || (type == ShortBinding) || (type == BooleanBinding)) {
5175 		switch (localPosition) {
5176 			case 0 :
5177 				this.istore_0();
5178 				break;
5179 			case 1 :
5180 				this.istore_1();
5181 				break;
5182 			case 2 :
5183 				this.istore_2();
5184 				break;
5185 			case 3 :
5186 				this.istore_3();
5187 				break;
5188 			default :
5189 				this.istore(localPosition);
5190 		}
5191 		return;
5192 	}
5193 	// Using dedicated float bytecode
5194 	if (type == FloatBinding) {
5195 		switch (localPosition) {
5196 			case 0 :
5197 				this.fstore_0();
5198 				break;
5199 			case 1 :
5200 				this.fstore_1();
5201 				break;
5202 			case 2 :
5203 				this.fstore_2();
5204 				break;
5205 			case 3 :
5206 				this.fstore_3();
5207 				break;
5208 			default :
5209 				this.fstore(localPosition);
5210 		}
5211 		return;
5212 	}
5213 	// Using dedicated long bytecode
5214 	if (type == LongBinding) {
5215 		switch (localPosition) {
5216 			case 0 :
5217 				this.lstore_0();
5218 				break;
5219 			case 1 :
5220 				this.lstore_1();
5221 				break;
5222 			case 2 :
5223 				this.lstore_2();
5224 				break;
5225 			case 3 :
5226 				this.lstore_3();
5227 				break;
5228 			default :
5229 				this.lstore(localPosition);
5230 		}
5231 		return;
5232 	}
5233 	// Using dedicated double bytecode
5234 	if (type == DoubleBinding) {
5235 		switch (localPosition) {
5236 			case 0 :
5237 				this.dstore_0();
5238 				break;
5239 			case 1 :
5240 				this.dstore_1();
5241 				break;
5242 			case 2 :
5243 				this.dstore_2();
5244 				break;
5245 			case 3 :
5246 				this.dstore_3();
5247 				break;
5248 			default :
5249 				this.dstore(localPosition);
5250 		}
5251 		return;
5252 	}
5253 	// Reference object
5254 	switch (localPosition) {
5255 		case 0 :
5256 			this.astore_0();
5257 			break;
5258 		case 1 :
5259 			this.astore_1();
5260 			break;
5261 		case 2 :
5262 			this.astore_2();
5263 			break;
5264 		case 3 :
5265 			this.astore_3();
5266 			break;
5267 		default :
5268 			this.astore(localPosition);
5269 	}
5270 }
storeInt(int localPosition)5271 public final void storeInt(int localPosition) {
5272 	switch (localPosition) {
5273 		case 0 :
5274 			this.istore_0();
5275 			break;
5276 		case 1 :
5277 			this.istore_1();
5278 			break;
5279 		case 2 :
5280 			this.istore_2();
5281 			break;
5282 		case 3 :
5283 			this.istore_3();
5284 			break;
5285 		default :
5286 			this.istore(localPosition);
5287 	}
5288 }
storeObject(int localPosition)5289 public final void storeObject(int localPosition) {
5290 	switch (localPosition) {
5291 		case 0 :
5292 			this.astore_0();
5293 			break;
5294 		case 1 :
5295 			this.astore_1();
5296 			break;
5297 		case 2 :
5298 			this.astore_2();
5299 			break;
5300 		case 3 :
5301 			this.astore_3();
5302 			break;
5303 		default :
5304 			this.astore(localPosition);
5305 	}
5306 }
swap()5307 final public void swap() {
5308 	if (DEBUG) System.out.println(position + "\t\tswap"); //$NON-NLS-1$
5309 	countLabels = 0;
5310 	if (classFileOffset >= bCodeStream.length) {
5311 		resizeByteArray();
5312 	}
5313 	position++;
5314 	bCodeStream[classFileOffset++] = OPC_swap;
5315 }
swap(int a[], int i, int j, int result[])5316 private static final void swap(int a[], int i, int j, int result[]) {
5317 	int T;
5318 	T = a[i];
5319 	a[i] = a[j];
5320 	a[j] = T;
5321 	T = result[j];
5322 	result[j] = result[i];
5323 	result[i] = T;
5324 }
tableswitch(CaseLabel defaultLabel, int low, int high, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel)5325 final public void tableswitch(CaseLabel defaultLabel, int low, int high, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel) {
5326 	if (DEBUG) System.out.println(position + "\t\ttableswitch"); //$NON-NLS-1$
5327 	countLabels = 0;
5328 	stackDepth--;
5329 	int length = casesLabel.length;
5330 	int pos = position;
5331 	defaultLabel.placeInstruction();
5332 	for (int i = 0; i < length; i++)
5333 		casesLabel[i].placeInstruction();
5334 	if (classFileOffset >= bCodeStream.length) {
5335 		resizeByteArray();
5336 	}
5337 	position++;
5338 	bCodeStream[classFileOffset++] = OPC_tableswitch;
5339 	for (int i = (3 - (pos % 4)); i > 0; i--) {
5340 		if (classFileOffset >= bCodeStream.length) {
5341 			resizeByteArray();
5342 		}
5343 		position++;
5344 		bCodeStream[classFileOffset++] = 0;
5345 	}
5346 	defaultLabel.branch();
5347 	writeSignedWord(low);
5348 	writeSignedWord(high);
5349 	int i = low, j = low;
5350 	// the index j is used to know if the index i is one of the missing entries in case of an
5351 	// optimized tableswitch
5352 	while (true) {
5353 		int index;
5354 		int key = keys[index = sortedIndexes[j - low]];
5355 		if (key == i) {
5356 			casesLabel[index].branch();
5357 			j++;
5358 			if (i == high) break; // if high is maxint, then avoids wrapping to minint.
5359 		} else {
5360 			defaultLabel.branch();
5361 		}
5362 		i++;
5363 	}
5364 }
toString()5365 public String toString() {
5366 	StringBuffer buffer = new StringBuffer("( position:"); //$NON-NLS-1$
5367 	buffer.append(position);
5368 	buffer.append(",\nstackDepth:"); //$NON-NLS-1$
5369 	buffer.append(stackDepth);
5370 	buffer.append(",\nmaxStack:"); //$NON-NLS-1$
5371 	buffer.append(stackMax);
5372 	buffer.append(",\nmaxLocals:"); //$NON-NLS-1$
5373 	buffer.append(maxLocals);
5374 	buffer.append(")"); //$NON-NLS-1$
5375 	return buffer.toString();
5376 }
updateLastRecordedEndPC(int pos)5377 public void updateLastRecordedEndPC(int pos) {
5378 
5379 	/* Tune positions in the table, this is due to some
5380 	 * extra bytecodes being
5381 	 * added to some user code (jumps). */
5382 	/** OLD CODE
5383 		if (!generateLineNumberAttributes)
5384 			return;
5385 		pcToSourceMap[pcToSourceMapSize - 1][1] = position;
5386 		// need to update the initialization endPC in case of generation of local variable attributes.
5387 		updateLocalVariablesAttribute(pos);
5388 	*/
5389 
5390 	if (!generateLineNumberAttributes)
5391 		return;
5392 	this.lastEntryPC = pos;
5393 	// need to update the initialization endPC in case of generation of local variable attributes.
5394 	updateLocalVariablesAttribute(pos);
5395 }
updateLocalVariablesAttribute(int pos)5396 public void updateLocalVariablesAttribute(int pos) {
5397 	// need to update the initialization endPC in case of generation of local variable attributes.
5398 	if (generateLocalVariableTableAttributes) {
5399 		for (int i = 0, max = locals.length; i < max; i++) {
5400 			LocalVariableBinding local = locals[i];
5401 			if ((local != null) && (local.initializationCount > 0)) {
5402 				if (local.initializationPCs[((local.initializationCount - 1) << 1) + 1] == pos) {
5403 					local.initializationPCs[((local.initializationCount - 1) << 1) + 1] = position;
5404 				}
5405 			}
5406 		}
5407 	}
5408 }
5409 /**
5410  * Write a signed 16 bits value into the byte array
5411  * @param value the signed short
5412  */
writeSignedShort(int value)5413 public final void writeSignedShort(int value) {
5414 	// we keep the resize in here because it is used outside the code stream
5415 	if (classFileOffset + 1 >= bCodeStream.length) {
5416 		resizeByteArray();
5417 	}
5418 	position += 2;
5419 	bCodeStream[classFileOffset++] = (byte) (value >> 8);
5420 	bCodeStream[classFileOffset++] = (byte) value;
5421 }
writeSignedShort(int pos, int value)5422 public final void writeSignedShort(int pos, int value) {
5423 	int currentOffset = startingClassFileOffset + pos;
5424 	if (currentOffset + 1 >= bCodeStream.length) {
5425 		resizeByteArray();
5426 	}
5427 	bCodeStream[currentOffset] = (byte) (value >> 8);
5428 	bCodeStream[currentOffset + 1] = (byte) value;
5429 }
writeSignedWord(int value)5430 public final void writeSignedWord(int value) {
5431 	// we keep the resize in here because it is used outside the code stream
5432 	if (classFileOffset + 3 >= bCodeStream.length) {
5433 		resizeByteArray();
5434 	}
5435 	position += 4;
5436 	bCodeStream[classFileOffset++] = (byte) ((value & 0xFF000000) >> 24);
5437 	bCodeStream[classFileOffset++] = (byte) ((value & 0xFF0000) >> 16);
5438 	bCodeStream[classFileOffset++] = (byte) ((value & 0xFF00) >> 8);
5439 	bCodeStream[classFileOffset++] = (byte) (value & 0xFF);
5440 }
writeSignedWord(int pos, int value)5441 public final void writeSignedWord(int pos, int value) {
5442 	int currentOffset = startingClassFileOffset + pos;
5443 	if (currentOffset + 4 >= bCodeStream.length) {
5444 		resizeByteArray();
5445 	}
5446 	bCodeStream[currentOffset++] = (byte) ((value & 0xFF000000) >> 24);
5447 	bCodeStream[currentOffset++] = (byte) ((value & 0xFF0000) >> 16);
5448 	bCodeStream[currentOffset++] = (byte) ((value & 0xFF00) >> 8);
5449 	bCodeStream[currentOffset++] = (byte) (value & 0xFF);
5450 }
5451 /**
5452  * Write a unsigned 16 bits value into the byte array
5453  * @param value the unsigned short
5454  */
writeUnsignedShort(int value)5455 protected final void writeUnsignedShort(int value) {
5456 	position += 2;
5457 	bCodeStream[classFileOffset++] = (byte) (value >>> 8);
5458 	bCodeStream[classFileOffset++] = (byte) value;
5459 }
5460 /*
5461  * Wide conditional branch compare, improved by swapping comparison opcode
5462  *   ifeq WideTarget
5463  * becomes
5464  *    ifne Intermediate
5465  *    gotow WideTarget
5466  *    Intermediate:
5467  */
generateWideRevertedConditionalBranch(byte revertedOpcode, Label wideTarget)5468 public void generateWideRevertedConditionalBranch(byte revertedOpcode, Label wideTarget) {
5469 		Label intermediate = new Label(this);
5470 		if (classFileOffset >= bCodeStream.length) {
5471 			resizeByteArray();
5472 		}
5473 		position++;
5474 		bCodeStream[classFileOffset++] = revertedOpcode;
5475 		intermediate.branch();
5476 		this.goto_w(wideTarget);
5477 		intermediate.place();
5478 }
5479 }
5480