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