From f6829621e6d552e65409c5bdc2d32a738f37a373 Mon Sep 17 00:00:00 2001 From: khartlage Date: Mon, 27 Jan 2003 17:47:49 +0000 Subject: [PATCH] Config editor through XML file --- net.sourceforge.phpeclipse/plugin.xml | 168 +- .../internal/compiler/codegen/CodeStream.java |11268 ++++++++-------- .../phpdt/internal/compiler/parser/Parser.java |14671 ++++++++++---------- .../phpeclipse/IPreferenceConstants.java | 133 +- .../src/net/sourceforge/phpeclipse/PHPCore.java | 10 +- .../phpeclipse/PHPEclipseBasePreferencePage.java | 208 + .../phpeclipse/PHPEclipsePreferencePage.java | 115 - .../phpeclipse/PHPLanguagePreferencePage.java | 76 + .../phpeclipse/PHPOutlinePreferencePage.java | 56 + .../phpeclipse/PHPSyntaxEditorPreferencePage.java | 464 + .../phpeclipse/PHPSyntaxPreferencePage.java | 64 - .../sourceforge/phpeclipse/PHPeclipsePlugin.java | 87 +- .../newPHPPreferencesMessages_DE.properties | 65 + .../newPHPPreferencesMessages_FR.properties | 65 + .../newPHPPreferencesMessages_en_GB.properties | 64 + .../phpeclipse/phpeditor/PHPSyntaxRdr.java | 276 + .../phpeclipse/phpeditor/PHPTextHover.java | 37 +- .../phpeclipse/phpeditor/PresentationAction.java | 56 +- .../phpeclipse/phpeditor/SyntaxError.java | 64 - .../phpeclipse/phpeditor/php/PHPCodeScanner.java | 220 +- .../phpeclipse/phpeditor/php/PHPConstant.java | 16 + .../phpeclipse/phpeditor/php/PHPElement.java | 33 + .../phpeclipse/phpeditor/php/PHPFunction.java | 20 + .../phpeditor/php/PHPFunctionDescription.java | 2388 ---- .../phpeclipse/phpeditor/php/PHPKeyword.java | 29 + .../phpeclipse/phpeditor/php/PHPType.java | 15 + .../sourceforge/phpeclipse/phpeditor/phpsyntax.xml | 2416 ++++ .../phpeditor/util/HTMLColorProvider.java | 2 +- .../phpeditor/util/PHPColorProvider.java | 73 +- .../phpeclipse/preferences/ColorEditor.java | 116 + .../preferences/OverlayPreferenceStore.java | 443 + .../preferences/PHPPreferencesMessages.java | 62 +- .../preferences/PHPProjectLibraryPage.java | 237 +- .../preferences/PHPProjectPropertyPage.java | 144 +- 34 files changed, 18046 insertions(+), 16115 deletions(-) create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java delete mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipsePreferencePage.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPLanguagePreferencePage.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPOutlinePreferencePage.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPSyntaxEditorPreferencePage.java delete mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPSyntaxPreferencePage.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_DE.properties create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_FR.properties create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_en_GB.properties create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSyntaxRdr.java delete mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/SyntaxError.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPConstant.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPElement.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPFunction.java delete mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPFunctionDescription.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPKeyword.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPType.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpsyntax.xml create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/ColorEditor.java create mode 100644 net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/OverlayPreferenceStore.java diff --git a/net.sourceforge.phpeclipse/plugin.xml b/net.sourceforge.phpeclipse/plugin.xml index 7783dea..5725887 100644 --- a/net.sourceforge.phpeclipse/plugin.xml +++ b/net.sourceforge.phpeclipse/plugin.xml @@ -2,7 +2,7 @@ @@ -92,23 +92,42 @@ Create a new PHP project. + + + + Create a Xaraya module. + + + + + id="net.sourceforge.phpeclipse..ProjectNatureImagePHP"> - - - - + --> - + id="net.sourceforge.phpeclipse.phpeditor.comment"> + id="net.sourceforge.phpeclipse.phpeditor.uncomment"> + id="net.sourceforge.phpeclipse.phpeditor.comment"> + id="net.sourceforge.phpeclipse.phpeditor.uncomment"> - + --> - - - - - - - - - - - - - - - - - - - - - - - - - - - + class="net.sourceforge.phpeclipse.PHPSyntaxEditorPreferencePage" + id="net.sourceforge.phpeclipse.preference.PHPSyntaxEditorPreferencePage"> - + + + + + @@ -552,30 +516,6 @@ - - - - - - - - - - - - Tracking Max Stack. + // -> Tracking Max Stack. - public int stackMax; // Use Ints to keep from using extra bc when adding - public int stackDepth; // Use Ints to keep from using extra bc when adding - public int maxLocals; - public static final int max = 100; // Maximum size of the code array - public static final int growFactor = 400; - public static final int LABELS_INCREMENT = 5; - public byte[] bCodeStream; - public int pcToSourceMapSize; - public int[] pcToSourceMap = new int[24]; - public int lastEntryPC; // last entry recorded - public int[] lineSeparatorPositions; - public int position; // So when first set can be incremented - public int classFileOffset; - public int startingClassFileOffset; // I need to keep the starting point inside the byte array - public ConstantPool constantPool; // The constant pool used to generate bytecodes that need to store information into the constant pool - public ClassFile classFile; // The current classfile it is associated to. - // local variable attributes output - public static final int LOCALS_INCREMENT = 10; - public LocalVariableBinding[] locals = new LocalVariableBinding[LOCALS_INCREMENT]; - static LocalVariableBinding[] noLocals = new LocalVariableBinding[LOCALS_INCREMENT]; - public LocalVariableBinding[] visibleLocals = new LocalVariableBinding[LOCALS_INCREMENT]; - static LocalVariableBinding[] noVisibleLocals = new LocalVariableBinding[LOCALS_INCREMENT]; - int visibleLocalsCount; - public AbstractMethodDeclaration methodDeclaration; - public ExceptionLabel[] exceptionHandlers = new ExceptionLabel[LABELS_INCREMENT]; - static ExceptionLabel[] noExceptionHandlers = new ExceptionLabel[LABELS_INCREMENT]; - public int exceptionHandlersNumber; - public static FieldBinding[] ImplicitThis = new FieldBinding[] {}; - public boolean generateLineNumberAttributes; - public boolean generateLocalVariableTableAttributes; - public boolean preserveUnusedLocals; - // store all the labels placed at the current position to be able to optimize - // a jump to the next bytecode. - public Label[] labels = new Label[LABELS_INCREMENT]; - static Label[] noLabels = new Label[LABELS_INCREMENT]; - public int countLabels; - public int allLocalsCounter; - public int maxFieldCount; - // to handle goto_w - public boolean wideMode = false; - public static final CompilationResult RESTART_IN_WIDE_MODE = new CompilationResult((char[])null, 0, 0, 0); - -public CodeStream(ClassFile classFile) { - generateLineNumberAttributes = (classFile.produceDebugAttributes & CompilerOptions.Lines) != 0; - generateLocalVariableTableAttributes = (classFile.produceDebugAttributes & CompilerOptions.Vars) != 0; - if (generateLineNumberAttributes) { - lineSeparatorPositions = classFile.referenceBinding.scope.referenceCompilationUnit().compilationResult.lineSeparatorPositions; - } -} -final public void aaload() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_aaload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_aaload); - } -} -final public void aastore() { - countLabels = 0; - stackDepth -= 3; - try { - position++; - bCodeStream[classFileOffset++] = OPC_aastore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_aastore); - } -} -final public void aconst_null() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_aconst_null; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_aconst_null); - } -} -public final void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) { - // Required to fix 1PR0XVS: LFRE:WINNT - Compiler: variable table for method appears incorrect - if (!generateLocalVariableTableAttributes) - return; -/* if (initStateIndex == lastInitStateIndexWhenAddingInits) - return; - lastInitStateIndexWhenAddingInits = initStateIndex; - if (lastInitStateIndexWhenRemovingInits != initStateIndex){ - lastInitStateIndexWhenRemovingInits = -2; // reinitialize remove index - // remove(1)-add(1)-remove(1) -> ignore second remove - // remove(1)-add(2)-remove(1) -> perform second remove - } - -*/ for (int i = 0; i < visibleLocalsCount; i++) { - LocalVariableBinding localBinding = visibleLocals[i]; - if (localBinding != null) { - // Check if the local is definitely assigned - if ((initStateIndex != -1) && isDefinitelyAssigned(scope, initStateIndex, localBinding)) { - if ((localBinding.initializationCount == 0) || (localBinding.initializationPCs[((localBinding.initializationCount - 1) << 1) + 1] != -1)) { - /* There are two cases: - * 1) there is no initialization interval opened ==> add an opened interval - * 2) there is already some initialization intervals but the last one is closed ==> add an opened interval - * An opened interval means that the value at localBinding.initializationPCs[localBinding.initializationCount - 1][1] - * is equals to -1. - * initializationPCs is a collection of pairs of int: - * first value is the startPC and second value is the endPC. -1 one for the last value means that the interval - * is not closed yet. - */ - localBinding.recordInitializationStartPC(position); - } - } - } - } -} -public void addLabel(Label aLabel) { - if (countLabels == labels.length) - System.arraycopy(labels, 0, (labels = new Label[countLabels + LABELS_INCREMENT]), 0, countLabels); - labels[countLabels++] = aLabel; -} -public void addVisibleLocalVariable(LocalVariableBinding localBinding) { - if (!generateLocalVariableTableAttributes) - return; + public int stackMax; // Use Ints to keep from using extra bc when adding + public int stackDepth; // Use Ints to keep from using extra bc when adding + public int maxLocals; + public static final int max = 100; // Maximum size of the code array + public static final int growFactor = 400; + public static final int LABELS_INCREMENT = 5; + public byte[] bCodeStream; + public int pcToSourceMapSize; + public int[] pcToSourceMap = new int[24]; + public int lastEntryPC; // last entry recorded + public int[] lineSeparatorPositions; + public int position; // So when first set can be incremented + public int classFileOffset; + public int startingClassFileOffset; // I need to keep the starting point inside the byte array + public ConstantPool constantPool; + // The constant pool used to generate bytecodes that need to store information into the constant pool + public ClassFile classFile; // The current classfile it is associated to. + // local variable attributes output + public static final int LOCALS_INCREMENT = 10; + public LocalVariableBinding[] locals = new LocalVariableBinding[LOCALS_INCREMENT]; + static LocalVariableBinding[] noLocals = new LocalVariableBinding[LOCALS_INCREMENT]; + public LocalVariableBinding[] visibleLocals = new LocalVariableBinding[LOCALS_INCREMENT]; + static LocalVariableBinding[] noVisibleLocals = new LocalVariableBinding[LOCALS_INCREMENT]; + int visibleLocalsCount; + public AbstractMethodDeclaration methodDeclaration; + public ExceptionLabel[] exceptionHandlers = new ExceptionLabel[LABELS_INCREMENT]; + static ExceptionLabel[] noExceptionHandlers = new ExceptionLabel[LABELS_INCREMENT]; + public int exceptionHandlersNumber; + public static FieldBinding[] ImplicitThis = new FieldBinding[] { + }; + public boolean generateLineNumberAttributes; + public boolean generateLocalVariableTableAttributes; + public boolean preserveUnusedLocals; + // store all the labels placed at the current position to be able to optimize + // a jump to the next bytecode. + public Label[] labels = new Label[LABELS_INCREMENT]; + static Label[] noLabels = new Label[LABELS_INCREMENT]; + public int countLabels; + public int allLocalsCounter; + public int maxFieldCount; + // to handle goto_w + public boolean wideMode = false; + public static final CompilationResult RESTART_IN_WIDE_MODE = new CompilationResult((char[]) null, 0, 0, 0); - if (visibleLocalsCount >= visibleLocals.length) { - System.arraycopy(visibleLocals, 0, (visibleLocals = new LocalVariableBinding[visibleLocalsCount * 2]), 0, visibleLocalsCount); - } - visibleLocals[visibleLocalsCount++] = localBinding; -} -final public void aload(int iArg) { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (maxLocals <= iArg) { - maxLocals = iArg + 1; - } - if (iArg > 255) { // Widen - try { - position++; - bCodeStream[classFileOffset++] = OPC_wide; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_wide); - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_aload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_aload); - } - writeUnsignedShort(iArg); - } else { - // Don't need to use the wide bytecode - try { - position++; - bCodeStream[classFileOffset++] = OPC_aload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_aload); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) (iArg); - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) iArg); - } - } -} -final public void aload_0() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (maxLocals == 0) { - maxLocals = 1; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_aload_0; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_aload_0); - } -} -final public void aload_1() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (maxLocals <= 1) { - maxLocals = 2; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_aload_1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_aload_1); - } -} -final public void aload_2() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (maxLocals <= 2) { - maxLocals = 3; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_aload_2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_aload_2); - } -} -final public void aload_3() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (maxLocals <= 3) { - maxLocals = 4; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_aload_3; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_aload_3); - } -} -public final void anewarray(TypeBinding typeBinding) { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_anewarray; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_anewarray); - } - writeUnsignedShort(constantPool.literalIndex(typeBinding)); -} -public void anewarrayJavaLangClass() { - // anewarray: java.lang.Class - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_anewarray; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_anewarray); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangClass()); -} -public void anewarrayJavaLangObject() { - // anewarray: java.lang.Object - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_anewarray; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_anewarray); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangObject()); -} -final public void areturn() { - countLabels = 0; - stackDepth--; - // the stackDepth should be equal to 0 - try { - position++; - bCodeStream[classFileOffset++] = OPC_areturn; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_areturn); - } -} -public void arrayAt(int typeBindingID) { - switch (typeBindingID) { - case T_int : - this.iaload(); - break; - case T_byte : - case T_boolean : - this.baload(); - break; - case T_short : - this.saload(); - break; - case T_char : - this.caload(); - break; - case T_long : - this.laload(); - break; - case T_float : - this.faload(); - break; - case T_double : - this.daload(); - break; - default : - this.aaload(); - } -} -public void arrayAtPut(int elementTypeID, boolean valueRequired) { - switch (elementTypeID) { - case T_int : - if (valueRequired) - dup_x2(); - iastore(); - break; - case T_byte : - case T_boolean : - if (valueRequired) - dup_x2(); - bastore(); - break; - case T_short : - if (valueRequired) - dup_x2(); - sastore(); - break; - case T_char : - if (valueRequired) - dup_x2(); - castore(); - break; - case T_long : - if (valueRequired) - dup2_x2(); - lastore(); - break; - case T_float : - if (valueRequired) - dup_x2(); - fastore(); - break; - case T_double : - if (valueRequired) - dup2_x2(); - dastore(); - break; - default : - if (valueRequired) - dup_x2(); - aastore(); - } -} -final public void arraylength() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_arraylength; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_arraylength); - } -} -final public void astore(int iArg) { - countLabels = 0; - stackDepth--; - if (maxLocals <= iArg) { - maxLocals = iArg + 1; - } - if (iArg > 255) { // Widen - try { - position++; - bCodeStream[classFileOffset++] = OPC_wide; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_wide); - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_astore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_astore); - } - writeUnsignedShort(iArg); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_astore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_astore); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) iArg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) iArg); - } - } -} -final public void astore_0() { - countLabels = 0; - stackDepth--; - if (maxLocals == 0) { - maxLocals = 1; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_astore_0; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_astore_0); - } -} -final public void astore_1() { - countLabels = 0; - stackDepth--; - if (maxLocals <= 1) { - maxLocals = 2; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_astore_1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_astore_1); - } -} -final public void astore_2() { - countLabels = 0; - stackDepth--; - if (maxLocals <= 2) { - maxLocals = 3; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_astore_2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_astore_2); - } -} -final public void astore_3() { - countLabels = 0; - stackDepth--; - if (maxLocals <= 3) { - maxLocals = 4; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_astore_3; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_astore_3); - } -} -final public void athrow() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_athrow; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_athrow); - } -} -final public void baload() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_baload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_baload); - } -} -final public void bastore() { - countLabels = 0; - stackDepth -= 3; - try { - position++; - bCodeStream[classFileOffset++] = OPC_bastore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_bastore); - } -} -final public void bipush(byte b) { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_bipush; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_bipush); - } - writeSignedByte(b); -} -final public void caload() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_caload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_caload); - } -} -final public void castore() { - countLabels = 0; - stackDepth -= 3; - try { - position++; - bCodeStream[classFileOffset++] = OPC_castore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_castore); - } -} -public final void checkcast(TypeBinding typeBinding) { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_checkcast; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_checkcast); - } - writeUnsignedShort(constantPool.literalIndex(typeBinding)); -} -public final void checkcastJavaLangError() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_checkcast; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_checkcast); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangError()); -} -final public void d2f() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_d2f; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_d2f); - } -} -final public void d2i() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_d2i; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_d2i); - } -} -final public void d2l() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_d2l; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_d2l); - } -} -final public void dadd() { - countLabels = 0; - stackDepth -= 2; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dadd; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dadd); - } -} -final public void daload() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_daload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_daload); - } -} -final public void dastore() { - countLabels = 0; - stackDepth -= 4; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dastore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dastore); - } -} -final public void dcmpg() { - countLabels = 0; - stackDepth -= 3; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dcmpg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dcmpg); - } -} -final public void dcmpl() { - countLabels = 0; - stackDepth -= 3; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dcmpl; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dcmpl); - } -} -final public void dconst_0() { - countLabels = 0; - stackDepth += 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dconst_0; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dconst_0); - } -} -final public void dconst_1() { - countLabels = 0; - stackDepth += 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dconst_1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dconst_1); - } -} -final public void ddiv() { - countLabels = 0; - stackDepth -= 2; - try { - position++; - bCodeStream[classFileOffset++] = OPC_ddiv; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ddiv); - } -} -public void decrStackSize(int offset) { - stackDepth -= offset; -} -final public void dload(int iArg) { - countLabels = 0; - stackDepth += 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (maxLocals < iArg + 2) { - maxLocals = iArg + 2; // + 2 because it is a double - } - if (iArg > 255) { // Widen - try { - position++; - bCodeStream[classFileOffset++] = OPC_wide; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_wide); - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_dload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dload); - } - writeUnsignedShort(iArg); - } else { - // Don't need to use the wide bytecode - try { - position++; - bCodeStream[classFileOffset++] = OPC_dload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dload); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) iArg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) iArg); - } - } -} -final public void dload_0() { - countLabels = 0; - stackDepth += 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (maxLocals < 2) { - maxLocals = 2; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_dload_0; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dload_0); - } -} -final public void dload_1() { - countLabels = 0; - stackDepth += 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (maxLocals < 3) { - maxLocals = 3; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_dload_1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dload_1); - } -} -final public void dload_2() { - countLabels = 0; - stackDepth += 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (maxLocals < 4) { - maxLocals = 4; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_dload_2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dload_2); - } -} -final public void dload_3() { - countLabels = 0; - stackDepth += 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (maxLocals < 5) { - maxLocals = 5; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_dload_3; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dload_3); - } -} -final public void dmul() { - countLabels = 0; - stackDepth -= 2; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dmul; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dmul); - } -} -final public void dneg() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dneg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dneg); - } -} -final public void drem() { - countLabels = 0; - stackDepth -= 2; - try { - position++; - bCodeStream[classFileOffset++] = OPC_drem; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_drem); - } -} -final public void dreturn() { - countLabels = 0; - stackDepth -= 2; - // the stackDepth should be equal to 0 - try { - position++; - bCodeStream[classFileOffset++] = OPC_dreturn; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dreturn); - } -} -final public void dstore(int iArg) { - countLabels = 0; - stackDepth -= 2; - if (maxLocals <= iArg + 1) { - maxLocals = iArg + 2; - } - if (iArg > 255) { // Widen - try { - position++; - bCodeStream[classFileOffset++] = OPC_wide; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_wide); - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_dstore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dstore); - } - writeUnsignedShort(iArg); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_dstore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dstore); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) iArg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) iArg); - } - } -} -final public void dstore_0() { - countLabels = 0; - stackDepth -= 2; - if (maxLocals < 2) { - maxLocals = 2; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_dstore_0; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dstore_0); - } -} -final public void dstore_1() { - countLabels = 0; - stackDepth -= 2; - if (maxLocals < 3) { - maxLocals = 3; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_dstore_1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dstore_1); - } -} -final public void dstore_2() { - countLabels = 0; - stackDepth -= 2; - if (maxLocals < 4) { - maxLocals = 4; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_dstore_2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dstore_2); - } -} -final public void dstore_3() { - countLabels = 0; - stackDepth -= 2; - if (maxLocals < 5) { - maxLocals = 5; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_dstore_3; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dstore_3); - } -} -final public void dsub() { - countLabels = 0; - stackDepth -= 2; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dsub; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dsub); - } -} -final public void dup() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dup; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dup); - } -} -final public void dup_x1() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dup_x1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dup_x1); - } -} -final public void dup_x2() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dup_x2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dup_x2); - } -} -final public void dup2() { - countLabels = 0; - stackDepth += 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dup2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dup2); - } -} -final public void dup2_x1() { - countLabels = 0; - stackDepth += 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dup2_x1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dup2_x1); - } -} -final public void dup2_x2() { - countLabels = 0; - stackDepth += 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_dup2_x2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_dup2_x2); - } -} -public void exitUserScope(BlockScope blockScope) { - // mark all the scope's locals as loosing their definite assignment + public CodeStream(ClassFile classFile) { + generateLineNumberAttributes = (classFile.produceDebugAttributes & CompilerOptions.Lines) != 0; + generateLocalVariableTableAttributes = (classFile.produceDebugAttributes & CompilerOptions.Vars) != 0; + if (generateLineNumberAttributes) { + lineSeparatorPositions = classFile.referenceBinding.scope.referenceCompilationUnit().compilationResult.lineSeparatorPositions; + } + } + final public void aaload() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_aaload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_aaload); + } + } + final public void aastore() { + countLabels = 0; + stackDepth -= 3; + try { + position++; + bCodeStream[classFileOffset++] = OPC_aastore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_aastore); + } + } + final public void aconst_null() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_aconst_null; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_aconst_null); + } + } + public final void addDefinitelyAssignedVariables(Scope scope, int initStateIndex) { + // Required to fix 1PR0XVS: LFRE:WINNT - Compiler: variable table for method appears incorrect + if (!generateLocalVariableTableAttributes) + return; + /* if (initStateIndex == lastInitStateIndexWhenAddingInits) + return; + lastInitStateIndexWhenAddingInits = initStateIndex; + if (lastInitStateIndexWhenRemovingInits != initStateIndex){ + lastInitStateIndexWhenRemovingInits = -2; // reinitialize remove index + // remove(1)-add(1)-remove(1) -> ignore second remove + // remove(1)-add(2)-remove(1) -> perform second remove + } + + */ + for (int i = 0; i < visibleLocalsCount; i++) { + LocalVariableBinding localBinding = visibleLocals[i]; + if (localBinding != null) { + // Check if the local is definitely assigned + if ((initStateIndex != -1) && isDefinitelyAssigned(scope, initStateIndex, localBinding)) { + if ((localBinding.initializationCount == 0) + || (localBinding.initializationPCs[((localBinding.initializationCount - 1) << 1) + 1] != -1)) { + /* There are two cases: + * 1) there is no initialization interval opened ==> add an opened interval + * 2) there is already some initialization intervals but the last one is closed ==> add an opened interval + * An opened interval means that the value at localBinding.initializationPCs[localBinding.initializationCount - 1][1] + * is equals to -1. + * initializationPCs is a collection of pairs of int: + * first value is the startPC and second value is the endPC. -1 one for the last value means that the interval + * is not closed yet. + */ + localBinding.recordInitializationStartPC(position); + } + } + } + } + } + public void addLabel(Label aLabel) { + if (countLabels == labels.length) + System.arraycopy(labels, 0, (labels = new Label[countLabels + LABELS_INCREMENT]), 0, countLabels); + labels[countLabels++] = aLabel; + } + public void addVisibleLocalVariable(LocalVariableBinding localBinding) { + if (!generateLocalVariableTableAttributes) + return; - if (!generateLocalVariableTableAttributes) - return; - for (int i = 0; i < visibleLocalsCount; i++) { - LocalVariableBinding visibleLocal = visibleLocals[i]; - if ((visibleLocal != null) && (visibleLocal.declaringScope == blockScope)) { - // there maybe some some preserved locals never initialized - if (visibleLocal.initializationCount > 0){ - visibleLocals[i].recordInitializationEndPC(position); - } - visibleLocals[i] = null; // this variable is no longer visible afterwards - } - } -} -final public void f2d() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_f2d; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_f2d); - } -} -final public void f2i() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_f2i; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_f2i); - } -} -final public void f2l() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_f2l; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_f2l); - } -} -final public void fadd() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fadd; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fadd); - } -} -final public void faload() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_faload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_faload); - } -} -final public void fastore() { - countLabels = 0; - stackDepth -= 3; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fastore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fastore); - } -} -final public void fcmpg() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fcmpg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fcmpg); - } -} -final public void fcmpl() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fcmpl; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fcmpl); - } -} -final public void fconst_0() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fconst_0; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fconst_0); - } -} -final public void fconst_1() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fconst_1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fconst_1); - } -} -final public void fconst_2() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fconst_2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fconst_2); - } -} -final public void fdiv() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fdiv; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fdiv); - } -} -final public void fload(int iArg) { - countLabels = 0; - stackDepth++; - if (maxLocals <= iArg) { - maxLocals = iArg + 1; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - if (iArg > 255) { // Widen - try { - position++; - bCodeStream[classFileOffset++] = OPC_wide; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_wide); - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_fload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fload); - } - writeUnsignedShort(iArg); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_fload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fload); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) iArg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) iArg); - } - } -} -final public void fload_0() { - countLabels = 0; - stackDepth++; - if (maxLocals == 0) { - maxLocals = 1; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fload_0; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fload_0); - } -} -final public void fload_1() { - countLabels = 0; - stackDepth++; - if (maxLocals <= 1) { - maxLocals = 2; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fload_1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fload_1); - } -} -final public void fload_2() { - countLabels = 0; - stackDepth++; - if (maxLocals <= 2) { - maxLocals = 3; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fload_2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fload_2); - } -} -final public void fload_3() { - countLabels = 0; - stackDepth++; - if (maxLocals <= 3) { - maxLocals = 4; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fload_3; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fload_3); - } -} -final public void fmul() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fmul; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fmul); - } -} -final public void fneg() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fneg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fneg); - } -} -final public void frem() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_frem; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_frem); - } -} -final public void freturn() { - countLabels = 0; - stackDepth--; - // the stackDepth should be equal to 0 - try { - position++; - bCodeStream[classFileOffset++] = OPC_freturn; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_freturn); - } -} -final public void fstore(int iArg) { - countLabels = 0; - stackDepth--; - if (maxLocals <= iArg) { - maxLocals = iArg + 1; - } - if (iArg > 255) { // Widen - try { - position++; - bCodeStream[classFileOffset++] = OPC_wide; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_wide); - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_fstore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fstore); - } - writeUnsignedShort(iArg); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_fstore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fstore); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) iArg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) iArg); - } - } -} -final public void fstore_0() { - countLabels = 0; - stackDepth--; - if (maxLocals == 0) { - maxLocals = 1; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_fstore_0; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fstore_0); - } -} -final public void fstore_1() { - countLabels = 0; - stackDepth--; - if (maxLocals <= 1) { - maxLocals = 2; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_fstore_1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fstore_1); - } -} -final public void fstore_2() { - countLabels = 0; - stackDepth--; - if (maxLocals <= 2) { - maxLocals = 3; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_fstore_2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fstore_2); - } -} -final public void fstore_3() { - countLabels = 0; - stackDepth--; - if (maxLocals <= 3) { - maxLocals = 4; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_fstore_3; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fstore_3); - } -} -final public void fsub() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_fsub; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_fsub); - } -} -/** - * Macro for building a class descriptor object - */ -public void generateClassLiteralAccessForType(TypeBinding accessedType, FieldBinding syntheticFieldBinding) { - Label endLabel; - ExceptionLabel anyExceptionHandler; - int saveStackSize; - if (accessedType.isBaseType() && accessedType != NullBinding) { - this.getTYPE(accessedType.id); - return; - } - endLabel = new Label(this); + if (visibleLocalsCount >= visibleLocals.length) { + System.arraycopy(visibleLocals, 0, (visibleLocals = new LocalVariableBinding[visibleLocalsCount * 2]), 0, visibleLocalsCount); + } + visibleLocals[visibleLocalsCount++] = localBinding; + } + final public void aload(int iArg) { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (maxLocals <= iArg) { + maxLocals = iArg + 1; + } + if (iArg > 255) { // Widen + try { + position++; + bCodeStream[classFileOffset++] = OPC_wide; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_wide); + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_aload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_aload); + } + writeUnsignedShort(iArg); + } else { + // Don't need to use the wide bytecode + try { + position++; + bCodeStream[classFileOffset++] = OPC_aload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_aload); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) (iArg); + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) iArg); + } + } + } + final public void aload_0() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (maxLocals == 0) { + maxLocals = 1; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_aload_0; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_aload_0); + } + } + final public void aload_1() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (maxLocals <= 1) { + maxLocals = 2; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_aload_1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_aload_1); + } + } + final public void aload_2() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (maxLocals <= 2) { + maxLocals = 3; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_aload_2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_aload_2); + } + } + final public void aload_3() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (maxLocals <= 3) { + maxLocals = 4; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_aload_3; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_aload_3); + } + } + public final void anewarray(TypeBinding typeBinding) { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_anewarray; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_anewarray); + } + writeUnsignedShort(constantPool.literalIndex(typeBinding)); + } + public void anewarrayJavaLangClass() { + // anewarray: java.lang.Class + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_anewarray; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_anewarray); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangClass()); + } + public void anewarrayJavaLangObject() { + // anewarray: java.lang.Object + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_anewarray; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_anewarray); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangObject()); + } + final public void areturn() { + countLabels = 0; + stackDepth--; + // the stackDepth should be equal to 0 + try { + position++; + bCodeStream[classFileOffset++] = OPC_areturn; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_areturn); + } + } + public void arrayAt(int typeBindingID) { + switch (typeBindingID) { + case T_int : + this.iaload(); + break; + case T_byte : + case T_boolean : + this.baload(); + break; + case T_short : + this.saload(); + break; + case T_char : + this.caload(); + break; + case T_long : + this.laload(); + break; + case T_float : + this.faload(); + break; + case T_double : + this.daload(); + break; + default : + this.aaload(); + } + } + public void arrayAtPut(int elementTypeID, boolean valueRequired) { + switch (elementTypeID) { + case T_int : + if (valueRequired) + dup_x2(); + iastore(); + break; + case T_byte : + case T_boolean : + if (valueRequired) + dup_x2(); + bastore(); + break; + case T_short : + if (valueRequired) + dup_x2(); + sastore(); + break; + case T_char : + if (valueRequired) + dup_x2(); + castore(); + break; + case T_long : + if (valueRequired) + dup2_x2(); + lastore(); + break; + case T_float : + if (valueRequired) + dup_x2(); + fastore(); + break; + case T_double : + if (valueRequired) + dup2_x2(); + dastore(); + break; + default : + if (valueRequired) + dup_x2(); + aastore(); + } + } + final public void arraylength() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_arraylength; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_arraylength); + } + } + final public void astore(int iArg) { + countLabels = 0; + stackDepth--; + if (maxLocals <= iArg) { + maxLocals = iArg + 1; + } + if (iArg > 255) { // Widen + try { + position++; + bCodeStream[classFileOffset++] = OPC_wide; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_wide); + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_astore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_astore); + } + writeUnsignedShort(iArg); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_astore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_astore); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) iArg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) iArg); + } + } + } + final public void astore_0() { + countLabels = 0; + stackDepth--; + if (maxLocals == 0) { + maxLocals = 1; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_astore_0; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_astore_0); + } + } + final public void astore_1() { + countLabels = 0; + stackDepth--; + if (maxLocals <= 1) { + maxLocals = 2; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_astore_1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_astore_1); + } + } + final public void astore_2() { + countLabels = 0; + stackDepth--; + if (maxLocals <= 2) { + maxLocals = 3; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_astore_2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_astore_2); + } + } + final public void astore_3() { + countLabels = 0; + stackDepth--; + if (maxLocals <= 3) { + maxLocals = 4; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_astore_3; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_astore_3); + } + } + final public void athrow() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_athrow; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_athrow); + } + } + final public void baload() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_baload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_baload); + } + } + final public void bastore() { + countLabels = 0; + stackDepth -= 3; + try { + position++; + bCodeStream[classFileOffset++] = OPC_bastore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_bastore); + } + } + final public void bipush(byte b) { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_bipush; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_bipush); + } + writeSignedByte(b); + } + final public void caload() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_caload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_caload); + } + } + final public void castore() { + countLabels = 0; + stackDepth -= 3; + try { + position++; + bCodeStream[classFileOffset++] = OPC_castore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_castore); + } + } + public final void checkcast(TypeBinding typeBinding) { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_checkcast; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_checkcast); + } + writeUnsignedShort(constantPool.literalIndex(typeBinding)); + } + public final void checkcastJavaLangError() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_checkcast; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_checkcast); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangError()); + } + final public void d2f() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_d2f; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_d2f); + } + } + final public void d2i() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_d2i; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_d2i); + } + } + final public void d2l() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_d2l; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_d2l); + } + } + final public void dadd() { + countLabels = 0; + stackDepth -= 2; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dadd; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dadd); + } + } + final public void daload() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_daload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_daload); + } + } + final public void dastore() { + countLabels = 0; + stackDepth -= 4; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dastore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dastore); + } + } + final public void dcmpg() { + countLabels = 0; + stackDepth -= 3; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dcmpg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dcmpg); + } + } + final public void dcmpl() { + countLabels = 0; + stackDepth -= 3; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dcmpl; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dcmpl); + } + } + final public void dconst_0() { + countLabels = 0; + stackDepth += 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dconst_0; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dconst_0); + } + } + final public void dconst_1() { + countLabels = 0; + stackDepth += 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dconst_1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dconst_1); + } + } + final public void ddiv() { + countLabels = 0; + stackDepth -= 2; + try { + position++; + bCodeStream[classFileOffset++] = OPC_ddiv; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ddiv); + } + } + public void decrStackSize(int offset) { + stackDepth -= offset; + } + final public void dload(int iArg) { + countLabels = 0; + stackDepth += 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (maxLocals < iArg + 2) { + maxLocals = iArg + 2; // + 2 because it is a double + } + if (iArg > 255) { // Widen + try { + position++; + bCodeStream[classFileOffset++] = OPC_wide; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_wide); + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_dload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dload); + } + writeUnsignedShort(iArg); + } else { + // Don't need to use the wide bytecode + try { + position++; + bCodeStream[classFileOffset++] = OPC_dload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dload); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) iArg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) iArg); + } + } + } + final public void dload_0() { + countLabels = 0; + stackDepth += 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (maxLocals < 2) { + maxLocals = 2; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_dload_0; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dload_0); + } + } + final public void dload_1() { + countLabels = 0; + stackDepth += 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (maxLocals < 3) { + maxLocals = 3; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_dload_1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dload_1); + } + } + final public void dload_2() { + countLabels = 0; + stackDepth += 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (maxLocals < 4) { + maxLocals = 4; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_dload_2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dload_2); + } + } + final public void dload_3() { + countLabels = 0; + stackDepth += 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (maxLocals < 5) { + maxLocals = 5; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_dload_3; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dload_3); + } + } + final public void dmul() { + countLabels = 0; + stackDepth -= 2; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dmul; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dmul); + } + } + final public void dneg() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dneg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dneg); + } + } + final public void drem() { + countLabels = 0; + stackDepth -= 2; + try { + position++; + bCodeStream[classFileOffset++] = OPC_drem; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_drem); + } + } + final public void dreturn() { + countLabels = 0; + stackDepth -= 2; + // the stackDepth should be equal to 0 + try { + position++; + bCodeStream[classFileOffset++] = OPC_dreturn; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dreturn); + } + } + final public void dstore(int iArg) { + countLabels = 0; + stackDepth -= 2; + if (maxLocals <= iArg + 1) { + maxLocals = iArg + 2; + } + if (iArg > 255) { // Widen + try { + position++; + bCodeStream[classFileOffset++] = OPC_wide; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_wide); + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_dstore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dstore); + } + writeUnsignedShort(iArg); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_dstore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dstore); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) iArg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) iArg); + } + } + } + final public void dstore_0() { + countLabels = 0; + stackDepth -= 2; + if (maxLocals < 2) { + maxLocals = 2; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_dstore_0; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dstore_0); + } + } + final public void dstore_1() { + countLabels = 0; + stackDepth -= 2; + if (maxLocals < 3) { + maxLocals = 3; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_dstore_1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dstore_1); + } + } + final public void dstore_2() { + countLabels = 0; + stackDepth -= 2; + if (maxLocals < 4) { + maxLocals = 4; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_dstore_2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dstore_2); + } + } + final public void dstore_3() { + countLabels = 0; + stackDepth -= 2; + if (maxLocals < 5) { + maxLocals = 5; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_dstore_3; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dstore_3); + } + } + final public void dsub() { + countLabels = 0; + stackDepth -= 2; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dsub; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dsub); + } + } + final public void dup() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dup; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dup); + } + } + final public void dup_x1() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dup_x1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dup_x1); + } + } + final public void dup_x2() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dup_x2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dup_x2); + } + } + final public void dup2() { + countLabels = 0; + stackDepth += 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dup2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dup2); + } + } + final public void dup2_x1() { + countLabels = 0; + stackDepth += 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dup2_x1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dup2_x1); + } + } + final public void dup2_x2() { + countLabels = 0; + stackDepth += 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_dup2_x2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_dup2_x2); + } + } + public void exitUserScope(BlockScope blockScope) { + // mark all the scope's locals as loosing their definite assignment - if (syntheticFieldBinding != null) { // non interface case - this.getstatic(syntheticFieldBinding); - this.dup(); - this.ifnonnull(endLabel); - this.pop(); - } + if (!generateLocalVariableTableAttributes) + return; + for (int i = 0; i < visibleLocalsCount; i++) { + LocalVariableBinding visibleLocal = visibleLocals[i]; + if ((visibleLocal != null) && (visibleLocal.declaringScope == blockScope)) { + // there maybe some some preserved locals never initialized + if (visibleLocal.initializationCount > 0) { + visibleLocals[i].recordInitializationEndPC(position); + } + visibleLocals[i] = null; // this variable is no longer visible afterwards + } + } + } + final public void f2d() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_f2d; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_f2d); + } + } + final public void f2i() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_f2i; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_f2i); + } + } + final public void f2l() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_f2l; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_f2l); + } + } + final public void fadd() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fadd; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fadd); + } + } + final public void faload() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_faload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_faload); + } + } + final public void fastore() { + countLabels = 0; + stackDepth -= 3; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fastore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fastore); + } + } + final public void fcmpg() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fcmpg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fcmpg); + } + } + final public void fcmpl() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fcmpl; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fcmpl); + } + } + final public void fconst_0() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fconst_0; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fconst_0); + } + } + final public void fconst_1() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fconst_1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fconst_1); + } + } + final public void fconst_2() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fconst_2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fconst_2); + } + } + final public void fdiv() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fdiv; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fdiv); + } + } + final public void fload(int iArg) { + countLabels = 0; + stackDepth++; + if (maxLocals <= iArg) { + maxLocals = iArg + 1; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + if (iArg > 255) { // Widen + try { + position++; + bCodeStream[classFileOffset++] = OPC_wide; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_wide); + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_fload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fload); + } + writeUnsignedShort(iArg); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_fload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fload); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) iArg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) iArg); + } + } + } + final public void fload_0() { + countLabels = 0; + stackDepth++; + if (maxLocals == 0) { + maxLocals = 1; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fload_0; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fload_0); + } + } + final public void fload_1() { + countLabels = 0; + stackDepth++; + if (maxLocals <= 1) { + maxLocals = 2; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fload_1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fload_1); + } + } + final public void fload_2() { + countLabels = 0; + stackDepth++; + if (maxLocals <= 2) { + maxLocals = 3; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fload_2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fload_2); + } + } + final public void fload_3() { + countLabels = 0; + stackDepth++; + if (maxLocals <= 3) { + maxLocals = 4; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fload_3; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fload_3); + } + } + final public void fmul() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fmul; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fmul); + } + } + final public void fneg() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fneg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fneg); + } + } + final public void frem() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_frem; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_frem); + } + } + final public void freturn() { + countLabels = 0; + stackDepth--; + // the stackDepth should be equal to 0 + try { + position++; + bCodeStream[classFileOffset++] = OPC_freturn; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_freturn); + } + } + final public void fstore(int iArg) { + countLabels = 0; + stackDepth--; + if (maxLocals <= iArg) { + maxLocals = iArg + 1; + } + if (iArg > 255) { // Widen + try { + position++; + bCodeStream[classFileOffset++] = OPC_wide; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_wide); + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_fstore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fstore); + } + writeUnsignedShort(iArg); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_fstore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fstore); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) iArg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) iArg); + } + } + } + final public void fstore_0() { + countLabels = 0; + stackDepth--; + if (maxLocals == 0) { + maxLocals = 1; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_fstore_0; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fstore_0); + } + } + final public void fstore_1() { + countLabels = 0; + stackDepth--; + if (maxLocals <= 1) { + maxLocals = 2; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_fstore_1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fstore_1); + } + } + final public void fstore_2() { + countLabels = 0; + stackDepth--; + if (maxLocals <= 2) { + maxLocals = 3; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_fstore_2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fstore_2); + } + } + final public void fstore_3() { + countLabels = 0; + stackDepth--; + if (maxLocals <= 3) { + maxLocals = 4; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_fstore_3; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fstore_3); + } + } + final public void fsub() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_fsub; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_fsub); + } + } + /** + * Macro for building a class descriptor object + */ + public void generateClassLiteralAccessForType(TypeBinding accessedType, FieldBinding syntheticFieldBinding) { + Label endLabel; + ExceptionLabel anyExceptionHandler; + int saveStackSize; + if (accessedType.isBaseType() && accessedType != NullBinding) { + this.getTYPE(accessedType.id); + return; + } + endLabel = new Label(this); - /* Macro for building a class descriptor object... using or not a field cache to store it into... - this sequence is responsible for building the actual class descriptor. - - If the fieldCache is set, then it is supposed to be the body of a synthetic access method - factoring the actual descriptor creation out of the invocation site (saving space). - If the fieldCache is nil, then we are dumping the bytecode on the invocation site, since - we have no way to get a hand on the field cache to do better. */ + if (syntheticFieldBinding != null) { // non interface case + this.getstatic(syntheticFieldBinding); + this.dup(); + this.ifnonnull(endLabel); + this.pop(); + } + /* Macro for building a class descriptor object... using or not a field cache to store it into... + this sequence is responsible for building the actual class descriptor. + + If the fieldCache is set, then it is supposed to be the body of a synthetic access method + factoring the actual descriptor creation out of the invocation site (saving space). + If the fieldCache is nil, then we are dumping the bytecode on the invocation site, since + we have no way to get a hand on the field cache to do better. */ - // Wrap the code in an exception handler to convert a ClassNotFoundException into a NoClassDefError + // Wrap the code in an exception handler to convert a ClassNotFoundException into a NoClassDefError - anyExceptionHandler = new ExceptionLabel(this, TypeBinding.NullBinding /* represents ClassNotFoundException*/); - this.ldc(accessedType == TypeBinding.NullBinding ? "java.lang.Object" : String.valueOf(accessedType.constantPoolName()).replace('/', '.')); //$NON-NLS-1$ - this.invokeClassForName(); + anyExceptionHandler = new ExceptionLabel(this, TypeBinding.NullBinding /* represents ClassNotFoundException*/ + ); + this.ldc(accessedType == TypeBinding.NullBinding ? "java.lang.Object" : String.valueOf(accessedType.constantPoolName()).replace('/', '.')); //$NON-NLS-1$ + this.invokeClassForName(); - /* We need to protect the runtime code from binary inconsistencies - in case the accessedType is missing, the ClassNotFoundException has to be converted - into a NoClassDefError(old ex message), we thus need to build an exception handler for this one. */ - anyExceptionHandler.placeEnd(); + /* We need to protect the runtime code from binary inconsistencies + in case the accessedType is missing, the ClassNotFoundException has to be converted + into a NoClassDefError(old ex message), we thus need to build an exception handler for this one. */ + anyExceptionHandler.placeEnd(); - if (syntheticFieldBinding != null) { // non interface case - this.dup(); - this.putstatic(syntheticFieldBinding); - } - this.goto_(endLabel); + if (syntheticFieldBinding != null) { // non interface case + this.dup(); + this.putstatic(syntheticFieldBinding); + } + this.goto_(endLabel); + // Generate the body of the exception handler + saveStackSize = stackDepth; + stackDepth = 1; + /* ClassNotFoundException on stack -- the class literal could be doing more things + on the stack, which means that the stack may not be empty at this point in the + above code gen. So we save its state and restart it from 1. */ - // Generate the body of the exception handler - saveStackSize = stackDepth; - stackDepth = 1; - /* ClassNotFoundException on stack -- the class literal could be doing more things - on the stack, which means that the stack may not be empty at this point in the - above code gen. So we save its state and restart it from 1. */ + anyExceptionHandler.place(); - anyExceptionHandler.place(); + // Transform the current exception, and repush and throw a + // NoClassDefFoundError(ClassNotFound.getMessage()) - // Transform the current exception, and repush and throw a - // NoClassDefFoundError(ClassNotFound.getMessage()) + this.newNoClassDefFoundError(); + this.dup_x1(); + this.swap(); - this.newNoClassDefFoundError(); - this.dup_x1(); - this.swap(); + // Retrieve the message from the old exception + this.invokeThrowableGetMessage(); - // Retrieve the message from the old exception - this.invokeThrowableGetMessage(); + // Send the constructor taking a message string as an argument + this.invokeNoClassDefFoundErrorStringConstructor(); + this.athrow(); + endLabel.place(); + stackDepth = saveStackSize; + } + /** + * This method returns the exception handler to be able to generate the exception handler + * attribute. + */ + final public int[] generateCodeAttributeForProblemMethod(String errorName, String problemMessage) { + /** + * Equivalent code: + * try { + * throw ((Error) (Class.forName(errorName).getConstructor(new Class[] {Class.forName("java.lang.String")})).newInstance(new Object[] {problemMessage})); + * } catch (Exception e) { + * throw (NullPointerException) null; + * } + */ + int endPC, handlerPC; + ldc(errorName); + invokeClassForName(); + iconst_1(); + anewarrayJavaLangClass(); + dup(); + iconst_0(); + ldc("java.lang.String"); //$NON-NLS-1$ + invokeClassForName(); + aastore(); + invokeConstructorGetConstructor(); + iconst_1(); + anewarrayJavaLangObject(); + dup(); + iconst_0(); + ldc(problemMessage); + aastore(); + invokeObjectNewInstance(); + checkcastJavaLangError(); + athrow(); + endPC = handlerPC = position; + pop(); + aconst_null(); + athrow(); + return_(); + return new int[] { 0, endPC, handlerPC }; + } + public void generateConstant(Constant constant, int implicitConversionCode) { + int targetTypeID = implicitConversionCode >> 4; + switch (targetTypeID) { + case T_boolean : + generateInlinedValue(constant.booleanValue()); + break; + case T_char : + generateInlinedValue(constant.charValue()); + break; + case T_byte : + generateInlinedValue(constant.byteValue()); + break; + case T_short : + generateInlinedValue(constant.shortValue()); + break; + case T_int : + generateInlinedValue(constant.intValue()); + break; + case T_long : + generateInlinedValue(constant.longValue()); + break; + case T_float : + generateInlinedValue(constant.floatValue()); + break; + case T_double : + generateInlinedValue(constant.doubleValue()); + break; + case T_String : + this.ldc(constant.stringValue()); + break; + default : //reference object (constant can be from T_null or T_String) + if (constant.typeID() == T_String) + ldc(constant.stringValue()); + else + aconst_null(); + } + } + /** + * @param implicitConversionCode int + */ + public void generateImplicitConversion(int implicitConversionCode) { + switch (implicitConversionCode) { + case Float2Char : + this.f2i(); + this.i2c(); + break; + case Double2Char : + this.d2i(); + this.i2c(); + break; + case Int2Char : + case Short2Char : + case Byte2Char : + this.i2c(); + break; + case Long2Char : + this.l2i(); + this.i2c(); + break; + case Char2Float : + case Short2Float : + case Int2Float : + case Byte2Float : + this.i2f(); + break; + case Double2Float : + this.d2f(); + break; + case Long2Float : + this.l2f(); + break; + case Float2Byte : + this.f2i(); + this.i2b(); + break; + case Double2Byte : + this.d2i(); + this.i2b(); + break; + case Int2Byte : + case Short2Byte : + case Char2Byte : + this.i2b(); + break; + case Long2Byte : + this.l2i(); + this.i2b(); + break; + case Byte2Double : + case Char2Double : + case Short2Double : + case Int2Double : + this.i2d(); + break; + case Float2Double : + this.f2d(); + break; + case Long2Double : + this.l2d(); + break; + case Byte2Short : + case Char2Short : + case Int2Short : + this.i2s(); + break; + case Double2Short : + this.d2i(); + this.i2s(); + break; + case Long2Short : + this.l2i(); + this.i2s(); + break; + case Float2Short : + this.f2i(); + this.i2s(); + break; + case Double2Int : + this.d2i(); + break; + case Float2Int : + this.f2i(); + break; + case Long2Int : + this.l2i(); + break; + case Int2Long : + case Char2Long : + case Byte2Long : + case Short2Long : + this.i2l(); + break; + case Double2Long : + this.d2l(); + break; + case Float2Long : + this.f2l(); + } + } + public void generateInlinedValue(byte inlinedValue) { + switch (inlinedValue) { + case -1 : + this.iconst_m1(); + break; + case 0 : + this.iconst_0(); + break; + case 1 : + this.iconst_1(); + break; + case 2 : + this.iconst_2(); + break; + case 3 : + this.iconst_3(); + break; + case 4 : + this.iconst_4(); + break; + case 5 : + this.iconst_5(); + break; + default : + if ((-128 <= inlinedValue) && (inlinedValue <= 127)) { + this.bipush((byte) inlinedValue); + return; + } + } + } + public void generateInlinedValue(char inlinedValue) { + switch (inlinedValue) { + case 0 : + this.iconst_0(); + break; + case 1 : + this.iconst_1(); + break; + case 2 : + this.iconst_2(); + break; + case 3 : + this.iconst_3(); + break; + case 4 : + this.iconst_4(); + break; + case 5 : + this.iconst_5(); + break; + default : + if ((6 <= inlinedValue) && (inlinedValue <= 127)) { + this.bipush((byte) inlinedValue); + return; + } + if ((128 <= inlinedValue) && (inlinedValue <= 32767)) { + this.sipush(inlinedValue); + return; + } + this.ldc(inlinedValue); + } + } + public void generateInlinedValue(double inlinedValue) { + if (inlinedValue == 0.0) { + if (Double.doubleToLongBits(inlinedValue) != 0L) + this.ldc2_w(inlinedValue); + else + this.dconst_0(); + return; + } + if (inlinedValue == 1.0) { + this.dconst_1(); + return; + } + this.ldc2_w(inlinedValue); + } + public void generateInlinedValue(float inlinedValue) { + if (inlinedValue == 0.0f) { + if (Float.floatToIntBits(inlinedValue) != 0) + this.ldc(inlinedValue); + else + this.fconst_0(); + return; + } + if (inlinedValue == 1.0f) { + this.fconst_1(); + return; + } + if (inlinedValue == 2.0f) { + this.fconst_2(); + return; + } + this.ldc(inlinedValue); + } + public void generateInlinedValue(int inlinedValue) { + switch (inlinedValue) { + case -1 : + this.iconst_m1(); + break; + case 0 : + this.iconst_0(); + break; + case 1 : + this.iconst_1(); + break; + case 2 : + this.iconst_2(); + break; + case 3 : + this.iconst_3(); + break; + case 4 : + this.iconst_4(); + break; + case 5 : + this.iconst_5(); + break; + default : + if ((-128 <= inlinedValue) && (inlinedValue <= 127)) { + this.bipush((byte) inlinedValue); + return; + } + if ((-32768 <= inlinedValue) && (inlinedValue <= 32767)) { + this.sipush(inlinedValue); + return; + } + this.ldc(inlinedValue); + } + } + public void generateInlinedValue(long inlinedValue) { + if (inlinedValue == 0) { + this.lconst_0(); + return; + } + if (inlinedValue == 1) { + this.lconst_1(); + return; + } + this.ldc2_w(inlinedValue); + } + public void generateInlinedValue(short inlinedValue) { + switch (inlinedValue) { + case -1 : + this.iconst_m1(); + break; + case 0 : + this.iconst_0(); + break; + case 1 : + this.iconst_1(); + break; + case 2 : + this.iconst_2(); + break; + case 3 : + this.iconst_3(); + break; + case 4 : + this.iconst_4(); + break; + case 5 : + this.iconst_5(); + break; + default : + if ((-128 <= inlinedValue) && (inlinedValue <= 127)) { + this.bipush((byte) inlinedValue); + return; + } + this.sipush(inlinedValue); + } + } + public void generateInlinedValue(boolean inlinedValue) { + if (inlinedValue) + this.iconst_1(); + else + this.iconst_0(); + } + public void generateOuterAccess(Object[] mappingSequence, AstNode invocationSite, Scope scope) { + if (mappingSequence == null) + return; + if (mappingSequence == BlockScope.EmulationPathToImplicitThis) { + if (scope.methodScope().isConstructorCall) { + scope.problemReporter().errorThisSuperInStatic(invocationSite); + } + this.aload_0(); + return; + } + if (mappingSequence[0] instanceof FieldBinding) { + FieldBinding fieldBinding = (FieldBinding) mappingSequence[0]; + if (scope.methodScope().isConstructorCall) { + scope.problemReporter().errorThisSuperInStatic(invocationSite); + } + this.aload_0(); + this.getfield(fieldBinding); + } else { + load((LocalVariableBinding) mappingSequence[0]); + } + for (int i = 1, length = mappingSequence.length; i < length; i++) { + if (mappingSequence[i] instanceof FieldBinding) { + FieldBinding fieldBinding = (FieldBinding) mappingSequence[i]; + this.getfield(fieldBinding); + } else { + this.invokestatic((MethodBinding) mappingSequence[i]); + } + } + } + /** + * The equivalent code performs a string conversion: + * + * @param oper1 org.eclipse.jdt.internal.compiler.lookup.BlockScope + * @param oper1 org.eclipse.jdt.internal.compiler.ast.Expression + * @param oper2 org.eclipse.jdt.internal.compiler.ast.Expression + */ + public void generateStringAppend(BlockScope blockScope, Expression oper1, Expression oper2) { + int pc; + if (oper1 == null) { + /* Operand is already on the stack, and maybe nil: + note type1 is always to java.lang.String here.*/ + this.newStringBuffer(); + this.dup_x1(); + this.swap(); + // If argument is reference type, need to transform it + // into a string (handles null case) + this.invokeStringValueOf(T_Object); + this.invokeStringBufferStringConstructor(); + } else { + pc = position; + oper1.generateOptimizedStringBufferCreation(blockScope, this, oper1.implicitConversion & 0xF); + this.recordPositionsFrom(pc, oper1.sourceStart); + } + pc = position; + oper2.generateOptimizedStringBuffer(blockScope, this, oper2.implicitConversion & 0xF); + this.recordPositionsFrom(pc, oper2.sourceStart); + this.invokeStringBufferToString(); + } + /** + * Code responsible to generate the suitable code to supply values for the synthetic arguments of + * a constructor invocation of a nested type. + */ + public void generateSyntheticArgumentValues( + BlockScope currentScope, + ReferenceBinding targetType, + Expression enclosingInstance, + AstNode invocationSite) { - // Send the constructor taking a message string as an argument - this.invokeNoClassDefFoundErrorStringConstructor(); - this.athrow(); - endLabel.place(); - stackDepth = saveStackSize; -} -/** - * This method returns the exception handler to be able to generate the exception handler - * attribute. - */ -final public int[] generateCodeAttributeForProblemMethod(String errorName, String problemMessage) { - /** - * Equivalent code: - * try { - * throw ((Error) (Class.forName(errorName).getConstructor(new Class[] {Class.forName("java.lang.String")})).newInstance(new Object[] {problemMessage})); - * } catch (Exception e) { - * throw (NullPointerException) null; - * } - */ - int endPC, handlerPC; - ldc(errorName); - invokeClassForName(); - iconst_1(); - anewarrayJavaLangClass(); - dup(); - iconst_0(); - ldc("java.lang.String"); //$NON-NLS-1$ - invokeClassForName(); - aastore(); - invokeConstructorGetConstructor(); - iconst_1(); - anewarrayJavaLangObject(); - dup(); - iconst_0(); - ldc(problemMessage); - aastore(); - invokeObjectNewInstance(); - checkcastJavaLangError(); - athrow(); - endPC = handlerPC = position; - pop(); - aconst_null(); - athrow(); - return_(); - return new int[] {0, endPC, handlerPC}; -} -public void generateConstant(Constant constant, int implicitConversionCode) { - int targetTypeID = implicitConversionCode >> 4; - switch (targetTypeID) { - case T_boolean : - generateInlinedValue(constant.booleanValue()); - break; - case T_char : - generateInlinedValue(constant.charValue()); - break; - case T_byte : - generateInlinedValue(constant.byteValue()); - break; - case T_short : - generateInlinedValue(constant.shortValue()); - break; - case T_int : - generateInlinedValue(constant.intValue()); - break; - case T_long : - generateInlinedValue(constant.longValue()); - break; - case T_float : - generateInlinedValue(constant.floatValue()); - break; - case T_double : - generateInlinedValue(constant.doubleValue()); - break; - case T_String : - this.ldc(constant.stringValue()); - break; - default : //reference object (constant can be from T_null or T_String) - if (constant.typeID() == T_String) - ldc(constant.stringValue()); - else - aconst_null(); - } -} -/** - * @param implicitConversionCode int - */ -public void generateImplicitConversion(int implicitConversionCode) { - switch (implicitConversionCode) { - case Float2Char : - this.f2i(); - this.i2c(); - break; - case Double2Char : - this.d2i(); - this.i2c(); - break; - case Int2Char : - case Short2Char : - case Byte2Char : - this.i2c(); - break; - case Long2Char : - this.l2i(); - this.i2c(); - break; - case Char2Float : - case Short2Float : - case Int2Float : - case Byte2Float : - this.i2f(); - break; - case Double2Float : - this.d2f(); - break; - case Long2Float : - this.l2f(); - break; - case Float2Byte : - this.f2i(); - this.i2b(); - break; - case Double2Byte : - this.d2i(); - this.i2b(); - break; - case Int2Byte : - case Short2Byte : - case Char2Byte : - this.i2b(); - break; - case Long2Byte : - this.l2i(); - this.i2b(); - break; - case Byte2Double : - case Char2Double : - case Short2Double : - case Int2Double : - this.i2d(); - break; - case Float2Double : - this.f2d(); - break; - case Long2Double : - this.l2d(); - break; - case Byte2Short : - case Char2Short : - case Int2Short : - this.i2s(); - break; - case Double2Short : - this.d2i(); - this.i2s(); - break; - case Long2Short : - this.l2i(); - this.i2s(); - break; - case Float2Short : - this.f2i(); - this.i2s(); - break; - case Double2Int : - this.d2i(); - break; - case Float2Int : - this.f2i(); - break; - case Long2Int : - this.l2i(); - break; - case Int2Long : - case Char2Long : - case Byte2Long : - case Short2Long : - this.i2l(); - break; - case Double2Long : - this.d2l(); - break; - case Float2Long : - this.f2l(); - } -} -public void generateInlinedValue(byte inlinedValue) { - switch (inlinedValue) { - case -1 : - this.iconst_m1(); - break; - case 0 : - this.iconst_0(); - break; - case 1 : - this.iconst_1(); - break; - case 2 : - this.iconst_2(); - break; - case 3 : - this.iconst_3(); - break; - case 4 : - this.iconst_4(); - break; - case 5 : - this.iconst_5(); - break; - default : - if ((-128 <= inlinedValue) && (inlinedValue <= 127)) { - this.bipush((byte) inlinedValue); - return; - } - } -} -public void generateInlinedValue(char inlinedValue) { - switch (inlinedValue) { - case 0 : - this.iconst_0(); - break; - case 1 : - this.iconst_1(); - break; - case 2 : - this.iconst_2(); - break; - case 3 : - this.iconst_3(); - break; - case 4 : - this.iconst_4(); - break; - case 5 : - this.iconst_5(); - break; - default : - if ((6 <= inlinedValue) && (inlinedValue <= 127)) { - this.bipush((byte) inlinedValue); - return; - } - if ((128 <= inlinedValue) && (inlinedValue <= 32767)) { - this.sipush(inlinedValue); - return; - } - this.ldc(inlinedValue); - } -} -public void generateInlinedValue(double inlinedValue) { - if (inlinedValue == 0.0) { - if (Double.doubleToLongBits(inlinedValue) != 0L) - this.ldc2_w(inlinedValue); - else - this.dconst_0(); - return; - } - if (inlinedValue == 1.0) { - this.dconst_1(); - return; - } - this.ldc2_w(inlinedValue); -} -public void generateInlinedValue(float inlinedValue) { - if (inlinedValue == 0.0f) { - if (Float.floatToIntBits(inlinedValue) != 0) - this.ldc(inlinedValue); - else - this.fconst_0(); - return; - } - if (inlinedValue == 1.0f) { - this.fconst_1(); - return; - } - if (inlinedValue == 2.0f) { - this.fconst_2(); - return; - } - this.ldc(inlinedValue); -} -public void generateInlinedValue(int inlinedValue) { - switch (inlinedValue) { - case -1 : - this.iconst_m1(); - break; - case 0 : - this.iconst_0(); - break; - case 1 : - this.iconst_1(); - break; - case 2 : - this.iconst_2(); - break; - case 3 : - this.iconst_3(); - break; - case 4 : - this.iconst_4(); - break; - case 5 : - this.iconst_5(); - break; - default : - if ((-128 <= inlinedValue) && (inlinedValue <= 127)) { - this.bipush((byte) inlinedValue); - return; - } - if ((-32768 <= inlinedValue) && (inlinedValue <= 32767)) { - this.sipush(inlinedValue); - return; - } - this.ldc(inlinedValue); - } -} -public void generateInlinedValue(long inlinedValue) { - if (inlinedValue == 0) { - this.lconst_0(); - return; - } - if (inlinedValue == 1) { - this.lconst_1(); - return; - } - this.ldc2_w(inlinedValue); -} -public void generateInlinedValue(short inlinedValue) { - switch (inlinedValue) { - case -1 : - this.iconst_m1(); - break; - case 0 : - this.iconst_0(); - break; - case 1 : - this.iconst_1(); - break; - case 2 : - this.iconst_2(); - break; - case 3 : - this.iconst_3(); - break; - case 4 : - this.iconst_4(); - break; - case 5 : - this.iconst_5(); - break; - default : - if ((-128 <= inlinedValue) && (inlinedValue <= 127)) { - this.bipush((byte) inlinedValue); - return; - } - this.sipush(inlinedValue); - } -} -public void generateInlinedValue(boolean inlinedValue) { - if (inlinedValue) - this.iconst_1(); - else - this.iconst_0(); -} -public void generateOuterAccess(Object[] mappingSequence, AstNode invocationSite, Scope scope) { - if (mappingSequence == null) - return; - if (mappingSequence == BlockScope.EmulationPathToImplicitThis) { - if (scope.methodScope().isConstructorCall){ - scope.problemReporter().errorThisSuperInStatic(invocationSite); - } - this.aload_0(); - return; - } - if (mappingSequence[0] instanceof FieldBinding) { - FieldBinding fieldBinding = (FieldBinding) mappingSequence[0]; - if (scope.methodScope().isConstructorCall){ - scope.problemReporter().errorThisSuperInStatic(invocationSite); - } - this.aload_0(); - this.getfield(fieldBinding); - } else { - load((LocalVariableBinding) mappingSequence[0]); - } - for (int i = 1, length = mappingSequence.length; i < length; i++) { - if (mappingSequence[i] instanceof FieldBinding) { - FieldBinding fieldBinding = (FieldBinding) mappingSequence[i]; - this.getfield(fieldBinding); - } else { - this.invokestatic((MethodBinding) mappingSequence[i]); - } - } -} -/** - * The equivalent code performs a string conversion: - * - * @param oper1 org.eclipse.jdt.internal.compiler.lookup.BlockScope - * @param oper1 org.eclipse.jdt.internal.compiler.ast.Expression - * @param oper2 org.eclipse.jdt.internal.compiler.ast.Expression - */ -public void generateStringAppend(BlockScope blockScope, Expression oper1, Expression oper2) { - int pc; - if (oper1 == null) { - /* Operand is already on the stack, and maybe nil: - note type1 is always to java.lang.String here.*/ - this.newStringBuffer(); - this.dup_x1(); - this.swap(); - // If argument is reference type, need to transform it - // into a string (handles null case) - this.invokeStringValueOf(T_Object); - this.invokeStringBufferStringConstructor(); - } else { - pc = position; - oper1.generateOptimizedStringBufferCreation(blockScope, this, oper1.implicitConversion & 0xF); - this.recordPositionsFrom(pc, oper1.sourceStart); - } - pc = position; - oper2.generateOptimizedStringBuffer(blockScope, this, oper2.implicitConversion & 0xF); - this.recordPositionsFrom(pc, oper2.sourceStart); - this.invokeStringBufferToString(); -} -/** - * Code responsible to generate the suitable code to supply values for the synthetic arguments of - * a constructor invocation of a nested type. - */ -public void generateSyntheticArgumentValues(BlockScope currentScope, ReferenceBinding targetType, Expression enclosingInstance, AstNode invocationSite) { + // perform some emulation work in case there is some and we are inside a local type only + ReferenceBinding[] syntheticArgumentTypes; - // perform some emulation work in case there is some and we are inside a local type only - ReferenceBinding[] syntheticArgumentTypes; + // generate the enclosing instance first + if ((syntheticArgumentTypes = targetType.syntheticEnclosingInstanceTypes()) != null) { - // generate the enclosing instance first - if ((syntheticArgumentTypes = targetType.syntheticEnclosingInstanceTypes()) != null) { + ReferenceBinding targetEnclosingType = + targetType.isAnonymousType() + ? targetType.superclass().enclosingType() // supplying enclosing instance for the anonymous type's superclass + : targetType.enclosingType(); - ReferenceBinding targetEnclosingType = targetType.isAnonymousType() ? - targetType.superclass().enclosingType() // supplying enclosing instance for the anonymous type's superclass - : targetType.enclosingType(); - - for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) { - ReferenceBinding syntheticArgType = syntheticArgumentTypes[i]; - if (enclosingInstance != null && i == 0) { - if (syntheticArgType != targetEnclosingType) { - currentScope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, targetType); - } - //if (currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4){ - enclosingInstance.generateCode(currentScope, this, true); - if (syntheticArgType == targetEnclosingType){ - this.dup(); - } - this.invokeObjectGetClass(); // causes null check for all explicit enclosing instances - this.pop(); - //} else { - // enclosingInstance.generateCode(currentScope, this, syntheticArgType == targetEnclosingType); - //} - } else { - Object[] emulationPath = currentScope.getCompatibleEmulationPath(syntheticArgType); - if (emulationPath == null) { - currentScope.problemReporter().missingEnclosingInstanceSpecification(syntheticArgType, invocationSite); - } else { - this.generateOuterAccess(emulationPath, invocationSite, currentScope); - } - } - } - } else { // we may still have an enclosing instance to consider - if (enclosingInstance != null) { - currentScope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, targetType); - //if (currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4){ - enclosingInstance.generateCode(currentScope, this, true); - this.invokeObjectGetClass(); // causes null check for all explicit enclosing instances - this.pop(); - //} else { - // enclosingInstance.generateCode(currentScope, this, false); // do not want the value - //} - } - } - // generate the synthetic outer arguments then - SyntheticArgumentBinding syntheticArguments[]; - if ((syntheticArguments = targetType.syntheticOuterLocalVariables()) != null) { - for (int i = 0, max = syntheticArguments.length; i < max; i++) { - VariableBinding[] emulationPath = currentScope.getEmulationPath(syntheticArguments[i].actualOuterLocalVariable); - if (emulationPath == null) { - // could not emulate a path to a given outer local variable (internal error) - currentScope.problemReporter().needImplementation(); - } else { - this.generateOuterAccess(emulationPath, invocationSite, currentScope); - } - } - } -} -/** - * @param parameters org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] - * @param constructorBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding - */ -public void generateSyntheticBodyForConstructorAccess(SyntheticAccessMethodBinding accessBinding) { + for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) { + ReferenceBinding syntheticArgType = syntheticArgumentTypes[i]; + if (enclosingInstance != null && i == 0) { + if (syntheticArgType != targetEnclosingType) { + currentScope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, targetType); + } + //if (currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4){ + enclosingInstance.generateCode(currentScope, this, true); + if (syntheticArgType == targetEnclosingType) { + this.dup(); + } + this.invokeObjectGetClass(); // causes null check for all explicit enclosing instances + this.pop(); + //} else { + // enclosingInstance.generateCode(currentScope, this, syntheticArgType == targetEnclosingType); + //} + } else { + Object[] emulationPath = currentScope.getCompatibleEmulationPath(syntheticArgType); + if (emulationPath == null) { + currentScope.problemReporter().missingEnclosingInstanceSpecification(syntheticArgType, invocationSite); + } else { + this.generateOuterAccess(emulationPath, invocationSite, currentScope); + } + } + } + } else { // we may still have an enclosing instance to consider + if (enclosingInstance != null) { + currentScope.problemReporter().unnecessaryEnclosingInstanceSpecification(enclosingInstance, targetType); + //if (currentScope.environment().options.complianceLevel >= CompilerOptions.JDK1_4){ + enclosingInstance.generateCode(currentScope, this, true); + this.invokeObjectGetClass(); // causes null check for all explicit enclosing instances + this.pop(); + //} else { + // enclosingInstance.generateCode(currentScope, this, false); // do not want the value + //} + } + } + // generate the synthetic outer arguments then + SyntheticArgumentBinding syntheticArguments[]; + if ((syntheticArguments = targetType.syntheticOuterLocalVariables()) != null) { + for (int i = 0, max = syntheticArguments.length; i < max; i++) { + VariableBinding[] emulationPath = currentScope.getEmulationPath(syntheticArguments[i].actualOuterLocalVariable); + if (emulationPath == null) { + // could not emulate a path to a given outer local variable (internal error) + currentScope.problemReporter().needImplementation(); + } else { + this.generateOuterAccess(emulationPath, invocationSite, currentScope); + } + } + } + } + /** + * @param parameters org.eclipse.jdt.internal.compiler.lookup.TypeBinding[] + * @param constructorBinding org.eclipse.jdt.internal.compiler.lookup.MethodBinding + */ + public void generateSyntheticBodyForConstructorAccess(SyntheticAccessMethodBinding accessBinding) { - initializeMaxLocals(accessBinding); + initializeMaxLocals(accessBinding); - MethodBinding constructorBinding = accessBinding.targetMethod; - TypeBinding[] parameters = constructorBinding.parameters; - int length = parameters.length; - int resolvedPosition = 1; - this.aload_0(); - if (constructorBinding.declaringClass.isNestedType()) { - NestedTypeBinding nestedType = (NestedTypeBinding) constructorBinding.declaringClass; - SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticEnclosingInstances(); - for (int i = 0; i < (syntheticArguments == null ? 0 : syntheticArguments.length); i++) { - TypeBinding type; - load((type = syntheticArguments[i].type), resolvedPosition); - if ((type == DoubleBinding) || (type == LongBinding)) - resolvedPosition += 2; - else - resolvedPosition++; - } - syntheticArguments = nestedType.syntheticOuterLocalVariables(); - for (int i = 0; i < (syntheticArguments == null ? 0 : syntheticArguments.length); i++) { - TypeBinding type; - load((type = syntheticArguments[i].type), resolvedPosition); - if ((type == DoubleBinding) || (type == LongBinding)) - resolvedPosition += 2; - else - resolvedPosition++; - } - } - for (int i = 0; i < length; i++) { - load(parameters[i], resolvedPosition); - if ((parameters[i] == DoubleBinding) || (parameters[i] == LongBinding)) - resolvedPosition += 2; - else - resolvedPosition++; - } - this.invokespecial(constructorBinding); - this.return_(); -} -public void generateSyntheticBodyForFieldReadAccess(SyntheticAccessMethodBinding accessBinding) { - initializeMaxLocals(accessBinding); - FieldBinding fieldBinding = accessBinding.targetReadField; - TypeBinding type; - if (fieldBinding.isStatic()) - this.getstatic(fieldBinding); - else { - this.aload_0(); - this.getfield(fieldBinding); - } - if ((type = fieldBinding.type).isBaseType()) { - if (type == IntBinding) - this.ireturn(); - else - if (type == FloatBinding) - this.freturn(); - else - if (type == LongBinding) - this.lreturn(); - else - if (type == DoubleBinding) - this.dreturn(); - else - this.ireturn(); - } else - this.areturn(); -} -public void generateSyntheticBodyForFieldWriteAccess(SyntheticAccessMethodBinding accessBinding) { - initializeMaxLocals(accessBinding); - FieldBinding fieldBinding = accessBinding.targetWriteField; - if (fieldBinding.isStatic()) { - load(fieldBinding.type, 0); - this.putstatic(fieldBinding); - } else { - this.aload_0(); - load(fieldBinding.type, 1); - this.putfield(fieldBinding); - } - this.return_(); -} -public void generateSyntheticBodyForMethodAccess(SyntheticAccessMethodBinding accessBinding) { + MethodBinding constructorBinding = accessBinding.targetMethod; + TypeBinding[] parameters = constructorBinding.parameters; + int length = parameters.length; + int resolvedPosition = 1; + this.aload_0(); + if (constructorBinding.declaringClass.isNestedType()) { + NestedTypeBinding nestedType = (NestedTypeBinding) constructorBinding.declaringClass; + SyntheticArgumentBinding[] syntheticArguments = nestedType.syntheticEnclosingInstances(); + for (int i = 0; i < (syntheticArguments == null ? 0 : syntheticArguments.length); i++) { + TypeBinding type; + load((type = syntheticArguments[i].type), resolvedPosition); + if ((type == DoubleBinding) || (type == LongBinding)) + resolvedPosition += 2; + else + resolvedPosition++; + } + syntheticArguments = nestedType.syntheticOuterLocalVariables(); + for (int i = 0; i < (syntheticArguments == null ? 0 : syntheticArguments.length); i++) { + TypeBinding type; + load((type = syntheticArguments[i].type), resolvedPosition); + if ((type == DoubleBinding) || (type == LongBinding)) + resolvedPosition += 2; + else + resolvedPosition++; + } + } + for (int i = 0; i < length; i++) { + load(parameters[i], resolvedPosition); + if ((parameters[i] == DoubleBinding) || (parameters[i] == LongBinding)) + resolvedPosition += 2; + else + resolvedPosition++; + } + this.invokespecial(constructorBinding); + this.return_(); + } + public void generateSyntheticBodyForFieldReadAccess(SyntheticAccessMethodBinding accessBinding) { + initializeMaxLocals(accessBinding); + FieldBinding fieldBinding = accessBinding.targetReadField; + TypeBinding type; + if (fieldBinding.isStatic()) + this.getstatic(fieldBinding); + else { + this.aload_0(); + this.getfield(fieldBinding); + } + if ((type = fieldBinding.type).isBaseType()) { + if (type == IntBinding) + this.ireturn(); + else if (type == FloatBinding) + this.freturn(); + else if (type == LongBinding) + this.lreturn(); + else if (type == DoubleBinding) + this.dreturn(); + else + this.ireturn(); + } else + this.areturn(); + } + public void generateSyntheticBodyForFieldWriteAccess(SyntheticAccessMethodBinding accessBinding) { + initializeMaxLocals(accessBinding); + FieldBinding fieldBinding = accessBinding.targetWriteField; + if (fieldBinding.isStatic()) { + load(fieldBinding.type, 0); + this.putstatic(fieldBinding); + } else { + this.aload_0(); + load(fieldBinding.type, 1); + this.putfield(fieldBinding); + } + this.return_(); + } + public void generateSyntheticBodyForMethodAccess(SyntheticAccessMethodBinding accessBinding) { - initializeMaxLocals(accessBinding); - MethodBinding methodBinding = accessBinding.targetMethod; - TypeBinding[] parameters = methodBinding.parameters; - int length = parameters.length; - int resolvedPosition; - if (methodBinding.isStatic()) - resolvedPosition = 0; - else { - this.aload_0(); - resolvedPosition = 1; - } - for (int i = 0; i < length; i++) { - load(parameters[i], resolvedPosition); - if ((parameters[i] == DoubleBinding) || (parameters[i] == LongBinding)) - resolvedPosition += 2; - else - resolvedPosition++; - } - TypeBinding type; - if (methodBinding.isStatic()) - this.invokestatic(methodBinding); - else { - if (methodBinding.isConstructor() - || methodBinding.isPrivate() - // qualified super "X.super.foo()" targets methods from superclass - || (methodBinding.declaringClass != methodDeclaration.binding.declaringClass)){ - this.invokespecial(methodBinding); - } else { - if (methodBinding.declaringClass.isInterface()){ - this.invokeinterface(methodBinding); - } else { - this.invokevirtual(methodBinding); - } - } - } - if ((type = methodBinding.returnType).isBaseType()) - if (type == VoidBinding) - this.return_(); - else - if (type == IntBinding) - this.ireturn(); - else - if (type == FloatBinding) - this.freturn(); - else - if (type == LongBinding) - this.lreturn(); - else - if (type == DoubleBinding) - this.dreturn(); - else - this.ireturn(); - else - this.areturn(); -} -final public byte[] getContents() { - byte[] contents; - System.arraycopy(bCodeStream, 0, contents = new byte[position], 0, position); - return contents; -} -final public void getfield(FieldBinding fieldBinding) { - countLabels = 0; - if ((fieldBinding.type.id == T_double) || (fieldBinding.type.id == T_long)) { - if (++stackDepth > stackMax) - stackMax = stackDepth; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_getfield; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_getfield); - } - writeUnsignedShort(constantPool.literalIndex(fieldBinding)); -} -final public void getstatic(FieldBinding fieldBinding) { - countLabels = 0; - if ((fieldBinding.type.id == T_double) || (fieldBinding.type.id == T_long)) - stackDepth += 2; - else - stackDepth += 1; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_getstatic; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_getstatic); - } - writeUnsignedShort(constantPool.literalIndex(fieldBinding)); -} -public void getSystemOut() { - countLabels = 0; - if (++stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_getstatic; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_getstatic); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangSystemOut()); -} -public void getTYPE(int baseTypeID) { - countLabels = 0; - if (++stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_getstatic; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_getstatic); - } - switch (baseTypeID) { - // getstatic: java.lang.Byte.TYPE - case T_byte : - writeUnsignedShort(constantPool.literalIndexForJavaLangByteTYPE()); - break; - // getstatic: java.lang.Short.TYPE - case T_short : - writeUnsignedShort(constantPool.literalIndexForJavaLangShortTYPE()); - break; - // getstatic: java.lang.Character.TYPE - case T_char : - writeUnsignedShort(constantPool.literalIndexForJavaLangCharacterTYPE()); - break; - // getstatic: java.lang.Integer.TYPE - case T_int : - writeUnsignedShort(constantPool.literalIndexForJavaLangIntegerTYPE()); - break; - // getstatic: java.lang.Long.TYPE - case T_long : - writeUnsignedShort(constantPool.literalIndexForJavaLangLongTYPE()); - break; - // getstatic: java.lang.Float.TYPE - case T_float : - writeUnsignedShort(constantPool.literalIndexForJavaLangFloatTYPE()); - break; - // getstatic: java.lang.Double.TYPE - case T_double : - writeUnsignedShort(constantPool.literalIndexForJavaLangDoubleTYPE()); - break; - // getstatic: java.lang.Boolean.TYPE - case T_boolean : - writeUnsignedShort(constantPool.literalIndexForJavaLangBooleanTYPE()); - break; - // getstatic: java.lang.Void.TYPE - case T_void : - writeUnsignedShort(constantPool.literalIndexForJavaLangVoidTYPE()); - break; - } -} -/** - * We didn't call it goto, because there is a conflit with the goto keyword - */ -final public void goto_(Label lbl) { - if (this.wideMode) { - this.goto_w(lbl); - return; - } - try { - lbl.inlineForwardReferencesFromLabelsTargeting(position); - /* - Possible optimization for code such as: - public Object foo() { - boolean b = true; - if (b) { - if (b) - return null; - } else { - if (b) { - return null; - } - } - return null; - } - The goto around the else block for the first if will - be unreachable, because the thenClause of the second if - returns. - See inlineForwardReferencesFromLabelsTargeting defined - on the Label class for the remaining part of this - optimization. - if (!lbl.isBranchTarget(position)) { - switch(bCodeStream[classFileOffset-1]) { - case OPC_return : - case OPC_areturn: - return; - } - }*/ - position++; - bCodeStream[classFileOffset++] = OPC_goto; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_goto); - } - lbl.branch(); -} + initializeMaxLocals(accessBinding); + MethodBinding methodBinding = accessBinding.targetMethod; + TypeBinding[] parameters = methodBinding.parameters; + int length = parameters.length; + int resolvedPosition; + if (methodBinding.isStatic()) + resolvedPosition = 0; + else { + this.aload_0(); + resolvedPosition = 1; + } + for (int i = 0; i < length; i++) { + load(parameters[i], resolvedPosition); + if ((parameters[i] == DoubleBinding) || (parameters[i] == LongBinding)) + resolvedPosition += 2; + else + resolvedPosition++; + } + TypeBinding type; + if (methodBinding.isStatic()) + this.invokestatic(methodBinding); + else { + if (methodBinding.isConstructor() + || methodBinding.isPrivate() // qualified super "X.super.foo()" targets methods from superclass + || (methodBinding.declaringClass != methodDeclaration.binding.declaringClass)) { + this.invokespecial(methodBinding); + } else { + if (methodBinding.declaringClass.isInterface()) { + this.invokeinterface(methodBinding); + } else { + this.invokevirtual(methodBinding); + } + } + } + if ((type = methodBinding.returnType).isBaseType()) + if (type == VoidBinding) + this.return_(); + else if (type == IntBinding) + this.ireturn(); + else if (type == FloatBinding) + this.freturn(); + else if (type == LongBinding) + this.lreturn(); + else if (type == DoubleBinding) + this.dreturn(); + else + this.ireturn(); + else + this.areturn(); + } + final public byte[] getContents() { + byte[] contents; + System.arraycopy(bCodeStream, 0, contents = new byte[position], 0, position); + return contents; + } + final public void getfield(FieldBinding fieldBinding) { + countLabels = 0; + if ((fieldBinding.type.id == T_double) || (fieldBinding.type.id == T_long)) { + if (++stackDepth > stackMax) + stackMax = stackDepth; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_getfield; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_getfield); + } + writeUnsignedShort(constantPool.literalIndex(fieldBinding)); + } + final public void getstatic(FieldBinding fieldBinding) { + countLabels = 0; + if ((fieldBinding.type.id == T_double) || (fieldBinding.type.id == T_long)) + stackDepth += 2; + else + stackDepth += 1; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_getstatic; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_getstatic); + } + writeUnsignedShort(constantPool.literalIndex(fieldBinding)); + } + public void getSystemOut() { + countLabels = 0; + if (++stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_getstatic; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_getstatic); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangSystemOut()); + } + public void getTYPE(int baseTypeID) { + countLabels = 0; + if (++stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_getstatic; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_getstatic); + } + switch (baseTypeID) { + // getstatic: java.lang.Byte.TYPE + case T_byte : + writeUnsignedShort(constantPool.literalIndexForJavaLangByteTYPE()); + break; + // getstatic: java.lang.Short.TYPE + case T_short : + writeUnsignedShort(constantPool.literalIndexForJavaLangShortTYPE()); + break; + // getstatic: java.lang.Character.TYPE + case T_char : + writeUnsignedShort(constantPool.literalIndexForJavaLangCharacterTYPE()); + break; + // getstatic: java.lang.Integer.TYPE + case T_int : + writeUnsignedShort(constantPool.literalIndexForJavaLangIntegerTYPE()); + break; + // getstatic: java.lang.Long.TYPE + case T_long : + writeUnsignedShort(constantPool.literalIndexForJavaLangLongTYPE()); + break; + // getstatic: java.lang.Float.TYPE + case T_float : + writeUnsignedShort(constantPool.literalIndexForJavaLangFloatTYPE()); + break; + // getstatic: java.lang.Double.TYPE + case T_double : + writeUnsignedShort(constantPool.literalIndexForJavaLangDoubleTYPE()); + break; + // getstatic: java.lang.Boolean.TYPE + case T_boolean : + writeUnsignedShort(constantPool.literalIndexForJavaLangBooleanTYPE()); + break; + // getstatic: java.lang.Void.TYPE + case T_void : + writeUnsignedShort(constantPool.literalIndexForJavaLangVoidTYPE()); + break; + } + } + /** + * We didn't call it goto, because there is a conflit with the goto keyword + */ + final public void goto_(Label lbl) { + if (this.wideMode) { + this.goto_w(lbl); + return; + } + try { + lbl.inlineForwardReferencesFromLabelsTargeting(position); + /* + Possible optimization for code such as: + public Object foo() { + boolean b = true; + if (b) { + if (b) + return null; + } else { + if (b) { + return null; + } + } + return null; + } + The goto around the else block for the first if will + be unreachable, because the thenClause of the second if + returns. + See inlineForwardReferencesFromLabelsTargeting defined + on the Label class for the remaining part of this + optimization. + if (!lbl.isBranchTarget(position)) { + switch(bCodeStream[classFileOffset-1]) { + case OPC_return : + case OPC_areturn: + return; + } + }*/ + position++; + bCodeStream[classFileOffset++] = OPC_goto; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_goto); + } + lbl.branch(); + } -/** - * We didn't call it goto, because there is a conflit with the goto keyword - */ -final public void internal_goto_(Label lbl) { - try { - lbl.inlineForwardReferencesFromLabelsTargeting(position); - /* - Possible optimization for code such as: - public Object foo() { - boolean b = true; - if (b) { - if (b) - return null; - } else { - if (b) { - return null; - } - } - return null; - } - The goto around the else block for the first if will - be unreachable, because the thenClause of the second if - returns. - See inlineForwardReferencesFromLabelsTargeting defined - on the Label class for the remaining part of this - optimization. - if (!lbl.isBranchTarget(position)) { - switch(bCodeStream[classFileOffset-1]) { - case OPC_return : - case OPC_areturn: - return; - } - }*/ - position++; - bCodeStream[classFileOffset++] = OPC_goto; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_goto); - } - lbl.branch(); -} -final public void goto_w(Label lbl) { - try { - position++; - bCodeStream[classFileOffset++] = OPC_goto_w; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_goto_w); - } - lbl.branchWide(); -} -final public void i2b() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_i2b; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_i2b); - } -} -final public void i2c() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_i2c; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_i2c); - } -} -final public void i2d() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_i2d; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_i2d); - } -} -final public void i2f() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_i2f; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_i2f); - } -} -final public void i2l() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_i2l; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_i2l); - } -} -final public void i2s() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_i2s; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_i2s); - } -} -final public void iadd() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iadd; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iadd); - } -} -final public void iaload() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iaload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iaload); - } -} -final public void iand() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iand; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iand); - } -} -final public void iastore() { - countLabels = 0; - stackDepth -= 3; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iastore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iastore); - } -} -final public void iconst_0() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iconst_0; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iconst_0); - } -} -final public void iconst_1() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iconst_1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iconst_1); - } -} -final public void iconst_2() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iconst_2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iconst_2); - } -} -final public void iconst_3() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iconst_3; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iconst_3); - } -} -final public void iconst_4() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iconst_4; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iconst_4); - } -} -final public void iconst_5() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iconst_5; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iconst_5); - } -} -final public void iconst_m1() { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iconst_m1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iconst_m1); - } -} -final public void idiv() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_idiv; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_idiv); - } -} -final public void if_acmpeq(Label lbl) { - countLabels = 0; - stackDepth-=2; - if (this.wideMode) { - generateWideConditionalBranch(OPC_if_acmpeq, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_if_acmpeq; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_if_acmpeq); - } - lbl.branch(); - } -} -final public void if_acmpne(Label lbl) { - countLabels = 0; - stackDepth-=2; - if (this.wideMode) { - generateWideConditionalBranch(OPC_if_acmpne, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_if_acmpne; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_if_acmpne); - } - lbl.branch(); - } -} -final public void if_icmpeq(Label lbl) { - countLabels = 0; - stackDepth -= 2; - if (this.wideMode) { - generateWideConditionalBranch(OPC_if_icmpeq, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_if_icmpeq; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_if_icmpeq); - } - lbl.branch(); - } -} -final public void if_icmpge(Label lbl) { - countLabels = 0; - stackDepth -= 2; - if (this.wideMode) { - generateWideConditionalBranch(OPC_if_icmpge, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_if_icmpge; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_if_icmpge); - } - lbl.branch(); - } -} -final public void if_icmpgt(Label lbl) { - countLabels = 0; - stackDepth -= 2; - if (this.wideMode) { - generateWideConditionalBranch(OPC_if_icmpgt, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_if_icmpgt; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_if_icmpgt); - } - lbl.branch(); - } -} -final public void if_icmple(Label lbl) { - countLabels = 0; - stackDepth -= 2; - if (this.wideMode) { - generateWideConditionalBranch(OPC_if_icmple, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_if_icmple; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_if_icmple); - } - lbl.branch(); - } -} -final public void if_icmplt(Label lbl) { - countLabels = 0; - stackDepth -= 2; - if (this.wideMode) { - generateWideConditionalBranch(OPC_if_icmplt, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_if_icmplt; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_if_icmplt); - } - lbl.branch(); - } -} -final public void if_icmpne(Label lbl) { - countLabels = 0; - stackDepth -= 2; - if (this.wideMode) { - generateWideConditionalBranch(OPC_if_icmpne, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_if_icmpne; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_if_icmpne); - } - lbl.branch(); - } -} -final public void ifeq(Label lbl) { - countLabels = 0; - stackDepth--; - if (this.wideMode) { - generateWideConditionalBranch(OPC_ifeq, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_ifeq; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ifeq); - } - lbl.branch(); - } -} -final public void ifge(Label lbl) { - countLabels = 0; - stackDepth--; - if (this.wideMode) { - generateWideConditionalBranch(OPC_ifge, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_ifge; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ifge); - } - lbl.branch(); - } -} -final public void ifgt(Label lbl) { - countLabels = 0; - stackDepth--; - if (this.wideMode) { - generateWideConditionalBranch(OPC_ifgt, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_ifgt; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ifgt); - } - lbl.branch(); - } -} -final public void ifle(Label lbl) { - countLabels = 0; - stackDepth--; - if (this.wideMode) { - generateWideConditionalBranch(OPC_ifle, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_ifle; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ifle); - } - lbl.branch(); - } -} -final public void iflt(Label lbl) { - countLabels = 0; - stackDepth--; - if (this.wideMode) { - generateWideConditionalBranch(OPC_iflt, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_iflt; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iflt); - } - lbl.branch(); - } -} -final public void ifne(Label lbl) { - countLabels = 0; - stackDepth--; - if (this.wideMode) { - generateWideConditionalBranch(OPC_ifne, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_ifne; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ifne); - } - lbl.branch(); - } -} -final public void ifnonnull(Label lbl) { - countLabels = 0; - stackDepth--; - if (this.wideMode) { - generateWideConditionalBranch(OPC_ifnonnull, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_ifnonnull; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ifnonnull); - } - lbl.branch(); - } -} -final public void ifnull(Label lbl) { - countLabels = 0; - stackDepth--; - if (this.wideMode) { - generateWideConditionalBranch(OPC_ifnull, lbl); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_ifnull; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ifnull); - } - lbl.branch(); - } -} -final public void iinc(int index, int value) { - countLabels = 0; - if ((index > 255) || (value < -128 || value > 127)) { // have to widen - try { - position++; - bCodeStream[classFileOffset++] = OPC_wide; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_wide); - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_iinc; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iinc); - } - writeUnsignedShort(index); - writeSignedShort(value); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_iinc; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iinc); - } - writeUnsignedByte(index); - writeSignedByte(value); - } -} -final public void iload(int iArg) { - countLabels = 0; - stackDepth++; - if (maxLocals <= iArg) { - maxLocals = iArg + 1; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - if (iArg > 255) { // Widen - try { - position++; - bCodeStream[classFileOffset++] = OPC_wide; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_wide); - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_iload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iload); - } - writeUnsignedShort(iArg); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_iload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iload); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) iArg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) iArg); - } - } -} -final public void iload_0() { - countLabels = 0; - stackDepth++; - if (maxLocals <= 0) { - maxLocals = 1; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iload_0; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iload_0); - } -} -final public void iload_1() { - countLabels = 0; - stackDepth++; - if (maxLocals <= 1) { - maxLocals = 2; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iload_1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iload_1); - } -} -final public void iload_2() { - countLabels = 0; - stackDepth++; - if (maxLocals <= 2) { - maxLocals = 3; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iload_2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iload_2); - } -} -final public void iload_3() { - countLabels = 0; - stackDepth++; - if (maxLocals <= 3) { - maxLocals = 4; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iload_3; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iload_3); - } -} -final public void imul() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_imul; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_imul); - } -} -public void incrementTemp(LocalVariableBinding localBinding, int value) { - if (value == (short) value) { - this.iinc(localBinding.resolvedPosition, value); - return; - } - load(localBinding); - this.ldc(value); - this.iadd(); - store(localBinding, false); -} -public void incrStackSize(int offset) { - if ((stackDepth += offset) > stackMax) - stackMax = stackDepth; -} -public int indexOfSameLineEntrySincePC(int pc, int line) { - for (int index = pc, max = pcToSourceMapSize; index < max; index+=2) { - if (pcToSourceMap[index+1] == line) - return index; - } - return -1; -} -final public void ineg() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_ineg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ineg); - } -} -public void init(ClassFile classFile) { - this.classFile = classFile; - this.constantPool = classFile.constantPool; - this.bCodeStream = classFile.contents; - this.classFileOffset = classFile.contentsOffset; - this.startingClassFileOffset = this.classFileOffset; - pcToSourceMapSize = 0; - lastEntryPC = 0; - int length = visibleLocals.length; - if (noVisibleLocals.length < length) { - noVisibleLocals = new LocalVariableBinding[length]; - } - System.arraycopy(noVisibleLocals, 0, visibleLocals, 0, length); - visibleLocalsCount = 0; - - length = locals.length; - if (noLocals.length < length) { - noLocals = new LocalVariableBinding[length]; - } - System.arraycopy(noLocals, 0, locals, 0, length); - allLocalsCounter = 0; + /** + * We didn't call it goto, because there is a conflit with the goto keyword + */ + final public void internal_goto_(Label lbl) { + try { + lbl.inlineForwardReferencesFromLabelsTargeting(position); + /* + Possible optimization for code such as: + public Object foo() { + boolean b = true; + if (b) { + if (b) + return null; + } else { + if (b) { + return null; + } + } + return null; + } + The goto around the else block for the first if will + be unreachable, because the thenClause of the second if + returns. + See inlineForwardReferencesFromLabelsTargeting defined + on the Label class for the remaining part of this + optimization. + if (!lbl.isBranchTarget(position)) { + switch(bCodeStream[classFileOffset-1]) { + case OPC_return : + case OPC_areturn: + return; + } + }*/ + position++; + bCodeStream[classFileOffset++] = OPC_goto; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_goto); + } + lbl.branch(); + } + final public void goto_w(Label lbl) { + try { + position++; + bCodeStream[classFileOffset++] = OPC_goto_w; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_goto_w); + } + lbl.branchWide(); + } + final public void i2b() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_i2b; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_i2b); + } + } + final public void i2c() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_i2c; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_i2c); + } + } + final public void i2d() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_i2d; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_i2d); + } + } + final public void i2f() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_i2f; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_i2f); + } + } + final public void i2l() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_i2l; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_i2l); + } + } + final public void i2s() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_i2s; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_i2s); + } + } + final public void iadd() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iadd; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iadd); + } + } + final public void iaload() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iaload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iaload); + } + } + final public void iand() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iand; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iand); + } + } + final public void iastore() { + countLabels = 0; + stackDepth -= 3; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iastore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iastore); + } + } + final public void iconst_0() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iconst_0; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iconst_0); + } + } + final public void iconst_1() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iconst_1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iconst_1); + } + } + final public void iconst_2() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iconst_2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iconst_2); + } + } + final public void iconst_3() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iconst_3; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iconst_3); + } + } + final public void iconst_4() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iconst_4; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iconst_4); + } + } + final public void iconst_5() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iconst_5; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iconst_5); + } + } + final public void iconst_m1() { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iconst_m1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iconst_m1); + } + } + final public void idiv() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_idiv; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_idiv); + } + } + final public void if_acmpeq(Label lbl) { + countLabels = 0; + stackDepth -= 2; + if (this.wideMode) { + generateWideConditionalBranch(OPC_if_acmpeq, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_if_acmpeq; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_if_acmpeq); + } + lbl.branch(); + } + } + final public void if_acmpne(Label lbl) { + countLabels = 0; + stackDepth -= 2; + if (this.wideMode) { + generateWideConditionalBranch(OPC_if_acmpne, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_if_acmpne; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_if_acmpne); + } + lbl.branch(); + } + } + final public void if_icmpeq(Label lbl) { + countLabels = 0; + stackDepth -= 2; + if (this.wideMode) { + generateWideConditionalBranch(OPC_if_icmpeq, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_if_icmpeq; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_if_icmpeq); + } + lbl.branch(); + } + } + final public void if_icmpge(Label lbl) { + countLabels = 0; + stackDepth -= 2; + if (this.wideMode) { + generateWideConditionalBranch(OPC_if_icmpge, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_if_icmpge; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_if_icmpge); + } + lbl.branch(); + } + } + final public void if_icmpgt(Label lbl) { + countLabels = 0; + stackDepth -= 2; + if (this.wideMode) { + generateWideConditionalBranch(OPC_if_icmpgt, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_if_icmpgt; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_if_icmpgt); + } + lbl.branch(); + } + } + final public void if_icmple(Label lbl) { + countLabels = 0; + stackDepth -= 2; + if (this.wideMode) { + generateWideConditionalBranch(OPC_if_icmple, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_if_icmple; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_if_icmple); + } + lbl.branch(); + } + } + final public void if_icmplt(Label lbl) { + countLabels = 0; + stackDepth -= 2; + if (this.wideMode) { + generateWideConditionalBranch(OPC_if_icmplt, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_if_icmplt; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_if_icmplt); + } + lbl.branch(); + } + } + final public void if_icmpne(Label lbl) { + countLabels = 0; + stackDepth -= 2; + if (this.wideMode) { + generateWideConditionalBranch(OPC_if_icmpne, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_if_icmpne; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_if_icmpne); + } + lbl.branch(); + } + } + final public void ifeq(Label lbl) { + countLabels = 0; + stackDepth--; + if (this.wideMode) { + generateWideConditionalBranch(OPC_ifeq, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_ifeq; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ifeq); + } + lbl.branch(); + } + } + final public void ifge(Label lbl) { + countLabels = 0; + stackDepth--; + if (this.wideMode) { + generateWideConditionalBranch(OPC_ifge, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_ifge; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ifge); + } + lbl.branch(); + } + } + final public void ifgt(Label lbl) { + countLabels = 0; + stackDepth--; + if (this.wideMode) { + generateWideConditionalBranch(OPC_ifgt, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_ifgt; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ifgt); + } + lbl.branch(); + } + } + final public void ifle(Label lbl) { + countLabels = 0; + stackDepth--; + if (this.wideMode) { + generateWideConditionalBranch(OPC_ifle, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_ifle; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ifle); + } + lbl.branch(); + } + } + final public void iflt(Label lbl) { + countLabels = 0; + stackDepth--; + if (this.wideMode) { + generateWideConditionalBranch(OPC_iflt, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_iflt; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iflt); + } + lbl.branch(); + } + } + final public void ifne(Label lbl) { + countLabels = 0; + stackDepth--; + if (this.wideMode) { + generateWideConditionalBranch(OPC_ifne, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_ifne; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ifne); + } + lbl.branch(); + } + } + final public void ifnonnull(Label lbl) { + countLabels = 0; + stackDepth--; + if (this.wideMode) { + generateWideConditionalBranch(OPC_ifnonnull, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_ifnonnull; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ifnonnull); + } + lbl.branch(); + } + } + final public void ifnull(Label lbl) { + countLabels = 0; + stackDepth--; + if (this.wideMode) { + generateWideConditionalBranch(OPC_ifnull, lbl); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_ifnull; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ifnull); + } + lbl.branch(); + } + } + final public void iinc(int index, int value) { + countLabels = 0; + if ((index > 255) || (value < -128 || value > 127)) { // have to widen + try { + position++; + bCodeStream[classFileOffset++] = OPC_wide; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_wide); + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_iinc; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iinc); + } + writeUnsignedShort(index); + writeSignedShort(value); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_iinc; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iinc); + } + writeUnsignedByte(index); + writeSignedByte(value); + } + } + final public void iload(int iArg) { + countLabels = 0; + stackDepth++; + if (maxLocals <= iArg) { + maxLocals = iArg + 1; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + if (iArg > 255) { // Widen + try { + position++; + bCodeStream[classFileOffset++] = OPC_wide; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_wide); + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_iload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iload); + } + writeUnsignedShort(iArg); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_iload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iload); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) iArg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) iArg); + } + } + } + final public void iload_0() { + countLabels = 0; + stackDepth++; + if (maxLocals <= 0) { + maxLocals = 1; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iload_0; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iload_0); + } + } + final public void iload_1() { + countLabels = 0; + stackDepth++; + if (maxLocals <= 1) { + maxLocals = 2; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iload_1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iload_1); + } + } + final public void iload_2() { + countLabels = 0; + stackDepth++; + if (maxLocals <= 2) { + maxLocals = 3; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iload_2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iload_2); + } + } + final public void iload_3() { + countLabels = 0; + stackDepth++; + if (maxLocals <= 3) { + maxLocals = 4; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iload_3; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iload_3); + } + } + final public void imul() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_imul; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_imul); + } + } + public void incrementTemp(LocalVariableBinding localBinding, int value) { + if (value == (short) value) { + this.iinc(localBinding.resolvedPosition, value); + return; + } + load(localBinding); + this.ldc(value); + this.iadd(); + store(localBinding, false); + } + public void incrStackSize(int offset) { + if ((stackDepth += offset) > stackMax) + stackMax = stackDepth; + } + public int indexOfSameLineEntrySincePC(int pc, int line) { + for (int index = pc, max = pcToSourceMapSize; index < max; index += 2) { + if (pcToSourceMap[index + 1] == line) + return index; + } + return -1; + } + final public void ineg() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_ineg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ineg); + } + } + public void init(ClassFile classFile) { + this.classFile = classFile; + this.constantPool = classFile.constantPool; + this.bCodeStream = classFile.contents; + this.classFileOffset = classFile.contentsOffset; + this.startingClassFileOffset = this.classFileOffset; + pcToSourceMapSize = 0; + lastEntryPC = 0; + int length = visibleLocals.length; + if (noVisibleLocals.length < length) { + noVisibleLocals = new LocalVariableBinding[length]; + } + System.arraycopy(noVisibleLocals, 0, visibleLocals, 0, length); + visibleLocalsCount = 0; - length = exceptionHandlers.length; - if (noExceptionHandlers.length < length) { - noExceptionHandlers = new ExceptionLabel[length]; - } - System.arraycopy(noExceptionHandlers, 0, exceptionHandlers, 0, length); - exceptionHandlersNumber = 0; - - length = labels.length; - if (noLabels.length < length) { - noLabels = new Label[length]; - } - System.arraycopy(noLabels, 0, labels, 0, length); - countLabels = 0; + length = locals.length; + if (noLocals.length < length) { + noLocals = new LocalVariableBinding[length]; + } + System.arraycopy(noLocals, 0, locals, 0, length); + allLocalsCounter = 0; - stackMax = 0; - stackDepth = 0; - maxLocals = 0; - position = 0; -} -/** - * @param methodDeclaration org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration - * @param classFile org.eclipse.jdt.internal.compiler.codegen.ClassFile - */ -public void initializeMaxLocals(MethodBinding methodBinding) { + length = exceptionHandlers.length; + if (noExceptionHandlers.length < length) { + noExceptionHandlers = new ExceptionLabel[length]; + } + System.arraycopy(noExceptionHandlers, 0, exceptionHandlers, 0, length); + exceptionHandlersNumber = 0; - maxLocals = (methodBinding == null || methodBinding.isStatic()) ? 0 : 1; - // take into account the synthetic parameters - if (methodBinding != null) { - if (methodBinding.isConstructor() && methodBinding.declaringClass.isNestedType()) { - ReferenceBinding enclosingInstanceTypes[]; - if ((enclosingInstanceTypes = methodBinding.declaringClass.syntheticEnclosingInstanceTypes()) != null) { - for (int i = 0, max = enclosingInstanceTypes.length; i < max; i++) { - maxLocals++; // an enclosingInstanceType can only be a reference binding. It cannot be - // LongBinding or DoubleBinding - } - } - SyntheticArgumentBinding syntheticArguments[]; - if ((syntheticArguments = methodBinding.declaringClass.syntheticOuterLocalVariables()) != null) { - for (int i = 0, max = syntheticArguments.length; i < max; i++) { - TypeBinding argType; - if (((argType = syntheticArguments[i].type) == LongBinding) || (argType == DoubleBinding)) { - maxLocals += 2; - } else { - maxLocals++; - } - } - } - } - TypeBinding[] arguments; - if ((arguments = methodBinding.parameters) != null) { - for (int i = 0, max = arguments.length; i < max; i++) { - TypeBinding argType; - if (((argType = arguments[i]) == LongBinding) || (argType == DoubleBinding)) { - maxLocals += 2; - } else { - maxLocals++; - } - } - } - } -} -/** - * This methods searches for an existing entry inside the pcToSourceMap table with a pc equals to @pc. - * If there is an existing entry it returns -1 (no insertion required). - * Otherwise it returns the index where the entry for the pc has to be inserted. - * This is based on the fact that the pcToSourceMap table is sorted according to the pc. - * - * @param int pc - * @return int - */ -public static int insertionIndex(int[] pcToSourceMap, int length, int pc) { - int g = 0; - int d = length - 2; - int m = 0; - while (g <= d) { - m = (g + d) / 2; - // we search only on even indexes - if ((m % 2) != 0) - m--; - int currentPC = pcToSourceMap[m]; - if (pc < currentPC) { - d = m - 2; - } else - if (pc > currentPC) { - g = m + 2; - } else { - return -1; - } - } - if (pc < pcToSourceMap[m]) - return m; - return m + 2; -} -/** - * We didn't call it instanceof because there is a conflit with the - * instanceof keyword - */ -final public void instance_of(TypeBinding typeBinding) { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_instanceof; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_instanceof); - } - writeUnsignedShort(constantPool.literalIndex(typeBinding)); -} -public void invokeClassForName() { - // invokestatic: java.lang.Class.forName(Ljava.lang.String;)Ljava.lang.Class; - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokestatic; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokestatic); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangClassForName()); -} + length = labels.length; + if (noLabels.length < length) { + noLabels = new Label[length]; + } + System.arraycopy(noLabels, 0, labels, 0, length); + countLabels = 0; -public void invokeJavaLangClassDesiredAssertionStatus() { - // invokevirtual: java.lang.Class.desiredAssertionStatus()Z; - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokevirtual; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokevirtual); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangClassDesiredAssertionStatus()); -} + stackMax = 0; + stackDepth = 0; + maxLocals = 0; + position = 0; + } + /** + * @param methodDeclaration org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration + * @param classFile org.eclipse.jdt.internal.compiler.codegen.ClassFile + */ + public void initializeMaxLocals(MethodBinding methodBinding) { -public void invokeConstructorGetConstructor() { - // invokevirtual: java.lang.Class.getConstructor(java.lang.Class[])Ljava.lang.reflect.Constructor; - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokevirtual; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokevirtual); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangClassGetConstructor()); -} -final public void invokeinterface(MethodBinding methodBinding) { - // initialized to 1 to take into account this immediately - countLabels = 0; - int argCount = 1; - int id; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokeinterface; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokeinterface); - } - writeUnsignedShort(constantPool.literalIndex(methodBinding)); - for (int i = methodBinding.parameters.length - 1; i >= 0; i--) - if (((id = methodBinding.parameters[i].id) == T_double) || (id == T_long)) - argCount += 2; - else - argCount += 1; - writeUnsignedByte(argCount); - // Generate a 0 into the byte array. Like the array is already fill with 0, we just need to increment - // the number of bytes. - position++; - classFileOffset++; - if (((id = methodBinding.returnType.id) == T_double) || (id == T_long)) - stackDepth += (2 - argCount); - else - if (id == T_void) - stackDepth -= argCount; - else - stackDepth += (1 - argCount); - if (stackDepth > stackMax) - stackMax = stackDepth; -} -public void invokeJavaLangErrorConstructor() { - // invokespecial: java.lang.Error(Ljava.lang.String;)V - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokespecial; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokespecial); - } - stackDepth -= 2; - writeUnsignedShort(constantPool.literalIndexForJavaLangErrorConstructor()); -} -public void invokeNoClassDefFoundErrorStringConstructor() { - // invokespecial: java.lang.NoClassDefFoundError.(Ljava.lang.String;)V - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokespecial; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokespecial); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangNoClassDefFoundErrorStringConstructor()); - stackDepth -= 2; -} -public void invokeObjectNewInstance() { - // invokevirtual: java.lang.reflect.Constructor.newInstance(java.lang.Object[])Ljava.lang.Object; - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokevirtual; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokevirtual); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangReflectConstructorNewInstance()); -} + maxLocals = (methodBinding == null || methodBinding.isStatic()) ? 0 : 1; + // take into account the synthetic parameters + if (methodBinding != null) { + if (methodBinding.isConstructor() && methodBinding.declaringClass.isNestedType()) { + ReferenceBinding enclosingInstanceTypes[]; + if ((enclosingInstanceTypes = methodBinding.declaringClass.syntheticEnclosingInstanceTypes()) != null) { + for (int i = 0, max = enclosingInstanceTypes.length; i < max; i++) { + maxLocals++; // an enclosingInstanceType can only be a reference binding. It cannot be + // LongBinding or DoubleBinding + } + } + SyntheticArgumentBinding syntheticArguments[]; + if ((syntheticArguments = methodBinding.declaringClass.syntheticOuterLocalVariables()) != null) { + for (int i = 0, max = syntheticArguments.length; i < max; i++) { + TypeBinding argType; + if (((argType = syntheticArguments[i].type) == LongBinding) || (argType == DoubleBinding)) { + maxLocals += 2; + } else { + maxLocals++; + } + } + } + } + TypeBinding[] arguments; + if ((arguments = methodBinding.parameters) != null) { + for (int i = 0, max = arguments.length; i < max; i++) { + TypeBinding argType; + if (((argType = arguments[i]) == LongBinding) || (argType == DoubleBinding)) { + maxLocals += 2; + } else { + maxLocals++; + } + } + } + } + } + /** + * This methods searches for an existing entry inside the pcToSourceMap table with a pc equals to @pc. + * If there is an existing entry it returns -1 (no insertion required). + * Otherwise it returns the index where the entry for the pc has to be inserted. + * This is based on the fact that the pcToSourceMap table is sorted according to the pc. + * + * @param int pc + * @return int + */ + public static int insertionIndex(int[] pcToSourceMap, int length, int pc) { + int g = 0; + int d = length - 2; + int m = 0; + while (g <= d) { + m = (g + d) / 2; + // we search only on even indexes + if ((m % 2) != 0) + m--; + int currentPC = pcToSourceMap[m]; + if (pc < currentPC) { + d = m - 2; + } else if (pc > currentPC) { + g = m + 2; + } else { + return -1; + } + } + if (pc < pcToSourceMap[m]) + return m; + return m + 2; + } + /** + * We didn't call it instanceof because there is a conflit with the + * instanceof keyword + */ + final public void instance_of(TypeBinding typeBinding) { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_instanceof; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_instanceof); + } + writeUnsignedShort(constantPool.literalIndex(typeBinding)); + } + public void invokeClassForName() { + // invokestatic: java.lang.Class.forName(Ljava.lang.String;)Ljava.lang.Class; + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokestatic; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokestatic); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangClassForName()); + } -public void invokeObjectGetClass() { - // invokevirtual: java.lang.Object.getClass()Ljava.lang.Class; - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokevirtual; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokevirtual); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangObjectGetClass()); -} + public void invokeJavaLangClassDesiredAssertionStatus() { + // invokevirtual: java.lang.Class.desiredAssertionStatus()Z; + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokevirtual; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokevirtual); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangClassDesiredAssertionStatus()); + } -final public void invokespecial(MethodBinding methodBinding) { - // initialized to 1 to take into account this immediately - countLabels = 0; - int argCount = 1; - int id; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokespecial; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokespecial); - } - writeUnsignedShort(constantPool.literalIndex(methodBinding)); - if (methodBinding.isConstructor() && methodBinding.declaringClass.isNestedType()) { - // enclosing instances - TypeBinding[] syntheticArgumentTypes = methodBinding.declaringClass.syntheticEnclosingInstanceTypes(); - if (syntheticArgumentTypes != null) { - for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) { - if (((id = syntheticArgumentTypes[i].id) == T_double) || (id == T_long)) { - argCount += 2; - } else { - argCount++; - } - } - } - // outer local variables - SyntheticArgumentBinding[] syntheticArguments = methodBinding.declaringClass.syntheticOuterLocalVariables(); - if (syntheticArguments != null) { - for (int i = 0, max = syntheticArguments.length; i < max; i++) { - if (((id = syntheticArguments[i].type.id) == T_double) || (id == T_long)) { - argCount += 2; - } else { - argCount++; - } - } - } - } - for (int i = methodBinding.parameters.length - 1; i >= 0; i--) - if (((id = methodBinding.parameters[i].id) == T_double) || (id == T_long)) - argCount += 2; - else - argCount++; - if (((id = methodBinding.returnType.id) == T_double) || (id == T_long)) - stackDepth += (2 - argCount); - else - if (id == T_void) - stackDepth -= argCount; - else - stackDepth += (1 - argCount); - if (stackDepth > stackMax) - stackMax = stackDepth; -} -final public void invokestatic(MethodBinding methodBinding) { - // initialized to 0 to take into account that there is no this for - // a static method - countLabels = 0; - int argCount = 0; - int id; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokestatic; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokestatic); - } - writeUnsignedShort(constantPool.literalIndex(methodBinding)); - for (int i = methodBinding.parameters.length - 1; i >= 0; i--) - if (((id = methodBinding.parameters[i].id) == T_double) || (id == T_long)) - argCount += 2; - else - argCount += 1; - if (((id = methodBinding.returnType.id) == T_double) || (id == T_long)) - stackDepth += (2 - argCount); - else - if (id == T_void) - stackDepth -= argCount; - else - stackDepth += (1 - argCount); - if (stackDepth > stackMax) - stackMax = stackDepth; -} -/** - * The equivalent code performs a string conversion of the TOS - * @param typeID int - */ -public void invokeStringBufferAppendForType(int typeID) { - countLabels = 0; - int usedTypeID; - if (typeID == T_null) - usedTypeID = T_String; - else - usedTypeID = typeID; - // invokevirtual - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokevirtual; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokevirtual); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangStringBufferAppend(typeID)); - if ((usedTypeID == T_long) || (usedTypeID == T_double)) - stackDepth -= 2; - else - stackDepth--; -} + public void invokeConstructorGetConstructor() { + // invokevirtual: java.lang.Class.getConstructor(java.lang.Class[])Ljava.lang.reflect.Constructor; + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokevirtual; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokevirtual); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangClassGetConstructor()); + } + final public void invokeinterface(MethodBinding methodBinding) { + // initialized to 1 to take into account this immediately + countLabels = 0; + int argCount = 1; + int id; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokeinterface; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokeinterface); + } + writeUnsignedShort(constantPool.literalIndex(methodBinding)); + for (int i = methodBinding.parameters.length - 1; i >= 0; i--) + if (((id = methodBinding.parameters[i].id) == T_double) || (id == T_long)) + argCount += 2; + else + argCount += 1; + writeUnsignedByte(argCount); + // Generate a 0 into the byte array. Like the array is already fill with 0, we just need to increment + // the number of bytes. + position++; + classFileOffset++; + if (((id = methodBinding.returnType.id) == T_double) || (id == T_long)) + stackDepth += (2 - argCount); + else if (id == T_void) + stackDepth -= argCount; + else + stackDepth += (1 - argCount); + if (stackDepth > stackMax) + stackMax = stackDepth; + } + public void invokeJavaLangErrorConstructor() { + // invokespecial: java.lang.Error(Ljava.lang.String;)V + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokespecial; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokespecial); + } + stackDepth -= 2; + writeUnsignedShort(constantPool.literalIndexForJavaLangErrorConstructor()); + } + public void invokeNoClassDefFoundErrorStringConstructor() { + // invokespecial: java.lang.NoClassDefFoundError.(Ljava.lang.String;)V + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokespecial; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokespecial); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangNoClassDefFoundErrorStringConstructor()); + stackDepth -= 2; + } + public void invokeObjectNewInstance() { + // invokevirtual: java.lang.reflect.Constructor.newInstance(java.lang.Object[])Ljava.lang.Object; + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokevirtual; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokevirtual); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangReflectConstructorNewInstance()); + } -public void invokeJavaLangAssertionErrorConstructor(int typeBindingID) { - // invokespecial: java.lang.AssertionError.(typeBindingID)V - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokespecial; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokespecial); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangAssertionErrorConstructor(typeBindingID)); - stackDepth -= 2; -} + public void invokeObjectGetClass() { + // invokevirtual: java.lang.Object.getClass()Ljava.lang.Class; + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokevirtual; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokevirtual); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangObjectGetClass()); + } -public void invokeJavaLangAssertionErrorDefaultConstructor() { - // invokespecial: java.lang.AssertionError.()V - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokespecial; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokespecial); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangAssertionErrorDefaultConstructor()); - stackDepth --; -} + final public void invokespecial(MethodBinding methodBinding) { + // initialized to 1 to take into account this immediately + countLabels = 0; + int argCount = 1; + int id; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokespecial; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokespecial); + } + writeUnsignedShort(constantPool.literalIndex(methodBinding)); + if (methodBinding.isConstructor() && methodBinding.declaringClass.isNestedType()) { + // enclosing instances + TypeBinding[] syntheticArgumentTypes = methodBinding.declaringClass.syntheticEnclosingInstanceTypes(); + if (syntheticArgumentTypes != null) { + for (int i = 0, max = syntheticArgumentTypes.length; i < max; i++) { + if (((id = syntheticArgumentTypes[i].id) == T_double) || (id == T_long)) { + argCount += 2; + } else { + argCount++; + } + } + } + // outer local variables + SyntheticArgumentBinding[] syntheticArguments = methodBinding.declaringClass.syntheticOuterLocalVariables(); + if (syntheticArguments != null) { + for (int i = 0, max = syntheticArguments.length; i < max; i++) { + if (((id = syntheticArguments[i].type.id) == T_double) || (id == T_long)) { + argCount += 2; + } else { + argCount++; + } + } + } + } + for (int i = methodBinding.parameters.length - 1; i >= 0; i--) + if (((id = methodBinding.parameters[i].id) == T_double) || (id == T_long)) + argCount += 2; + else + argCount++; + if (((id = methodBinding.returnType.id) == T_double) || (id == T_long)) + stackDepth += (2 - argCount); + else if (id == T_void) + stackDepth -= argCount; + else + stackDepth += (1 - argCount); + if (stackDepth > stackMax) + stackMax = stackDepth; + } + final public void invokestatic(MethodBinding methodBinding) { + // initialized to 0 to take into account that there is no this for + // a static method + countLabels = 0; + int argCount = 0; + int id; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokestatic; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokestatic); + } + writeUnsignedShort(constantPool.literalIndex(methodBinding)); + for (int i = methodBinding.parameters.length - 1; i >= 0; i--) + if (((id = methodBinding.parameters[i].id) == T_double) || (id == T_long)) + argCount += 2; + else + argCount += 1; + if (((id = methodBinding.returnType.id) == T_double) || (id == T_long)) + stackDepth += (2 - argCount); + else if (id == T_void) + stackDepth -= argCount; + else + stackDepth += (1 - argCount); + if (stackDepth > stackMax) + stackMax = stackDepth; + } + /** + * The equivalent code performs a string conversion of the TOS + * @param typeID int + */ + public void invokeStringBufferAppendForType(int typeID) { + countLabels = 0; + int usedTypeID; + if (typeID == T_null) + usedTypeID = T_String; + else + usedTypeID = typeID; + // invokevirtual + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokevirtual; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokevirtual); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangStringBufferAppend(typeID)); + if ((usedTypeID == T_long) || (usedTypeID == T_double)) + stackDepth -= 2; + else + stackDepth--; + } -public void invokeStringBufferDefaultConstructor() { - // invokespecial: java.lang.StringBuffer.()V - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokespecial; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokespecial); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangStringBufferDefaultConstructor()); - stackDepth--; -} -public void invokeStringBufferStringConstructor() { - // invokespecial: java.lang.StringBuffer.(Ljava.lang.String;)V - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokespecial; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokespecial); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangStringBufferConstructor()); - stackDepth -= 2; -} + public void invokeJavaLangAssertionErrorConstructor(int typeBindingID) { + // invokespecial: java.lang.AssertionError.(typeBindingID)V + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokespecial; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokespecial); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangAssertionErrorConstructor(typeBindingID)); + stackDepth -= 2; + } -public void invokeStringBufferToString() { - // invokevirtual: StringBuffer.toString()Ljava.lang.String; - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokevirtual; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokevirtual); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangStringBufferToString()); -} -public void invokeStringIntern() { - // invokevirtual: java.lang.String.intern() - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokevirtual; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokevirtual); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangStringIntern()); -} -public void invokeStringValueOf(int typeID) { - // invokestatic: java.lang.String.valueOf(argumentType) - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokestatic; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokestatic); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangStringValueOf(typeID)); -} -public void invokeSystemExit() { - // invokestatic: java.lang.System.exit(I) - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokestatic; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokestatic); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangSystemExitInt()); - stackDepth--; // int argument -} -public void invokeThrowableGetMessage() { - // invokevirtual: java.lang.Throwable.getMessage()Ljava.lang.String; - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokevirtual; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokevirtual); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangThrowableGetMessage()); -} -final public void invokevirtual(MethodBinding methodBinding) { - // initialized to 1 to take into account this immediately - countLabels = 0; - int argCount = 1; - int id; - try { - position++; - bCodeStream[classFileOffset++] = OPC_invokevirtual; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_invokevirtual); - } - writeUnsignedShort(constantPool.literalIndex(methodBinding)); - for (int i = methodBinding.parameters.length - 1; i >= 0; i--) - if (((id = methodBinding.parameters[i].id) == T_double) || (id == T_long)) - argCount += 2; - else - argCount++; - if (((id = methodBinding.returnType.id) == T_double) || (id == T_long)) - stackDepth += (2 - argCount); - else - if (id == T_void) - stackDepth -= argCount; - else - stackDepth += (1 - argCount); - if (stackDepth > stackMax) - stackMax = stackDepth; -} -final public void ior() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_ior; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ior); - } -} -final public void irem() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_irem; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_irem); - } -} -final public void ireturn() { - countLabels = 0; - stackDepth--; - // the stackDepth should be equal to 0 - try { - position++; - bCodeStream[classFileOffset++] = OPC_ireturn; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ireturn); - } -} -public boolean isDefinitelyAssigned(Scope scope, int initStateIndex, LocalVariableBinding local) { - // Dependant of UnconditionalFlowInfo.isDefinitelyAssigned(..) - if (initStateIndex == -1) - return false; - if (local.isArgument) { - return true; - } - int position = local.id + maxFieldCount; - MethodScope methodScope = scope.methodScope(); - // id is zero-based - if (position < UnconditionalFlowInfo.BitCacheSize) { - return (methodScope.definiteInits[initStateIndex] & (1L << position)) != 0; // use bits - } - // use extra vector - long[] extraInits = methodScope.extraDefiniteInits[initStateIndex]; - if (extraInits == null) - return false; // if vector not yet allocated, then not initialized - int vectorIndex; - if ((vectorIndex = (position / UnconditionalFlowInfo.BitCacheSize) - 1) >= extraInits.length) - return false; // if not enough room in vector, then not initialized - return ((extraInits[vectorIndex]) & (1L << (position % UnconditionalFlowInfo.BitCacheSize))) != 0; -} -final public void ishl() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_ishl; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ishl); - } -} -final public void ishr() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_ishr; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ishr); - } -} -final public void istore(int iArg) { - countLabels = 0; - stackDepth--; - if (maxLocals <= iArg) { - maxLocals = iArg + 1; - } - if (iArg > 255) { // Widen - try { - position++; - bCodeStream[classFileOffset++] = OPC_wide; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_wide); - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_istore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_istore); - } - writeUnsignedShort(iArg); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_istore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_istore); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) iArg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) iArg); - } - } -} -final public void istore_0() { - countLabels = 0; - stackDepth--; - if (maxLocals == 0) { - maxLocals = 1; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_istore_0; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_istore_0); - } -} -final public void istore_1() { - countLabels = 0; - stackDepth--; - if (maxLocals <= 1) { - maxLocals = 2; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_istore_1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_istore_1); - } -} -final public void istore_2() { - countLabels = 0; - stackDepth--; - if (maxLocals <= 2) { - maxLocals = 3; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_istore_2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_istore_2); - } -} -final public void istore_3() { - countLabels = 0; - stackDepth--; - if (maxLocals <= 3) { - maxLocals = 4; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_istore_3; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_istore_3); - } -} -final public void isub() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_isub; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_isub); - } -} -final public void iushr() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_iushr; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_iushr); - } -} -final public void ixor() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_ixor; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ixor); - } -} -final public void jsr(Label lbl) { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_jsr; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_jsr); - } - lbl.branch(); -} -final public void jsr_w(Label lbl) { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_jsr_w; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_jsr_w); - } - lbl.branchWide(); -} -final public void l2d() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_l2d; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_l2d); - } -} -final public void l2f() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_l2f; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_l2f); - } -} -final public void l2i() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_l2i; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_l2i); - } -} -final public void ladd() { - countLabels = 0; - stackDepth -= 2; - try { - position++; - bCodeStream[classFileOffset++] = OPC_ladd; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ladd); - } -} -final public void laload() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_laload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_laload); - } -} -final public void land() { - countLabels = 0; - stackDepth -= 2; - try { - position++; - bCodeStream[classFileOffset++] = OPC_land; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_land); - } -} -final public void lastore() { - countLabels = 0; - stackDepth -= 4; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lastore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lastore); - } -} -final public void lcmp() { - countLabels = 0; - stackDepth -= 3; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lcmp; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lcmp); - } -} -final public void lconst_0() { - countLabels = 0; - stackDepth += 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lconst_0; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lconst_0); - } -} -final public void lconst_1() { - countLabels = 0; - stackDepth += 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lconst_1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lconst_1); - } -} -final public void ldc(float constant) { - countLabels = 0; - int index = constantPool.literalIndex(constant); - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (index > 255) { - // Generate a ldc_w - try { - position++; - bCodeStream[classFileOffset++] = OPC_ldc_w; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ldc_w); - } - writeUnsignedShort(index); - } else { - // Generate a ldc - try { - position++; - bCodeStream[classFileOffset++] = OPC_ldc; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ldc); - } - writeUnsignedByte(index); - } -} -final public void ldc(int constant) { - countLabels = 0; - int index = constantPool.literalIndex(constant); - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (index > 255) { - // Generate a ldc_w - try { - position++; - bCodeStream[classFileOffset++] = OPC_ldc_w; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ldc_w); - } - writeUnsignedShort(index); - } else { - // Generate a ldc - try { - position++; - bCodeStream[classFileOffset++] = OPC_ldc; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ldc); - } - writeUnsignedByte(index); - } -} -final public void ldc(String constant) { - countLabels = 0; - int currentConstantPoolIndex = constantPool.currentIndex; - int currentConstantPoolOffset = constantPool.currentOffset; - int currentCodeStreamPosition = position; - int index = constantPool.literalIndexForLdc(constant.toCharArray()); - if (index > 0) { - // the string already exists inside the constant pool - // we reuse the same index - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (index > 255) { - // Generate a ldc_w - try { - position++; - bCodeStream[classFileOffset++] = OPC_ldc_w; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ldc_w); - } - writeUnsignedShort(index); - } else { - // Generate a ldc - try { - position++; - bCodeStream[classFileOffset++] = OPC_ldc; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ldc); - } - writeUnsignedByte(index); - } - } else { - // the string is too big to be utf8-encoded in one pass. - // we have to split it into different pieces. - // first we clean all side-effects due to the code above - // this case is very rare, so we can afford to lose time to handle it - char[] constantChars = constant.toCharArray(); - position = currentCodeStreamPosition; - constantPool.currentIndex = currentConstantPoolIndex; - constantPool.currentOffset = currentConstantPoolOffset; - constantPool.stringCache.remove(constantChars); - constantPool.UTF8Cache.remove(constantChars); - int i = 0; - int length = 0; - int constantLength = constant.length(); - byte[] utf8encoding = new byte[Math.min(constantLength + 100, 65535)]; - int utf8encodingLength = 0; - while ((length < 65532) && (i < constantLength)) { - char current = constantChars[i]; - // we resize the byte array immediately if necessary - if (length + 3 > (utf8encodingLength = utf8encoding.length)) { - System.arraycopy(utf8encoding, 0, (utf8encoding = new byte[Math.min(utf8encodingLength + 100, 65535)]), 0, length); - } - if ((current >= 0x0001) && (current <= 0x007F)) { - // we only need one byte: ASCII table - utf8encoding[length++] = (byte) current; - } else { - if (current > 0x07FF) { - // we need 3 bytes - utf8encoding[length++] = (byte) (0xE0 | ((current >> 12) & 0x0F)); // 0xE0 = 1110 0000 - utf8encoding[length++] = (byte) (0x80 | ((current >> 6) & 0x3F)); // 0x80 = 1000 0000 - utf8encoding[length++] = (byte) (0x80 | (current & 0x3F)); // 0x80 = 1000 0000 - } else { - // we can be 0 or between 0x0080 and 0x07FF - // In that case we only need 2 bytes - utf8encoding[length++] = (byte) (0xC0 | ((current >> 6) & 0x1F)); // 0xC0 = 1100 0000 - utf8encoding[length++] = (byte) (0x80 | (current & 0x3F)); // 0x80 = 1000 0000 - } - } - i++; - } - // check if all the string is encoded (PR 1PR2DWJ) - // the string is too big to be encoded in one pass - newStringBuffer(); - dup(); - // write the first part - char[] subChars = new char[i]; - System.arraycopy(constantChars, 0, subChars, 0, i); - System.arraycopy(utf8encoding, 0, (utf8encoding = new byte[length]), 0, length); - index = constantPool.literalIndex(subChars, utf8encoding); - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (index > 255) { - // Generate a ldc_w - try { - position++; - bCodeStream[classFileOffset++] = OPC_ldc_w; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ldc_w); - } - writeUnsignedShort(index); - } else { - // Generate a ldc - try { - position++; - bCodeStream[classFileOffset++] = OPC_ldc; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ldc); - } - writeUnsignedByte(index); - } - // write the remaining part - invokeStringBufferStringConstructor(); - while (i < constantLength) { - length = 0; - utf8encoding = new byte[Math.min(constantLength - i + 100, 65535)]; - int startIndex = i; - while ((length < 65532) && (i < constantLength)) { - char current = constantChars[i]; - // we resize the byte array immediately if necessary - if (constantLength + 2 > (utf8encodingLength = utf8encoding.length)) { - System.arraycopy(utf8encoding, 0, (utf8encoding = new byte[Math.min(utf8encodingLength + 100, 65535)]), 0, length); - } - if ((current >= 0x0001) && (current <= 0x007F)) { - // we only need one byte: ASCII table - utf8encoding[length++] = (byte) current; - } else { - if (current > 0x07FF) { - // we need 3 bytes - utf8encoding[length++] = (byte) (0xE0 | ((current >> 12) & 0x0F)); // 0xE0 = 1110 0000 - utf8encoding[length++] = (byte) (0x80 | ((current >> 6) & 0x3F)); // 0x80 = 1000 0000 - utf8encoding[length++] = (byte) (0x80 | (current & 0x3F)); // 0x80 = 1000 0000 - } else { - // we can be 0 or between 0x0080 and 0x07FF - // In that case we only need 2 bytes - utf8encoding[length++] = (byte) (0xC0 | ((current >> 6) & 0x1F)); // 0xC0 = 1100 0000 - utf8encoding[length++] = (byte) (0x80 | (current & 0x3F)); // 0x80 = 1000 0000 - } - } - i++; - } - // the next part is done - subChars = new char[i - startIndex]; - System.arraycopy(constantChars, startIndex, subChars, 0, i - startIndex); - System.arraycopy(utf8encoding, 0, (utf8encoding = new byte[length]), 0, length); - index = constantPool.literalIndex(subChars, utf8encoding); - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - if (index > 255) { - // Generate a ldc_w - try { - position++; - bCodeStream[classFileOffset++] = OPC_ldc_w; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ldc_w); - } - writeUnsignedShort(index); - } else { - // Generate a ldc - try { - position++; - bCodeStream[classFileOffset++] = OPC_ldc; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ldc); - } - writeUnsignedByte(index); - } - // now on the stack it should be a StringBuffer and a string. - invokeStringBufferAppendForType(T_String); - } - invokeStringBufferToString(); - invokeStringIntern(); - } -} -final public void ldc2_w(double constant) { - countLabels = 0; - int index = constantPool.literalIndex(constant); - stackDepth += 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - // Generate a ldc2_w - try { - position++; - bCodeStream[classFileOffset++] = OPC_ldc2_w; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ldc2_w); - } - writeUnsignedShort(index); -} -final public void ldc2_w(long constant) { - countLabels = 0; - int index = constantPool.literalIndex(constant); - stackDepth += 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - // Generate a ldc2_w - try { - position++; - bCodeStream[classFileOffset++] = OPC_ldc2_w; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ldc2_w); - } - writeUnsignedShort(index); -} -final public void ldiv() { - countLabels = 0; - stackDepth -= 2; - try { - position++; - bCodeStream[classFileOffset++] = OPC_ldiv; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ldiv); - } -} -final public void lload(int iArg) { - countLabels = 0; - stackDepth += 2; - if (maxLocals <= iArg + 1) { - maxLocals = iArg + 2; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - if (iArg > 255) { // Widen - try { - position++; - bCodeStream[classFileOffset++] = OPC_wide; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_wide); - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_lload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lload); - } - writeUnsignedShort(iArg); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_lload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lload); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) iArg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) iArg); - } - } -} -final public void lload_0() { - countLabels = 0; - stackDepth += 2; - if (maxLocals < 2) { - maxLocals = 2; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lload_0; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lload_0); - } -} -final public void lload_1() { - countLabels = 0; - stackDepth += 2; - if (maxLocals < 3) { - maxLocals = 3; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lload_1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lload_1); - } -} -final public void lload_2() { - countLabels = 0; - stackDepth += 2; - if (maxLocals < 4) { - maxLocals = 4; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lload_2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lload_2); - } -} -final public void lload_3() { - countLabels = 0; - stackDepth += 2; - if (maxLocals < 5) { - maxLocals = 5; - } - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lload_3; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lload_3); - } -} -final public void lmul() { - countLabels = 0; - stackDepth -= 2; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lmul; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lmul); - } -} -final public void lneg() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lneg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lneg); - } -} -public final void load(LocalVariableBinding localBinding) { - countLabels = 0; - TypeBinding typeBinding = localBinding.type; - int resolvedPosition = localBinding.resolvedPosition; - // Using dedicated int bytecode - if (typeBinding == IntBinding) { - switch (resolvedPosition) { - case 0 : - this.iload_0(); - break; - case 1 : - this.iload_1(); - break; - case 2 : - this.iload_2(); - break; - case 3 : - this.iload_3(); - break; - default : - this.iload(resolvedPosition); - } - return; - } - // Using dedicated float bytecode - if (typeBinding == FloatBinding) { - switch (resolvedPosition) { - case 0 : - this.fload_0(); - break; - case 1 : - this.fload_1(); - break; - case 2 : - this.fload_2(); - break; - case 3 : - this.fload_3(); - break; - default : - this.fload(resolvedPosition); - } - return; - } - // Using dedicated long bytecode - if (typeBinding == LongBinding) { - switch (resolvedPosition) { - case 0 : - this.lload_0(); - break; - case 1 : - this.lload_1(); - break; - case 2 : - this.lload_2(); - break; - case 3 : - this.lload_3(); - break; - default : - this.lload(resolvedPosition); - } - return; - } - // Using dedicated double bytecode - if (typeBinding == DoubleBinding) { - switch (resolvedPosition) { - case 0 : - this.dload_0(); - break; - case 1 : - this.dload_1(); - break; - case 2 : - this.dload_2(); - break; - case 3 : - this.dload_3(); - break; - default : - this.dload(resolvedPosition); - } - return; - } - // boolean, byte, char and short are handled as int - if ((typeBinding == ByteBinding) || (typeBinding == CharBinding) || (typeBinding == BooleanBinding) || (typeBinding == ShortBinding)) { - switch (resolvedPosition) { - case 0 : - this.iload_0(); - break; - case 1 : - this.iload_1(); - break; - case 2 : - this.iload_2(); - break; - case 3 : - this.iload_3(); - break; - default : - this.iload(resolvedPosition); - } - return; - } + public void invokeJavaLangAssertionErrorDefaultConstructor() { + // invokespecial: java.lang.AssertionError.()V + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokespecial; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokespecial); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangAssertionErrorDefaultConstructor()); + stackDepth--; + } - // Reference object - switch (resolvedPosition) { - case 0 : - this.aload_0(); - break; - case 1 : - this.aload_1(); - break; - case 2 : - this.aload_2(); - break; - case 3 : - this.aload_3(); - break; - default : - this.aload(resolvedPosition); - } -} -public final void load(TypeBinding typeBinding, int resolvedPosition) { - countLabels = 0; - // Using dedicated int bytecode - if (typeBinding == IntBinding) { - switch (resolvedPosition) { - case 0 : - this.iload_0(); - break; - case 1 : - this.iload_1(); - break; - case 2 : - this.iload_2(); - break; - case 3 : - this.iload_3(); - break; - default : - this.iload(resolvedPosition); - } - return; - } - // Using dedicated float bytecode - if (typeBinding == FloatBinding) { - switch (resolvedPosition) { - case 0 : - this.fload_0(); - break; - case 1 : - this.fload_1(); - break; - case 2 : - this.fload_2(); - break; - case 3 : - this.fload_3(); - break; - default : - this.fload(resolvedPosition); - } - return; - } - // Using dedicated long bytecode - if (typeBinding == LongBinding) { - switch (resolvedPosition) { - case 0 : - this.lload_0(); - break; - case 1 : - this.lload_1(); - break; - case 2 : - this.lload_2(); - break; - case 3 : - this.lload_3(); - break; - default : - this.lload(resolvedPosition); - } - return; - } - // Using dedicated double bytecode - if (typeBinding == DoubleBinding) { - switch (resolvedPosition) { - case 0 : - this.dload_0(); - break; - case 1 : - this.dload_1(); - break; - case 2 : - this.dload_2(); - break; - case 3 : - this.dload_3(); - break; - default : - this.dload(resolvedPosition); - } - return; - } - // boolean, byte, char and short are handled as int - if ((typeBinding == ByteBinding) || (typeBinding == CharBinding) || (typeBinding == BooleanBinding) || (typeBinding == ShortBinding)) { - switch (resolvedPosition) { - case 0 : - this.iload_0(); - break; - case 1 : - this.iload_1(); - break; - case 2 : - this.iload_2(); - break; - case 3 : - this.iload_3(); - break; - default : - this.iload(resolvedPosition); - } - return; - } + public void invokeStringBufferDefaultConstructor() { + // invokespecial: java.lang.StringBuffer.()V + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokespecial; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokespecial); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangStringBufferDefaultConstructor()); + stackDepth--; + } + public void invokeStringBufferStringConstructor() { + // invokespecial: java.lang.StringBuffer.(Ljava.lang.String;)V + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokespecial; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokespecial); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangStringBufferConstructor()); + stackDepth -= 2; + } - // Reference object - switch (resolvedPosition) { - case 0 : - this.aload_0(); - break; - case 1 : - this.aload_1(); - break; - case 2 : - this.aload_2(); - break; - case 3 : - this.aload_3(); - break; - default : - this.aload(resolvedPosition); - } -} -public final void loadInt(int resolvedPosition) { - // Using dedicated int bytecode - switch (resolvedPosition) { - case 0 : - this.iload_0(); - break; - case 1 : - this.iload_1(); - break; - case 2 : - this.iload_2(); - break; - case 3 : - this.iload_3(); - break; - default : - this.iload(resolvedPosition); - } -} -public final void loadObject(int resolvedPosition) { - switch (resolvedPosition) { - case 0 : - this.aload_0(); - break; - case 1 : - this.aload_1(); - break; - case 2 : - this.aload_2(); - break; - case 3 : - this.aload_3(); - break; - default : - this.aload(resolvedPosition); - } -} -final public void lookupswitch(CaseLabel defaultLabel, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel) { - countLabels = 0; - stackDepth--; - int length = keys.length; - int pos = position; - defaultLabel.placeInstruction(); - for (int i = 0; i < length; i++) { - casesLabel[i].placeInstruction(); - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_lookupswitch; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lookupswitch); - } - for (int i = (3 - (pos % 4)); i > 0; i--) { - position++; // Padding - classFileOffset++; - } - defaultLabel.branch(); - writeSignedWord(length); - for (int i = 0; i < length; i++) { - writeSignedWord(keys[sortedIndexes[i]]); - casesLabel[sortedIndexes[i]].branch(); - } -} -final public void lor() { - countLabels = 0; - stackDepth -= 2; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lor; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lor); - } -} -final public void lrem() { - countLabels = 0; - stackDepth -= 2; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lrem; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lrem); - } -} -final public void lreturn() { - countLabels = 0; - stackDepth -= 2; - // the stackDepth should be equal to 0 - try { - position++; - bCodeStream[classFileOffset++] = OPC_lreturn; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lreturn); - } -} -final public void lshl() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lshl; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lshl); - } -} -final public void lshr() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lshr; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lshr); - } -} -final public void lstore(int iArg) { - countLabels = 0; - stackDepth -= 2; - if (maxLocals <= iArg + 1) { - maxLocals = iArg + 2; - } - if (iArg > 255) { // Widen - try { - position++; - bCodeStream[classFileOffset++] = OPC_wide; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_wide); - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_lstore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lstore); - } - writeUnsignedShort(iArg); - } else { - try { - position++; - bCodeStream[classFileOffset++] = OPC_lstore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lstore); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) iArg; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) iArg); - } - } -} -final public void lstore_0() { - countLabels = 0; - stackDepth -= 2; - if (maxLocals < 2) { - maxLocals = 2; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_lstore_0; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lstore_0); - } -} -final public void lstore_1() { - countLabels = 0; - stackDepth -= 2; - if (maxLocals < 3) { - maxLocals = 3; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_lstore_1; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lstore_1); - } -} -final public void lstore_2() { - countLabels = 0; - stackDepth -= 2; - if (maxLocals < 4) { - maxLocals = 4; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_lstore_2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lstore_2); - } -} -final public void lstore_3() { - countLabels = 0; - stackDepth -= 2; - if (maxLocals < 5) { - maxLocals = 5; - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_lstore_3; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lstore_3); - } -} -final public void lsub() { - countLabels = 0; - stackDepth -= 2; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lsub; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lsub); - } -} -final public void lushr() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lushr; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lushr); - } -} -final public void lxor() { - countLabels = 0; - stackDepth -= 2; - try { - position++; - bCodeStream[classFileOffset++] = OPC_lxor; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_lxor); - } -} -final public void monitorenter() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_monitorenter; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_monitorenter); - } -} -final public void monitorexit() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_monitorexit; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_monitorexit); - } -} -final public void multianewarray(TypeBinding typeBinding, int dimensions) { - countLabels = 0; - stackDepth += (1 - dimensions); - try { - position++; - bCodeStream[classFileOffset++] = OPC_multianewarray; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_multianewarray); - } - writeUnsignedShort(constantPool.literalIndex(typeBinding)); - writeUnsignedByte(dimensions); -} -public static void needImplementation() { -} -/** - * We didn't call it new, because there is a conflit with the new keyword - */ -final public void new_(TypeBinding typeBinding) { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_new; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_new); - } - writeUnsignedShort(constantPool.literalIndex(typeBinding)); -} -final public void newarray(int array_Type) { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_newarray; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_newarray); - } - writeUnsignedByte(array_Type); -} -public void newArray(Scope scope, ArrayBinding arrayBinding) { - TypeBinding component = arrayBinding.elementsType(scope); - switch (component.id) { - case T_int : - this.newarray(10); - break; - case T_byte : - this.newarray(8); - break; - case T_boolean : - this.newarray(4); - break; - case T_short : - this.newarray(9); - break; - case T_char : - this.newarray(5); - break; - case T_long : - this.newarray(11); - break; - case T_float : - this.newarray(6); - break; - case T_double : - this.newarray(7); - break; - default : - this.anewarray(component); - } -} -public void newJavaLangError() { - // new: java.lang.Error - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_new; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_new); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangError()); -} + public void invokeStringBufferToString() { + // invokevirtual: StringBuffer.toString()Ljava.lang.String; + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokevirtual; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokevirtual); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangStringBufferToString()); + } + public void invokeStringIntern() { + // invokevirtual: java.lang.String.intern() + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokevirtual; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokevirtual); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangStringIntern()); + } + public void invokeStringValueOf(int typeID) { + // invokestatic: java.lang.String.valueOf(argumentType) + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokestatic; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokestatic); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangStringValueOf(typeID)); + } + public void invokeSystemExit() { + // invokestatic: java.lang.System.exit(I) + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokestatic; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokestatic); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangSystemExitInt()); + stackDepth--; // int argument + } + public void invokeThrowableGetMessage() { + // invokevirtual: java.lang.Throwable.getMessage()Ljava.lang.String; + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokevirtual; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokevirtual); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangThrowableGetMessage()); + } + final public void invokevirtual(MethodBinding methodBinding) { + // initialized to 1 to take into account this immediately + countLabels = 0; + int argCount = 1; + int id; + try { + position++; + bCodeStream[classFileOffset++] = OPC_invokevirtual; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_invokevirtual); + } + writeUnsignedShort(constantPool.literalIndex(methodBinding)); + for (int i = methodBinding.parameters.length - 1; i >= 0; i--) + if (((id = methodBinding.parameters[i].id) == T_double) || (id == T_long)) + argCount += 2; + else + argCount++; + if (((id = methodBinding.returnType.id) == T_double) || (id == T_long)) + stackDepth += (2 - argCount); + else if (id == T_void) + stackDepth -= argCount; + else + stackDepth += (1 - argCount); + if (stackDepth > stackMax) + stackMax = stackDepth; + } + final public void ior() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_ior; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ior); + } + } + final public void irem() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_irem; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_irem); + } + } + final public void ireturn() { + countLabels = 0; + stackDepth--; + // the stackDepth should be equal to 0 + try { + position++; + bCodeStream[classFileOffset++] = OPC_ireturn; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ireturn); + } + } + public boolean isDefinitelyAssigned(Scope scope, int initStateIndex, LocalVariableBinding local) { + // Dependant of UnconditionalFlowInfo.isDefinitelyAssigned(..) + if (initStateIndex == -1) + return false; + if (local.isArgument) { + return true; + } + int position = local.id + maxFieldCount; + MethodScope methodScope = scope.methodScope(); + // id is zero-based + if (position < UnconditionalFlowInfo.BitCacheSize) { + return (methodScope.definiteInits[initStateIndex] & (1L << position)) != 0; // use bits + } + // use extra vector + long[] extraInits = methodScope.extraDefiniteInits[initStateIndex]; + if (extraInits == null) + return false; // if vector not yet allocated, then not initialized + int vectorIndex; + if ((vectorIndex = (position / UnconditionalFlowInfo.BitCacheSize) - 1) >= extraInits.length) + return false; // if not enough room in vector, then not initialized + return ((extraInits[vectorIndex]) & (1L << (position % UnconditionalFlowInfo.BitCacheSize))) != 0; + } + final public void ishl() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_ishl; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ishl); + } + } + final public void ishr() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_ishr; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ishr); + } + } + final public void istore(int iArg) { + countLabels = 0; + stackDepth--; + if (maxLocals <= iArg) { + maxLocals = iArg + 1; + } + if (iArg > 255) { // Widen + try { + position++; + bCodeStream[classFileOffset++] = OPC_wide; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_wide); + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_istore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_istore); + } + writeUnsignedShort(iArg); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_istore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_istore); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) iArg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) iArg); + } + } + } + final public void istore_0() { + countLabels = 0; + stackDepth--; + if (maxLocals == 0) { + maxLocals = 1; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_istore_0; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_istore_0); + } + } + final public void istore_1() { + countLabels = 0; + stackDepth--; + if (maxLocals <= 1) { + maxLocals = 2; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_istore_1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_istore_1); + } + } + final public void istore_2() { + countLabels = 0; + stackDepth--; + if (maxLocals <= 2) { + maxLocals = 3; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_istore_2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_istore_2); + } + } + final public void istore_3() { + countLabels = 0; + stackDepth--; + if (maxLocals <= 3) { + maxLocals = 4; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_istore_3; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_istore_3); + } + } + final public void isub() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_isub; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_isub); + } + } + final public void iushr() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_iushr; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_iushr); + } + } + final public void ixor() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_ixor; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ixor); + } + } + final public void jsr(Label lbl) { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_jsr; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_jsr); + } + lbl.branch(); + } + final public void jsr_w(Label lbl) { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_jsr_w; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_jsr_w); + } + lbl.branchWide(); + } + final public void l2d() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_l2d; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_l2d); + } + } + final public void l2f() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_l2f; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_l2f); + } + } + final public void l2i() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_l2i; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_l2i); + } + } + final public void ladd() { + countLabels = 0; + stackDepth -= 2; + try { + position++; + bCodeStream[classFileOffset++] = OPC_ladd; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ladd); + } + } + final public void laload() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_laload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_laload); + } + } + final public void land() { + countLabels = 0; + stackDepth -= 2; + try { + position++; + bCodeStream[classFileOffset++] = OPC_land; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_land); + } + } + final public void lastore() { + countLabels = 0; + stackDepth -= 4; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lastore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lastore); + } + } + final public void lcmp() { + countLabels = 0; + stackDepth -= 3; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lcmp; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lcmp); + } + } + final public void lconst_0() { + countLabels = 0; + stackDepth += 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lconst_0; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lconst_0); + } + } + final public void lconst_1() { + countLabels = 0; + stackDepth += 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lconst_1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lconst_1); + } + } + final public void ldc(float constant) { + countLabels = 0; + int index = constantPool.literalIndex(constant); + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (index > 255) { + // Generate a ldc_w + try { + position++; + bCodeStream[classFileOffset++] = OPC_ldc_w; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ldc_w); + } + writeUnsignedShort(index); + } else { + // Generate a ldc + try { + position++; + bCodeStream[classFileOffset++] = OPC_ldc; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ldc); + } + writeUnsignedByte(index); + } + } + final public void ldc(int constant) { + countLabels = 0; + int index = constantPool.literalIndex(constant); + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (index > 255) { + // Generate a ldc_w + try { + position++; + bCodeStream[classFileOffset++] = OPC_ldc_w; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ldc_w); + } + writeUnsignedShort(index); + } else { + // Generate a ldc + try { + position++; + bCodeStream[classFileOffset++] = OPC_ldc; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ldc); + } + writeUnsignedByte(index); + } + } + final public void ldc(String constant) { + countLabels = 0; + int currentConstantPoolIndex = constantPool.currentIndex; + int currentConstantPoolOffset = constantPool.currentOffset; + int currentCodeStreamPosition = position; + int index = constantPool.literalIndexForLdc(constant.toCharArray()); + if (index > 0) { + // the string already exists inside the constant pool + // we reuse the same index + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (index > 255) { + // Generate a ldc_w + try { + position++; + bCodeStream[classFileOffset++] = OPC_ldc_w; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ldc_w); + } + writeUnsignedShort(index); + } else { + // Generate a ldc + try { + position++; + bCodeStream[classFileOffset++] = OPC_ldc; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ldc); + } + writeUnsignedByte(index); + } + } else { + // the string is too big to be utf8-encoded in one pass. + // we have to split it into different pieces. + // first we clean all side-effects due to the code above + // this case is very rare, so we can afford to lose time to handle it + char[] constantChars = constant.toCharArray(); + position = currentCodeStreamPosition; + constantPool.currentIndex = currentConstantPoolIndex; + constantPool.currentOffset = currentConstantPoolOffset; + constantPool.stringCache.remove(constantChars); + constantPool.UTF8Cache.remove(constantChars); + int i = 0; + int length = 0; + int constantLength = constant.length(); + byte[] utf8encoding = new byte[Math.min(constantLength + 100, 65535)]; + int utf8encodingLength = 0; + while ((length < 65532) && (i < constantLength)) { + char current = constantChars[i]; + // we resize the byte array immediately if necessary + if (length + 3 > (utf8encodingLength = utf8encoding.length)) { + System.arraycopy(utf8encoding, 0, (utf8encoding = new byte[Math.min(utf8encodingLength + 100, 65535)]), 0, length); + } + if ((current >= 0x0001) && (current <= 0x007F)) { + // we only need one byte: ASCII table + utf8encoding[length++] = (byte) current; + } else { + if (current > 0x07FF) { + // we need 3 bytes + utf8encoding[length++] = (byte) (0xE0 | ((current >> 12) & 0x0F)); // 0xE0 = 1110 0000 + utf8encoding[length++] = (byte) (0x80 | ((current >> 6) & 0x3F)); // 0x80 = 1000 0000 + utf8encoding[length++] = (byte) (0x80 | (current & 0x3F)); // 0x80 = 1000 0000 + } else { + // we can be 0 or between 0x0080 and 0x07FF + // In that case we only need 2 bytes + utf8encoding[length++] = (byte) (0xC0 | ((current >> 6) & 0x1F)); // 0xC0 = 1100 0000 + utf8encoding[length++] = (byte) (0x80 | (current & 0x3F)); // 0x80 = 1000 0000 + } + } + i++; + } + // check if all the string is encoded (PR 1PR2DWJ) + // the string is too big to be encoded in one pass + newStringBuffer(); + dup(); + // write the first part + char[] subChars = new char[i]; + System.arraycopy(constantChars, 0, subChars, 0, i); + System.arraycopy(utf8encoding, 0, (utf8encoding = new byte[length]), 0, length); + index = constantPool.literalIndex(subChars, utf8encoding); + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (index > 255) { + // Generate a ldc_w + try { + position++; + bCodeStream[classFileOffset++] = OPC_ldc_w; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ldc_w); + } + writeUnsignedShort(index); + } else { + // Generate a ldc + try { + position++; + bCodeStream[classFileOffset++] = OPC_ldc; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ldc); + } + writeUnsignedByte(index); + } + // write the remaining part + invokeStringBufferStringConstructor(); + while (i < constantLength) { + length = 0; + utf8encoding = new byte[Math.min(constantLength - i + 100, 65535)]; + int startIndex = i; + while ((length < 65532) && (i < constantLength)) { + char current = constantChars[i]; + // we resize the byte array immediately if necessary + if (constantLength + 2 > (utf8encodingLength = utf8encoding.length)) { + System.arraycopy(utf8encoding, 0, (utf8encoding = new byte[Math.min(utf8encodingLength + 100, 65535)]), 0, length); + } + if ((current >= 0x0001) && (current <= 0x007F)) { + // we only need one byte: ASCII table + utf8encoding[length++] = (byte) current; + } else { + if (current > 0x07FF) { + // we need 3 bytes + utf8encoding[length++] = (byte) (0xE0 | ((current >> 12) & 0x0F)); // 0xE0 = 1110 0000 + utf8encoding[length++] = (byte) (0x80 | ((current >> 6) & 0x3F)); // 0x80 = 1000 0000 + utf8encoding[length++] = (byte) (0x80 | (current & 0x3F)); // 0x80 = 1000 0000 + } else { + // we can be 0 or between 0x0080 and 0x07FF + // In that case we only need 2 bytes + utf8encoding[length++] = (byte) (0xC0 | ((current >> 6) & 0x1F)); // 0xC0 = 1100 0000 + utf8encoding[length++] = (byte) (0x80 | (current & 0x3F)); // 0x80 = 1000 0000 + } + } + i++; + } + // the next part is done + subChars = new char[i - startIndex]; + System.arraycopy(constantChars, startIndex, subChars, 0, i - startIndex); + System.arraycopy(utf8encoding, 0, (utf8encoding = new byte[length]), 0, length); + index = constantPool.literalIndex(subChars, utf8encoding); + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + if (index > 255) { + // Generate a ldc_w + try { + position++; + bCodeStream[classFileOffset++] = OPC_ldc_w; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ldc_w); + } + writeUnsignedShort(index); + } else { + // Generate a ldc + try { + position++; + bCodeStream[classFileOffset++] = OPC_ldc; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ldc); + } + writeUnsignedByte(index); + } + // now on the stack it should be a StringBuffer and a string. + invokeStringBufferAppendForType(T_String); + } + invokeStringBufferToString(); + invokeStringIntern(); + } + } + final public void ldc2_w(double constant) { + countLabels = 0; + int index = constantPool.literalIndex(constant); + stackDepth += 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + // Generate a ldc2_w + try { + position++; + bCodeStream[classFileOffset++] = OPC_ldc2_w; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ldc2_w); + } + writeUnsignedShort(index); + } + final public void ldc2_w(long constant) { + countLabels = 0; + int index = constantPool.literalIndex(constant); + stackDepth += 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + // Generate a ldc2_w + try { + position++; + bCodeStream[classFileOffset++] = OPC_ldc2_w; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ldc2_w); + } + writeUnsignedShort(index); + } + final public void ldiv() { + countLabels = 0; + stackDepth -= 2; + try { + position++; + bCodeStream[classFileOffset++] = OPC_ldiv; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ldiv); + } + } + final public void lload(int iArg) { + countLabels = 0; + stackDepth += 2; + if (maxLocals <= iArg + 1) { + maxLocals = iArg + 2; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + if (iArg > 255) { // Widen + try { + position++; + bCodeStream[classFileOffset++] = OPC_wide; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_wide); + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_lload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lload); + } + writeUnsignedShort(iArg); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_lload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lload); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) iArg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) iArg); + } + } + } + final public void lload_0() { + countLabels = 0; + stackDepth += 2; + if (maxLocals < 2) { + maxLocals = 2; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lload_0; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lload_0); + } + } + final public void lload_1() { + countLabels = 0; + stackDepth += 2; + if (maxLocals < 3) { + maxLocals = 3; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lload_1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lload_1); + } + } + final public void lload_2() { + countLabels = 0; + stackDepth += 2; + if (maxLocals < 4) { + maxLocals = 4; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lload_2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lload_2); + } + } + final public void lload_3() { + countLabels = 0; + stackDepth += 2; + if (maxLocals < 5) { + maxLocals = 5; + } + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lload_3; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lload_3); + } + } + final public void lmul() { + countLabels = 0; + stackDepth -= 2; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lmul; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lmul); + } + } + final public void lneg() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lneg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lneg); + } + } + public final void load(LocalVariableBinding localBinding) { + countLabels = 0; + TypeBinding typeBinding = localBinding.type; + int resolvedPosition = localBinding.resolvedPosition; + // Using dedicated int bytecode + if (typeBinding == IntBinding) { + switch (resolvedPosition) { + case 0 : + this.iload_0(); + break; + case 1 : + this.iload_1(); + break; + case 2 : + this.iload_2(); + break; + case 3 : + this.iload_3(); + break; + default : + this.iload(resolvedPosition); + } + return; + } + // Using dedicated float bytecode + if (typeBinding == FloatBinding) { + switch (resolvedPosition) { + case 0 : + this.fload_0(); + break; + case 1 : + this.fload_1(); + break; + case 2 : + this.fload_2(); + break; + case 3 : + this.fload_3(); + break; + default : + this.fload(resolvedPosition); + } + return; + } + // Using dedicated long bytecode + if (typeBinding == LongBinding) { + switch (resolvedPosition) { + case 0 : + this.lload_0(); + break; + case 1 : + this.lload_1(); + break; + case 2 : + this.lload_2(); + break; + case 3 : + this.lload_3(); + break; + default : + this.lload(resolvedPosition); + } + return; + } + // Using dedicated double bytecode + if (typeBinding == DoubleBinding) { + switch (resolvedPosition) { + case 0 : + this.dload_0(); + break; + case 1 : + this.dload_1(); + break; + case 2 : + this.dload_2(); + break; + case 3 : + this.dload_3(); + break; + default : + this.dload(resolvedPosition); + } + return; + } + // boolean, byte, char and short are handled as int + if ((typeBinding == ByteBinding) + || (typeBinding == CharBinding) + || (typeBinding == BooleanBinding) + || (typeBinding == ShortBinding)) { + switch (resolvedPosition) { + case 0 : + this.iload_0(); + break; + case 1 : + this.iload_1(); + break; + case 2 : + this.iload_2(); + break; + case 3 : + this.iload_3(); + break; + default : + this.iload(resolvedPosition); + } + return; + } -public void newJavaLangAssertionError() { - // new: java.lang.AssertionError - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_new; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_new); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangAssertionError()); -} + // Reference object + switch (resolvedPosition) { + case 0 : + this.aload_0(); + break; + case 1 : + this.aload_1(); + break; + case 2 : + this.aload_2(); + break; + case 3 : + this.aload_3(); + break; + default : + this.aload(resolvedPosition); + } + } + public final void load(TypeBinding typeBinding, int resolvedPosition) { + countLabels = 0; + // Using dedicated int bytecode + if (typeBinding == IntBinding) { + switch (resolvedPosition) { + case 0 : + this.iload_0(); + break; + case 1 : + this.iload_1(); + break; + case 2 : + this.iload_2(); + break; + case 3 : + this.iload_3(); + break; + default : + this.iload(resolvedPosition); + } + return; + } + // Using dedicated float bytecode + if (typeBinding == FloatBinding) { + switch (resolvedPosition) { + case 0 : + this.fload_0(); + break; + case 1 : + this.fload_1(); + break; + case 2 : + this.fload_2(); + break; + case 3 : + this.fload_3(); + break; + default : + this.fload(resolvedPosition); + } + return; + } + // Using dedicated long bytecode + if (typeBinding == LongBinding) { + switch (resolvedPosition) { + case 0 : + this.lload_0(); + break; + case 1 : + this.lload_1(); + break; + case 2 : + this.lload_2(); + break; + case 3 : + this.lload_3(); + break; + default : + this.lload(resolvedPosition); + } + return; + } + // Using dedicated double bytecode + if (typeBinding == DoubleBinding) { + switch (resolvedPosition) { + case 0 : + this.dload_0(); + break; + case 1 : + this.dload_1(); + break; + case 2 : + this.dload_2(); + break; + case 3 : + this.dload_3(); + break; + default : + this.dload(resolvedPosition); + } + return; + } + // boolean, byte, char and short are handled as int + if ((typeBinding == ByteBinding) + || (typeBinding == CharBinding) + || (typeBinding == BooleanBinding) + || (typeBinding == ShortBinding)) { + switch (resolvedPosition) { + case 0 : + this.iload_0(); + break; + case 1 : + this.iload_1(); + break; + case 2 : + this.iload_2(); + break; + case 3 : + this.iload_3(); + break; + default : + this.iload(resolvedPosition); + } + return; + } -public void newNoClassDefFoundError() { // new: java.lang.NoClassDefFoundError - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_new; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_new); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangNoClassDefFoundError()); -} -public void newStringBuffer() { // new: java.lang.StringBuffer - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_new; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_new); - } - writeUnsignedShort(constantPool.literalIndexForJavaLangStringBuffer()); -} -public void newWrapperFor(int typeID) { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_new; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_new); - } - switch (typeID) { - case T_int : // new: java.lang.Integer - writeUnsignedShort(constantPool.literalIndexForJavaLangInteger()); - break; - case T_boolean : // new: java.lang.Boolean - writeUnsignedShort(constantPool.literalIndexForJavaLangBoolean()); - break; - case T_byte : // new: java.lang.Byte - writeUnsignedShort(constantPool.literalIndexForJavaLangByte()); - break; - case T_char : // new: java.lang.Character - writeUnsignedShort(constantPool.literalIndexForJavaLangCharacter()); - break; - case T_float : // new: java.lang.Float - writeUnsignedShort(constantPool.literalIndexForJavaLangFloat()); - break; - case T_double : // new: java.lang.Double - writeUnsignedShort(constantPool.literalIndexForJavaLangDouble()); - break; - case T_short : // new: java.lang.Short - writeUnsignedShort(constantPool.literalIndexForJavaLangShort()); - break; - case T_long : // new: java.lang.Long - writeUnsignedShort(constantPool.literalIndexForJavaLangLong()); - break; - case T_void : // new: java.lang.Void - writeUnsignedShort(constantPool.literalIndexForJavaLangVoid()); - } -} -final public void nop() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_nop; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_nop); - } -} -final public void pop() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_pop; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_pop); - } -} -final public void pop2() { - countLabels = 0; - stackDepth -= 2; - try { - position++; - bCodeStream[classFileOffset++] = OPC_pop2; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_pop2); - } -} -final public void putfield(FieldBinding fieldBinding) { - countLabels = 0; - int id; - if (((id = fieldBinding.type.id) == T_double) || (id == T_long)) - stackDepth -= 3; - else - stackDepth -= 2; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_putfield; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_putfield); - } - writeUnsignedShort(constantPool.literalIndex(fieldBinding)); -} -final public void putstatic(FieldBinding fieldBinding) { - countLabels = 0; - int id; - if (((id = fieldBinding.type.id) == T_double) || (id == T_long)) - stackDepth -= 2; - else - stackDepth -= 1; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_putstatic; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_putstatic); - } - writeUnsignedShort(constantPool.literalIndex(fieldBinding)); -} -public void record(LocalVariableBinding local) { - if (!generateLocalVariableTableAttributes) - return; - if (allLocalsCounter == locals.length) { - // resize the collection - System.arraycopy(locals, 0, (locals = new LocalVariableBinding[allLocalsCounter + LOCALS_INCREMENT]), 0, allLocalsCounter); - } - locals[allLocalsCounter++] = local; - local.initializationPCs = new int[4]; - local.initializationCount = 0; -} -public void recordPositionsFrom(int startPC, int sourcePos) { + // Reference object + switch (resolvedPosition) { + case 0 : + this.aload_0(); + break; + case 1 : + this.aload_1(); + break; + case 2 : + this.aload_2(); + break; + case 3 : + this.aload_3(); + break; + default : + this.aload(resolvedPosition); + } + } + public final void loadInt(int resolvedPosition) { + // Using dedicated int bytecode + switch (resolvedPosition) { + case 0 : + this.iload_0(); + break; + case 1 : + this.iload_1(); + break; + case 2 : + this.iload_2(); + break; + case 3 : + this.iload_3(); + break; + default : + this.iload(resolvedPosition); + } + } + public final void loadObject(int resolvedPosition) { + switch (resolvedPosition) { + case 0 : + this.aload_0(); + break; + case 1 : + this.aload_1(); + break; + case 2 : + this.aload_2(); + break; + case 3 : + this.aload_3(); + break; + default : + this.aload(resolvedPosition); + } + } + final public void lookupswitch(CaseLabel defaultLabel, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel) { + countLabels = 0; + stackDepth--; + int length = keys.length; + int pos = position; + defaultLabel.placeInstruction(); + for (int i = 0; i < length; i++) { + casesLabel[i].placeInstruction(); + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_lookupswitch; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lookupswitch); + } + for (int i = (3 - (pos % 4)); i > 0; i--) { + position++; // Padding + classFileOffset++; + } + defaultLabel.branch(); + writeSignedWord(length); + for (int i = 0; i < length; i++) { + writeSignedWord(keys[sortedIndexes[i]]); + casesLabel[sortedIndexes[i]].branch(); + } + } + final public void lor() { + countLabels = 0; + stackDepth -= 2; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lor; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lor); + } + } + final public void lrem() { + countLabels = 0; + stackDepth -= 2; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lrem; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lrem); + } + } + final public void lreturn() { + countLabels = 0; + stackDepth -= 2; + // the stackDepth should be equal to 0 + try { + position++; + bCodeStream[classFileOffset++] = OPC_lreturn; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lreturn); + } + } + final public void lshl() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lshl; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lshl); + } + } + final public void lshr() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lshr; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lshr); + } + } + final public void lstore(int iArg) { + countLabels = 0; + stackDepth -= 2; + if (maxLocals <= iArg + 1) { + maxLocals = iArg + 2; + } + if (iArg > 255) { // Widen + try { + position++; + bCodeStream[classFileOffset++] = OPC_wide; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_wide); + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_lstore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lstore); + } + writeUnsignedShort(iArg); + } else { + try { + position++; + bCodeStream[classFileOffset++] = OPC_lstore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lstore); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) iArg; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) iArg); + } + } + } + final public void lstore_0() { + countLabels = 0; + stackDepth -= 2; + if (maxLocals < 2) { + maxLocals = 2; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_lstore_0; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lstore_0); + } + } + final public void lstore_1() { + countLabels = 0; + stackDepth -= 2; + if (maxLocals < 3) { + maxLocals = 3; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_lstore_1; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lstore_1); + } + } + final public void lstore_2() { + countLabels = 0; + stackDepth -= 2; + if (maxLocals < 4) { + maxLocals = 4; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_lstore_2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lstore_2); + } + } + final public void lstore_3() { + countLabels = 0; + stackDepth -= 2; + if (maxLocals < 5) { + maxLocals = 5; + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_lstore_3; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lstore_3); + } + } + final public void lsub() { + countLabels = 0; + stackDepth -= 2; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lsub; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lsub); + } + } + final public void lushr() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lushr; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lushr); + } + } + final public void lxor() { + countLabels = 0; + stackDepth -= 2; + try { + position++; + bCodeStream[classFileOffset++] = OPC_lxor; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_lxor); + } + } + final public void monitorenter() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_monitorenter; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_monitorenter); + } + } + final public void monitorexit() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_monitorexit; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_monitorexit); + } + } + final public void multianewarray(TypeBinding typeBinding, int dimensions) { + countLabels = 0; + stackDepth += (1 - dimensions); + try { + position++; + bCodeStream[classFileOffset++] = OPC_multianewarray; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_multianewarray); + } + writeUnsignedShort(constantPool.literalIndex(typeBinding)); + writeUnsignedByte(dimensions); + } + public static void needImplementation() { + } + /** + * We didn't call it new, because there is a conflit with the new keyword + */ + final public void new_(TypeBinding typeBinding) { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_new; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_new); + } + writeUnsignedShort(constantPool.literalIndex(typeBinding)); + } + final public void newarray(int array_Type) { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_newarray; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_newarray); + } + writeUnsignedByte(array_Type); + } + public void newArray(Scope scope, ArrayBinding arrayBinding) { + TypeBinding component = arrayBinding.elementsType(scope); + switch (component.id) { + case T_int : + this.newarray(10); + break; + case T_byte : + this.newarray(8); + break; + case T_boolean : + this.newarray(4); + break; + case T_short : + this.newarray(9); + break; + case T_char : + this.newarray(5); + break; + case T_long : + this.newarray(11); + break; + case T_float : + this.newarray(6); + break; + case T_double : + this.newarray(7); + break; + default : + this.anewarray(component); + } + } + public void newJavaLangError() { + // new: java.lang.Error + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_new; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_new); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangError()); + } - /* Record positions in the table, only if nothing has - * already been recorded. Since we output them on the way - * up (children first for more specific info) - * The pcToSourceMap table is always sorted. - */ + public void newJavaLangAssertionError() { + // new: java.lang.AssertionError + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_new; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_new); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangAssertionError()); + } - if (!generateLineNumberAttributes) - return; - if (sourcePos == 0) - return; + public void newNoClassDefFoundError() { // new: java.lang.NoClassDefFoundError + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_new; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_new); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangNoClassDefFoundError()); + } + public void newStringBuffer() { // new: java.lang.StringBuffer + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_new; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_new); + } + writeUnsignedShort(constantPool.literalIndexForJavaLangStringBuffer()); + } + public void newWrapperFor(int typeID) { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_new; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_new); + } + switch (typeID) { + case T_int : // new: java.lang.Integer + writeUnsignedShort(constantPool.literalIndexForJavaLangInteger()); + break; + case T_boolean : // new: java.lang.Boolean + writeUnsignedShort(constantPool.literalIndexForJavaLangBoolean()); + break; + case T_byte : // new: java.lang.Byte + writeUnsignedShort(constantPool.literalIndexForJavaLangByte()); + break; + case T_char : // new: java.lang.Character + writeUnsignedShort(constantPool.literalIndexForJavaLangCharacter()); + break; + case T_float : // new: java.lang.Float + writeUnsignedShort(constantPool.literalIndexForJavaLangFloat()); + break; + case T_double : // new: java.lang.Double + writeUnsignedShort(constantPool.literalIndexForJavaLangDouble()); + break; + case T_short : // new: java.lang.Short + writeUnsignedShort(constantPool.literalIndexForJavaLangShort()); + break; + case T_long : // new: java.lang.Long + writeUnsignedShort(constantPool.literalIndexForJavaLangLong()); + break; + case T_void : // new: java.lang.Void + writeUnsignedShort(constantPool.literalIndexForJavaLangVoid()); + } + } + final public void nop() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_nop; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_nop); + } + } + final public void pop() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_pop; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_pop); + } + } + final public void pop2() { + countLabels = 0; + stackDepth -= 2; + try { + position++; + bCodeStream[classFileOffset++] = OPC_pop2; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_pop2); + } + } + final public void putfield(FieldBinding fieldBinding) { + countLabels = 0; + int id; + if (((id = fieldBinding.type.id) == T_double) || (id == T_long)) + stackDepth -= 3; + else + stackDepth -= 2; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_putfield; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_putfield); + } + writeUnsignedShort(constantPool.literalIndex(fieldBinding)); + } + final public void putstatic(FieldBinding fieldBinding) { + countLabels = 0; + int id; + if (((id = fieldBinding.type.id) == T_double) || (id == T_long)) + stackDepth -= 2; + else + stackDepth -= 1; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_putstatic; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_putstatic); + } + writeUnsignedShort(constantPool.literalIndex(fieldBinding)); + } + public void record(LocalVariableBinding local) { + if (!generateLocalVariableTableAttributes) + return; + if (allLocalsCounter == locals.length) { + // resize the collection + System.arraycopy(locals, 0, (locals = new LocalVariableBinding[allLocalsCounter + LOCALS_INCREMENT]), 0, allLocalsCounter); + } + locals[allLocalsCounter++] = local; + local.initializationPCs = new int[4]; + local.initializationCount = 0; + } + public void recordPositionsFrom(int startPC, int sourcePos) { - // no code generated for this node. e.g. field without any initialization - if (position == startPC) - return; + /* Record positions in the table, only if nothing has + * already been recorded. Since we output them on the way + * up (children first for more specific info) + * The pcToSourceMap table is always sorted. + */ - // Widening an existing entry that already has the same source positions - if (pcToSourceMapSize + 4 > pcToSourceMap.length) { - // resize the array pcToSourceMap - System.arraycopy(pcToSourceMap, 0, (pcToSourceMap = new int[pcToSourceMapSize << 1]), 0, pcToSourceMapSize); - } - int newLine = ClassFile.searchLineNumber(lineSeparatorPositions, sourcePos); - // lastEntryPC represents the endPC of the lastEntry. - if (pcToSourceMapSize > 0) { - // in this case there is already an entry in the table - if (pcToSourceMap[pcToSourceMapSize - 1] != newLine) { - if (startPC < lastEntryPC) { - // we forgot to add an entry. - // search if an existing entry exists for startPC - int insertionIndex = insertionIndex(pcToSourceMap, pcToSourceMapSize, startPC); - if (insertionIndex != -1) { - // there is no existing entry starting with startPC. - int existingEntryIndex = indexOfSameLineEntrySincePC(startPC, newLine); // index for PC - /* the existingEntryIndex corresponds to en entry with the same line and a PC >= startPC. - in this case it is relevant to widen this entry instead of creating a new one. - line1: this(a, - b, - c); - with this code we generate each argument. We generate a aload0 to invoke the constructor. There is no entry for this - aload0 bytecode. The first entry is the one for the argument a. - But we want the constructor call to start at the aload0 pc and not just at the pc of the first argument. - So we widen the existing entry (if there is one) or we create a new entry with the startPC. - */ - if (existingEntryIndex != -1) { - // widen existing entry - pcToSourceMap[existingEntryIndex] = startPC; - } else { - // we have to add an entry that won't be sorted. So we sort the pcToSourceMap. - System.arraycopy(pcToSourceMap, insertionIndex, pcToSourceMap, insertionIndex + 2, pcToSourceMapSize - insertionIndex); - pcToSourceMap[insertionIndex++] = startPC; - pcToSourceMap[insertionIndex] = newLine; - pcToSourceMapSize += 2; - } - } - if (position != lastEntryPC) { // no bytecode since last entry pc - pcToSourceMap[pcToSourceMapSize++] = lastEntryPC; - pcToSourceMap[pcToSourceMapSize++] = newLine; - } - } else { - // we can safely add the new entry. The endPC of the previous entry is not in conflit with the startPC of the new entry. - pcToSourceMap[pcToSourceMapSize++] = startPC; - pcToSourceMap[pcToSourceMapSize++] = newLine; - } - } else { - /* the last recorded entry is on the same line. But it could be relevant to widen this entry. - we want to extend this entry forward in case we generated some bytecode before the last entry that are not related to any statement - */ - if (startPC < pcToSourceMap[pcToSourceMapSize - 2]) { - int insertionIndex = insertionIndex(pcToSourceMap, pcToSourceMapSize, startPC); - if (insertionIndex != -1) { - // widen the existing entry - // we have to figure out if we need to move the last entry at another location to keep a sorted table - if ((pcToSourceMapSize > 4) && (pcToSourceMap[pcToSourceMapSize - 4] > startPC)) { - System.arraycopy(pcToSourceMap, insertionIndex, pcToSourceMap, insertionIndex + 2, pcToSourceMapSize - 2 - insertionIndex); - pcToSourceMap[insertionIndex++] = startPC; - pcToSourceMap[insertionIndex] = newLine; - } else { - pcToSourceMap[pcToSourceMapSize - 2] = startPC; - } - } - } - } - lastEntryPC = position; - } else { - // record the first entry - pcToSourceMap[pcToSourceMapSize++] = startPC; - pcToSourceMap[pcToSourceMapSize++] = newLine; - lastEntryPC = position; - } -} -/** - * @param anExceptionLabel org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel - */ -public void registerExceptionHandler(ExceptionLabel anExceptionLabel) { - int length; - if (exceptionHandlersNumber >= (length = exceptionHandlers.length)) { - // resize the exception handlers table - System.arraycopy(exceptionHandlers, 0, exceptionHandlers = new ExceptionLabel[length + LABELS_INCREMENT], 0, length); - } - // no need to resize. So just add the new exception label - exceptionHandlers[exceptionHandlersNumber++] = anExceptionLabel; -} -public final void removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex) { - // given some flow info, make sure we did not loose some variables initialization - // if this happens, then we must update their pc entries to reflect it in debug attributes - if (!generateLocalVariableTableAttributes) - return; -/* if (initStateIndex == lastInitStateIndexWhenRemovingInits) - return; - - lastInitStateIndexWhenRemovingInits = initStateIndex; - if (lastInitStateIndexWhenAddingInits != initStateIndex){ - lastInitStateIndexWhenAddingInits = -2;// reinitialize add index - // add(1)-remove(1)-add(1) -> ignore second add - // add(1)-remove(2)-add(1) -> perform second add - }*/ - for (int i = 0; i < visibleLocalsCount; i++) { - LocalVariableBinding localBinding = visibleLocals[i]; - if (localBinding != null) { - if (initStateIndex == -1 || !isDefinitelyAssigned(scope, initStateIndex, localBinding)) { - if (localBinding.initializationCount > 0) { - localBinding.recordInitializationEndPC(position); - } - } - } - } -} -/** - * @param methodDeclaration org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration - * @param classFile org.eclipse.jdt.internal.compiler.codegen.ClassFile - */ -public void reset(AbstractMethodDeclaration methodDeclaration, ClassFile classFile) { - init(classFile); - this.methodDeclaration = methodDeclaration; - preserveUnusedLocals = methodDeclaration.scope.problemReporter().options.preserveAllLocalVariables; - initializeMaxLocals(methodDeclaration.binding); -} -/** - * @param methodDeclaration org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration - * @param classFile org.eclipse.jdt.internal.compiler.codegen.ClassFile - */ -public void resetForProblemClinit(ClassFile classFile) { - init(classFile); - maxLocals = 0; -} -protected final void resizeByteArray() { - int actualLength = bCodeStream.length; - int requiredSize = actualLength + growFactor; - if (classFileOffset > requiredSize) { - requiredSize = classFileOffset + growFactor; - } - System.arraycopy(bCodeStream, 0, (bCodeStream = new byte[requiredSize]), 0, actualLength); -} -/** - * This method is used to resize the internal byte array in - * case of a ArrayOutOfBoundsException when adding the value b. - * Resize and add the new byte b inside the array. - * @param b byte - */ -protected final void resizeByteArray(byte b) { - resizeByteArray(); - bCodeStream[classFileOffset - 1] = b; -} -final public void ret(int index) { - countLabels = 0; - if (index > 255) { // Widen - try { - position++; - bCodeStream[classFileOffset++] = OPC_wide; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_wide); - } - try { - position++; - bCodeStream[classFileOffset++] = OPC_ret; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ret); - } - writeUnsignedShort(index); - } else { // Don't Widen - try { - position++; - bCodeStream[classFileOffset++] = OPC_ret; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_ret); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) index; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) index); - } - } -} -final public void return_() { - countLabels = 0; - // the stackDepth should be equal to 0 - try { - position++; - bCodeStream[classFileOffset++] = OPC_return; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_return); - } -} -final public void saload() { - countLabels = 0; - stackDepth--; - try { - position++; - bCodeStream[classFileOffset++] = OPC_saload; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_saload); - } -} -final public void sastore() { - countLabels = 0; - stackDepth -= 3; - try { - position++; - bCodeStream[classFileOffset++] = OPC_sastore; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_sastore); - } -} -/** - * @param operatorConstant int - * @param type_ID int - */ -public void sendOperator(int operatorConstant, int type_ID) { - switch (type_ID) { - case T_int : - case T_boolean : - case T_char : - case T_byte : - case T_short : - switch (operatorConstant) { - case PLUS : - this.iadd(); - break; - case MINUS : - this.isub(); - break; - case MULTIPLY : - this.imul(); - break; - case DIVIDE : - this.idiv(); - break; - case REMAINDER : - this.irem(); - break; - case LEFT_SHIFT : - this.ishl(); - break; - case RIGHT_SHIFT : - this.ishr(); - break; - case UNSIGNED_RIGHT_SHIFT : - this.iushr(); - break; - case AND : - this.iand(); - break; - case OR : - this.ior(); - break; - case XOR : - this.ixor(); - break; - } - break; - case T_long : - switch (operatorConstant) { - case PLUS : - this.ladd(); - break; - case MINUS : - this.lsub(); - break; - case MULTIPLY : - this.lmul(); - break; - case DIVIDE : - this.ldiv(); - break; - case REMAINDER : - this.lrem(); - break; - case LEFT_SHIFT : - this.lshl(); - break; - case RIGHT_SHIFT : - this.lshr(); - break; - case UNSIGNED_RIGHT_SHIFT : - this.lushr(); - break; - case AND : - this.land(); - break; - case OR : - this.lor(); - break; - case XOR : - this.lxor(); - break; - } - break; - case T_float : - switch (operatorConstant) { - case PLUS : - this.fadd(); - break; - case MINUS : - this.fsub(); - break; - case MULTIPLY : - this.fmul(); - break; - case DIVIDE : - this.fdiv(); - break; - case REMAINDER : - this.frem(); - } - break; - case T_double : - switch (operatorConstant) { - case PLUS : - this.dadd(); - break; - case MINUS : - this.dsub(); - break; - case MULTIPLY : - this.dmul(); - break; - case DIVIDE : - this.ddiv(); - break; - case REMAINDER : - this.drem(); - } - } -} -final public void sipush(int s) { - countLabels = 0; - stackDepth++; - if (stackDepth > stackMax) - stackMax = stackDepth; - try { - position++; - bCodeStream[classFileOffset++] = OPC_sipush; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_sipush); - } - writeSignedShort(s); -} -public static final void sort(int[] tab, int lo0, int hi0, int[] result) { - int lo = lo0; - int hi = hi0; - int mid; - if (hi0 > lo0) { - /* Arbitrarily establishing partition element as the midpoint of - * the array. - */ - mid = tab[ (lo0 + hi0) / 2]; - // loop through the array until indices cross - while (lo <= hi) { - /* find the first element that is greater than or equal to - * the partition element starting from the left Index. - */ - while ((lo < hi0) && (tab[lo] < mid)) - ++lo; - /* find an element that is smaller than or equal to - * the partition element starting from the right Index. - */ - while ((hi > lo0) && (tab[hi] > mid)) - --hi; - // if the indexes have not crossed, swap - if (lo <= hi) { - swap(tab, lo, hi, result); - ++lo; - --hi; - } - } - /* If the right index has not reached the left side of array - * must now sort the left partition. - */ - if (lo0 < hi) - sort(tab, lo0, hi, result); - /* If the left index has not reached the right side of array - * must now sort the right partition. - */ - if (lo < hi0) - sort(tab, lo, hi0, result); - } -} -public final void store(LocalVariableBinding localBinding, boolean valueRequired) { - TypeBinding type = localBinding.type; - int position = localBinding.resolvedPosition; - // Using dedicated int bytecode - if ((type == IntBinding) || (type == CharBinding) || (type == ByteBinding) || (type == ShortBinding) || (type == BooleanBinding)) { - if (valueRequired) - this.dup(); - switch (position) { - case 0 : - this.istore_0(); - break; - case 1 : - this.istore_1(); - break; - case 2 : - this.istore_2(); - break; - case 3 : - this.istore_3(); - break; - default : - this.istore(position); - } - return; - } - // Using dedicated float bytecode - if (type == FloatBinding) { - if (valueRequired) - this.dup(); - switch (position) { - case 0 : - this.fstore_0(); - break; - case 1 : - this.fstore_1(); - break; - case 2 : - this.fstore_2(); - break; - case 3 : - this.fstore_3(); - break; - default : - this.fstore(position); - } - return; - } - // Using dedicated long bytecode - if (type == LongBinding) { - if (valueRequired) - this.dup2(); - switch (position) { - case 0 : - this.lstore_0(); - break; - case 1 : - this.lstore_1(); - break; - case 2 : - this.lstore_2(); - break; - case 3 : - this.lstore_3(); - break; - default : - this.lstore(position); - } - return; - } - // Using dedicated double bytecode - if (type == DoubleBinding) { - if (valueRequired) - this.dup2(); - switch (position) { - case 0 : - this.dstore_0(); - break; - case 1 : - this.dstore_1(); - break; - case 2 : - this.dstore_2(); - break; - case 3 : - this.dstore_3(); - break; - default : - this.dstore(position); - } - return; - } - // Reference object - if (valueRequired) - this.dup(); - switch (position) { - case 0 : - this.astore_0(); - break; - case 1 : - this.astore_1(); - break; - case 2 : - this.astore_2(); - break; - case 3 : - this.astore_3(); - break; - default : - this.astore(position); - } -} -public final void store(TypeBinding type, int position) { - // Using dedicated int bytecode - if ((type == IntBinding) || (type == CharBinding) || (type == ByteBinding) || (type == ShortBinding) || (type == BooleanBinding)) { - switch (position) { - case 0 : - this.istore_0(); - break; - case 1 : - this.istore_1(); - break; - case 2 : - this.istore_2(); - break; - case 3 : - this.istore_3(); - break; - default : - this.istore(position); - } - return; - } - // Using dedicated float bytecode - if (type == FloatBinding) { - switch (position) { - case 0 : - this.fstore_0(); - break; - case 1 : - this.fstore_1(); - break; - case 2 : - this.fstore_2(); - break; - case 3 : - this.fstore_3(); - break; - default : - this.fstore(position); - } - return; - } - // Using dedicated long bytecode - if (type == LongBinding) { - switch (position) { - case 0 : - this.lstore_0(); - break; - case 1 : - this.lstore_1(); - break; - case 2 : - this.lstore_2(); - break; - case 3 : - this.lstore_3(); - break; - default : - this.lstore(position); - } - return; - } - // Using dedicated double bytecode - if (type == DoubleBinding) { - switch (position) { - case 0 : - this.dstore_0(); - break; - case 1 : - this.dstore_1(); - break; - case 2 : - this.dstore_2(); - break; - case 3 : - this.dstore_3(); - break; - default : - this.dstore(position); - } - return; - } - // Reference object - switch (position) { - case 0 : - this.astore_0(); - break; - case 1 : - this.astore_1(); - break; - case 2 : - this.astore_2(); - break; - case 3 : - this.astore_3(); - break; - default : - this.astore(position); - } -} -public final void storeInt(int position) { - switch (position) { - case 0 : - this.istore_0(); - break; - case 1 : - this.istore_1(); - break; - case 2 : - this.istore_2(); - break; - case 3 : - this.istore_3(); - break; - default : - this.istore(position); - } -} -public final void storeObject(int position) { - switch (position) { - case 0 : - this.astore_0(); - break; - case 1 : - this.astore_1(); - break; - case 2 : - this.astore_2(); - break; - case 3 : - this.astore_3(); - break; - default : - this.astore(position); - } -} -final public void swap() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_swap; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_swap); - } -} -private static final void swap(int a[], int i, int j, int result[]) { - int T; - T = a[i]; - a[i] = a[j]; - a[j] = T; - T = result[j]; - result[j] = result[i]; - result[i] = T; -} -final public void tableswitch(CaseLabel defaultLabel, int low, int high, int[] keys, int[] sortedIndexes, CaseLabel[] casesLabel) { - countLabels = 0; - stackDepth--; - int length = casesLabel.length; - int pos = position; - defaultLabel.placeInstruction(); - for (int i = 0; i < length; i++) - casesLabel[i].placeInstruction(); - try { - position++; - bCodeStream[classFileOffset++] = OPC_tableswitch; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_tableswitch); - } - for (int i = (3 - (pos % 4)); i > 0; i--) { - position++; // Padding - classFileOffset++; - } - defaultLabel.branch(); - writeSignedWord(low); - writeSignedWord(high); - int i = low, j = low; - // the index j is used to know if the index i is one of the missing entries in case of an - // optimized tableswitch - while (true) { - int index; - int key = keys[index = sortedIndexes[j - low]]; - if (key == i) { - casesLabel[index].branch(); - j++; - if (i == high) break; // if high is maxint, then avoids wrapping to minint. - } else { - defaultLabel.branch(); - } - i++; - } -} -public String toString() { - StringBuffer buffer = new StringBuffer("( position:"); //$NON-NLS-1$ - buffer.append(position); - buffer.append(",\nstackDepth:"); //$NON-NLS-1$ - buffer.append(stackDepth); - buffer.append(",\nmaxStack:"); //$NON-NLS-1$ - buffer.append(stackMax); - buffer.append(",\nmaxLocals:"); //$NON-NLS-1$ - buffer.append(maxLocals); - buffer.append(")"); //$NON-NLS-1$ - return buffer.toString(); -} -public void updateLastRecordedEndPC(int pos) { + if (!generateLineNumberAttributes) + return; + if (sourcePos == 0) + return; - /* Tune positions in the table, this is due to some - * extra bytecodes being - * added to some user code (jumps). */ - /** OLD CODE - if (!generateLineNumberAttributes) - return; - pcToSourceMap[pcToSourceMapSize - 1][1] = position; - // need to update the initialization endPC in case of generation of local variable attributes. - updateLocalVariablesAttribute(pos); - */ + // no code generated for this node. e.g. field without any initialization + if (position == startPC) + return; - if (!generateLineNumberAttributes) - return; - // need to update the initialization endPC in case of generation of local variable attributes. - updateLocalVariablesAttribute(pos); -} -public void updateLocalVariablesAttribute(int pos) { - // need to update the initialization endPC in case of generation of local variable attributes. - if (generateLocalVariableTableAttributes) { - for (int i = 0, max = locals.length; i < max; i++) { - LocalVariableBinding local = locals[i]; - if ((local != null) && (local.initializationCount > 0)) { - if (local.initializationPCs[((local.initializationCount - 1) << 1) + 1] == pos) { - local.initializationPCs[((local.initializationCount - 1) << 1) + 1] = position; - } - } - } - } -} -final public void wide() { - countLabels = 0; - try { - position++; - bCodeStream[classFileOffset++] = OPC_wide; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(OPC_wide); - } -} -public final void writeByte(byte b) { - try { - position++; - bCodeStream[classFileOffset++] = b; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(b); - } -} -public final void writeByteAtPos(int pos, byte b) { - try { - bCodeStream[pos] = b; - } catch (IndexOutOfBoundsException ex) { - resizeByteArray(); - bCodeStream[pos] = b; - } -} -/** - * Write a unsigned 8 bits value into the byte array - * @param b the signed byte - */ -public final void writeSignedByte(int b) { - try { - position++; - bCodeStream[classFileOffset++] = (byte) b; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) b); - } -} -/** - * Write a signed 16 bits value into the byte array - * @param b the signed short - */ -public final void writeSignedShort(int b) { - try { - position++; - bCodeStream[classFileOffset++] = (byte) (b >> 8); - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) (b >> 8)); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) b; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) b); - } -} -public final void writeSignedShort(int pos, int b) { - int currentOffset = startingClassFileOffset + pos; - try { - bCodeStream[currentOffset] = (byte) (b >> 8); - } catch (IndexOutOfBoundsException e) { - resizeByteArray(); - bCodeStream[currentOffset] = (byte) (b >> 8); - } - try { - bCodeStream[currentOffset + 1] = (byte) b; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(); - bCodeStream[currentOffset + 1] = (byte) b; - } -} -public final void writeSignedWord(int value) { - try { - position++; - bCodeStream[classFileOffset++] = (byte) ((value & 0xFF000000) >> 24); - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) ((value & 0xFF000000) >> 24)); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) ((value & 0xFF0000) >> 16); - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) ((value & 0xFF0000) >> 16)); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) ((value & 0xFF00) >> 8); - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) ((value & 0xFF00) >> 8)); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) (value & 0xFF); - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) (value & 0xFF)); - } -} -public final void writeSignedWord(int pos, int value) { - int currentOffset = startingClassFileOffset + pos; - try { - bCodeStream[currentOffset++] = (byte) ((value & 0xFF000000) >> 24); - } catch (IndexOutOfBoundsException e) { - resizeByteArray(); - bCodeStream[currentOffset-1] = (byte) ((value & 0xFF000000) >> 24); - } - try { - bCodeStream[currentOffset++] = (byte) ((value & 0xFF0000) >> 16); - } catch (IndexOutOfBoundsException e) { - resizeByteArray(); - bCodeStream[currentOffset-1] = (byte) ((value & 0xFF0000) >> 16); - } - try { - bCodeStream[currentOffset++] = (byte) ((value & 0xFF00) >> 8); - } catch (IndexOutOfBoundsException e) { - resizeByteArray(); - bCodeStream[currentOffset-1] = (byte) ((value & 0xFF00) >> 8); - } - try { - bCodeStream[currentOffset++] = (byte) (value & 0xFF); - } catch (IndexOutOfBoundsException e) { - resizeByteArray(); - bCodeStream[currentOffset-1] = (byte) (value & 0xFF); - } -} -/** - * Write a unsigned 8 bits value into the byte array - * @param b the unsigned byte - */ -public final void writeUnsignedByte(int b) { - try { - position++; - bCodeStream[classFileOffset++] = (byte) b; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) b); - } -} -/** - * Write a unsigned 16 bits value into the byte array - * @param b the unsigned short - */ -public final void writeUnsignedShort(int b) { - try { - position++; - bCodeStream[classFileOffset++] = (byte) (b >>> 8); - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) (b >>> 8)); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) b; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) b); - } -} -/** - * Write a unsigned 32 bits value into the byte array - * @param value the unsigned word - */ -public final void writeUnsignedWord(int value) { - try { - position++; - bCodeStream[classFileOffset++] = (byte) (value >>> 24); - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) (value >>> 24)); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) (value >>> 16); - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) (value >>> 16)); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) (value >>> 8); - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) (value >>> 8)); - } - try { - position++; - bCodeStream[classFileOffset++] = (byte) value; - } catch (IndexOutOfBoundsException e) { - resizeByteArray((byte) value); - } -} + // Widening an existing entry that already has the same source positions + if (pcToSourceMapSize + 4 > pcToSourceMap.length) { + // resize the array pcToSourceMap + System.arraycopy(pcToSourceMap, 0, (pcToSourceMap = new int[pcToSourceMapSize << 1]), 0, pcToSourceMapSize); + } + int newLine = ClassFile.searchLineNumber(lineSeparatorPositions, sourcePos); + // lastEntryPC represents the endPC of the lastEntry. + if (pcToSourceMapSize > 0) { + // in this case there is already an entry in the table + if (pcToSourceMap[pcToSourceMapSize - 1] != newLine) { + if (startPC < lastEntryPC) { + // we forgot to add an entry. + // search if an existing entry exists for startPC + int insertionIndex = insertionIndex(pcToSourceMap, pcToSourceMapSize, startPC); + if (insertionIndex != -1) { + // there is no existing entry starting with startPC. + int existingEntryIndex = indexOfSameLineEntrySincePC(startPC, newLine); // index for PC + /* the existingEntryIndex corresponds to en entry with the same line and a PC >= startPC. + in this case it is relevant to widen this entry instead of creating a new one. + line1: this(a, + b, + c); + with this code we generate each argument. We generate a aload0 to invoke the constructor. There is no entry for this + aload0 bytecode. The first entry is the one for the argument a. + But we want the constructor call to start at the aload0 pc and not just at the pc of the first argument. + So we widen the existing entry (if there is one) or we create a new entry with the startPC. + */ + if (existingEntryIndex != -1) { + // widen existing entry + pcToSourceMap[existingEntryIndex] = startPC; + } else { + // we have to add an entry that won't be sorted. So we sort the pcToSourceMap. + System.arraycopy( + pcToSourceMap, + insertionIndex, + pcToSourceMap, + insertionIndex + 2, + pcToSourceMapSize - insertionIndex); + pcToSourceMap[insertionIndex++] = startPC; + pcToSourceMap[insertionIndex] = newLine; + pcToSourceMapSize += 2; + } + } + if (position != lastEntryPC) { // no bytecode since last entry pc + pcToSourceMap[pcToSourceMapSize++] = lastEntryPC; + pcToSourceMap[pcToSourceMapSize++] = newLine; + } + } else { + // we can safely add the new entry. The endPC of the previous entry is not in conflit with the startPC of the new entry. + pcToSourceMap[pcToSourceMapSize++] = startPC; + pcToSourceMap[pcToSourceMapSize++] = newLine; + } + } else { + /* the last recorded entry is on the same line. But it could be relevant to widen this entry. + we want to extend this entry forward in case we generated some bytecode before the last entry that are not related to any statement + */ + if (startPC < pcToSourceMap[pcToSourceMapSize - 2]) { + int insertionIndex = insertionIndex(pcToSourceMap, pcToSourceMapSize, startPC); + if (insertionIndex != -1) { + // widen the existing entry + // we have to figure out if we need to move the last entry at another location to keep a sorted table + if ((pcToSourceMapSize > 4) && (pcToSourceMap[pcToSourceMapSize - 4] > startPC)) { + System.arraycopy( + pcToSourceMap, + insertionIndex, + pcToSourceMap, + insertionIndex + 2, + pcToSourceMapSize - 2 - insertionIndex); + pcToSourceMap[insertionIndex++] = startPC; + pcToSourceMap[insertionIndex] = newLine; + } else { + pcToSourceMap[pcToSourceMapSize - 2] = startPC; + } + } + } + } + lastEntryPC = position; + } else { + // record the first entry + pcToSourceMap[pcToSourceMapSize++] = startPC; + pcToSourceMap[pcToSourceMapSize++] = newLine; + lastEntryPC = position; + } + } + /** + * @param anExceptionLabel org.eclipse.jdt.internal.compiler.codegen.ExceptionLabel + */ + public void registerExceptionHandler(ExceptionLabel anExceptionLabel) { + int length; + if (exceptionHandlersNumber >= (length = exceptionHandlers.length)) { + // resize the exception handlers table + System.arraycopy(exceptionHandlers, 0, exceptionHandlers = new ExceptionLabel[length + LABELS_INCREMENT], 0, length); + } + // no need to resize. So just add the new exception label + exceptionHandlers[exceptionHandlersNumber++] = anExceptionLabel; + } + public final void removeNotDefinitelyAssignedVariables(Scope scope, int initStateIndex) { + // given some flow info, make sure we did not loose some variables initialization + // if this happens, then we must update their pc entries to reflect it in debug attributes + if (!generateLocalVariableTableAttributes) + return; + /* if (initStateIndex == lastInitStateIndexWhenRemovingInits) + return; + + lastInitStateIndexWhenRemovingInits = initStateIndex; + if (lastInitStateIndexWhenAddingInits != initStateIndex){ + lastInitStateIndexWhenAddingInits = -2;// reinitialize add index + // add(1)-remove(1)-add(1) -> ignore second add + // add(1)-remove(2)-add(1) -> perform second add + }*/ + for (int i = 0; i < visibleLocalsCount; i++) { + LocalVariableBinding localBinding = visibleLocals[i]; + if (localBinding != null) { + if (initStateIndex == -1 || !isDefinitelyAssigned(scope, initStateIndex, localBinding)) { + if (localBinding.initializationCount > 0) { + localBinding.recordInitializationEndPC(position); + } + } + } + } + } + /** + * @param methodDeclaration org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration + * @param classFile org.eclipse.jdt.internal.compiler.codegen.ClassFile + */ + public void reset(AbstractMethodDeclaration methodDeclaration, ClassFile classFile) { + init(classFile); + this.methodDeclaration = methodDeclaration; + preserveUnusedLocals = methodDeclaration.scope.problemReporter().options.preserveAllLocalVariables; + initializeMaxLocals(methodDeclaration.binding); + } + /** + * @param methodDeclaration org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration + * @param classFile org.eclipse.jdt.internal.compiler.codegen.ClassFile + */ + public void resetForProblemClinit(ClassFile classFile) { + init(classFile); + maxLocals = 0; + } + protected final void resizeByteArray() { + int actualLength = bCodeStream.length; + int requiredSize = actualLength + growFactor; + if (classFileOffset > requiredSize) { + requiredSize = classFileOffset + growFactor; + } + System.arraycopy(bCodeStream, 0, (bCodeStream = new byte[requiredSize]), 0, actualLength); + } + /** + * This method is used to resize the internal byte array in + * case of a ArrayOutOfBoundsException when adding the value b. + * Resize and add the new byte b inside the array. + * @param b byte + */ + protected final void resizeByteArray(byte b) { + resizeByteArray(); + bCodeStream[classFileOffset - 1] = b; + } + final public void ret(int index) { + countLabels = 0; + if (index > 255) { // Widen + try { + position++; + bCodeStream[classFileOffset++] = OPC_wide; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_wide); + } + try { + position++; + bCodeStream[classFileOffset++] = OPC_ret; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ret); + } + writeUnsignedShort(index); + } else { // Don't Widen + try { + position++; + bCodeStream[classFileOffset++] = OPC_ret; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_ret); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) index; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) index); + } + } + } + final public void return_() { + countLabels = 0; + // the stackDepth should be equal to 0 + try { + position++; + bCodeStream[classFileOffset++] = OPC_return; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_return); + } + } + final public void saload() { + countLabels = 0; + stackDepth--; + try { + position++; + bCodeStream[classFileOffset++] = OPC_saload; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_saload); + } + } + final public void sastore() { + countLabels = 0; + stackDepth -= 3; + try { + position++; + bCodeStream[classFileOffset++] = OPC_sastore; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_sastore); + } + } + /** + * @param operatorConstant int + * @param type_ID int + */ + public void sendOperator(int operatorConstant, int type_ID) { + switch (type_ID) { + case T_int : + case T_boolean : + case T_char : + case T_byte : + case T_short : + switch (operatorConstant) { + case PLUS : + this.iadd(); + break; + case MINUS : + this.isub(); + break; + case MULTIPLY : + this.imul(); + break; + case DIVIDE : + this.idiv(); + break; + case REMAINDER : + this.irem(); + break; + case LEFT_SHIFT : + this.ishl(); + break; + case RIGHT_SHIFT : + this.ishr(); + break; + case UNSIGNED_RIGHT_SHIFT : + this.iushr(); + break; + case AND : + this.iand(); + break; + case OR : + this.ior(); + break; + case XOR : + this.ixor(); + break; + } + break; + case T_long : + switch (operatorConstant) { + case PLUS : + this.ladd(); + break; + case MINUS : + this.lsub(); + break; + case MULTIPLY : + this.lmul(); + break; + case DIVIDE : + this.ldiv(); + break; + case REMAINDER : + this.lrem(); + break; + case LEFT_SHIFT : + this.lshl(); + break; + case RIGHT_SHIFT : + this.lshr(); + break; + case UNSIGNED_RIGHT_SHIFT : + this.lushr(); + break; + case AND : + this.land(); + break; + case OR : + this.lor(); + break; + case XOR : + this.lxor(); + break; + } + break; + case T_float : + switch (operatorConstant) { + case PLUS : + this.fadd(); + break; + case MINUS : + this.fsub(); + break; + case MULTIPLY : + this.fmul(); + break; + case DIVIDE : + this.fdiv(); + break; + case REMAINDER : + this.frem(); + } + break; + case T_double : + switch (operatorConstant) { + case PLUS : + this.dadd(); + break; + case MINUS : + this.dsub(); + break; + case MULTIPLY : + this.dmul(); + break; + case DIVIDE : + this.ddiv(); + break; + case REMAINDER : + this.drem(); + } + } + } + final public void sipush(int s) { + countLabels = 0; + stackDepth++; + if (stackDepth > stackMax) + stackMax = stackDepth; + try { + position++; + bCodeStream[classFileOffset++] = OPC_sipush; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_sipush); + } + writeSignedShort(s); + } + public static final void sort(int[] tab, int lo0, int hi0, int[] result) { + int lo = lo0; + int hi = hi0; + int mid; + if (hi0 > lo0) { + /* Arbitrarily establishing partition element as the midpoint of + * the array. + */ + mid = tab[(lo0 + hi0) / 2]; + // loop through the array until indices cross + while (lo <= hi) { + /* find the first element that is greater than or equal to + * the partition element starting from the left Index. + */ + while ((lo < hi0) && (tab[lo] < mid)) + ++lo; + /* find an element that is smaller than or equal to + * the partition element starting from the right Index. + */ + while ((hi > lo0) && (tab[hi] > mid)) + --hi; + // if the indexes have not crossed, swap + if (lo <= hi) { + swap(tab, lo, hi, result); + ++lo; + --hi; + } + } + /* If the right index has not reached the left side of array + * must now sort the left partition. + */ + if (lo0 < hi) + sort(tab, lo0, hi, result); + /* If the left index has not reached the right side of array + * must now sort the right partition. + */ + if (lo < hi0) + sort(tab, lo, hi0, result); + } + } + public final void store(LocalVariableBinding localBinding, boolean valueRequired) { + TypeBinding type = localBinding.type; + int position = localBinding.resolvedPosition; + // Using dedicated int bytecode + if ((type == IntBinding) + || (type == CharBinding) + || (type == ByteBinding) + || (type == ShortBinding) + || (type == BooleanBinding)) { + if (valueRequired) + this.dup(); + switch (position) { + case 0 : + this.istore_0(); + break; + case 1 : + this.istore_1(); + break; + case 2 : + this.istore_2(); + break; + case 3 : + this.istore_3(); + break; + default : + this.istore(position); + } + return; + } + // Using dedicated float bytecode + if (type == FloatBinding) { + if (valueRequired) + this.dup(); + switch (position) { + case 0 : + this.fstore_0(); + break; + case 1 : + this.fstore_1(); + break; + case 2 : + this.fstore_2(); + break; + case 3 : + this.fstore_3(); + break; + default : + this.fstore(position); + } + return; + } + // Using dedicated long bytecode + if (type == LongBinding) { + if (valueRequired) + this.dup2(); + switch (position) { + case 0 : + this.lstore_0(); + break; + case 1 : + this.lstore_1(); + break; + case 2 : + this.lstore_2(); + break; + case 3 : + this.lstore_3(); + break; + default : + this.lstore(position); + } + return; + } + // Using dedicated double bytecode + if (type == DoubleBinding) { + if (valueRequired) + this.dup2(); + switch (position) { + case 0 : + this.dstore_0(); + break; + case 1 : + this.dstore_1(); + break; + case 2 : + this.dstore_2(); + break; + case 3 : + this.dstore_3(); + break; + default : + this.dstore(position); + } + return; + } + // Reference object + if (valueRequired) + this.dup(); + switch (position) { + case 0 : + this.astore_0(); + break; + case 1 : + this.astore_1(); + break; + case 2 : + this.astore_2(); + break; + case 3 : + this.astore_3(); + break; + default : + this.astore(position); + } + } + public final void store(TypeBinding type, int position) { + // Using dedicated int bytecode + if ((type == IntBinding) + || (type == CharBinding) + || (type == ByteBinding) + || (type == ShortBinding) + || (type == BooleanBinding)) { + switch (position) { + case 0 : + this.istore_0(); + break; + case 1 : + this.istore_1(); + break; + case 2 : + this.istore_2(); + break; + case 3 : + this.istore_3(); + break; + default : + this.istore(position); + } + return; + } + // Using dedicated float bytecode + if (type == FloatBinding) { + switch (position) { + case 0 : + this.fstore_0(); + break; + case 1 : + this.fstore_1(); + break; + case 2 : + this.fstore_2(); + break; + case 3 : + this.fstore_3(); + break; + default : + this.fstore(position); + } + return; + } + // Using dedicated long bytecode + if (type == LongBinding) { + switch (position) { + case 0 : + this.lstore_0(); + break; + case 1 : + this.lstore_1(); + break; + case 2 : + this.lstore_2(); + break; + case 3 : + this.lstore_3(); + break; + default : + this.lstore(position); + } + return; + } + // Using dedicated double bytecode + if (type == DoubleBinding) { + switch (position) { + case 0 : + this.dstore_0(); + break; + case 1 : + this.dstore_1(); + break; + case 2 : + this.dstore_2(); + break; + case 3 : + this.dstore_3(); + break; + default : + this.dstore(position); + } + return; + } + // Reference object + switch (position) { + case 0 : + this.astore_0(); + break; + case 1 : + this.astore_1(); + break; + case 2 : + this.astore_2(); + break; + case 3 : + this.astore_3(); + break; + default : + this.astore(position); + } + } + public final void storeInt(int position) { + switch (position) { + case 0 : + this.istore_0(); + break; + case 1 : + this.istore_1(); + break; + case 2 : + this.istore_2(); + break; + case 3 : + this.istore_3(); + break; + default : + this.istore(position); + } + } + public final void storeObject(int position) { + switch (position) { + case 0 : + this.astore_0(); + break; + case 1 : + this.astore_1(); + break; + case 2 : + this.astore_2(); + break; + case 3 : + this.astore_3(); + break; + default : + this.astore(position); + } + } + final public void swap() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_swap; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_swap); + } + } + private static final void swap(int a[], int i, int j, int result[]) { + int T; + T = a[i]; + a[i] = a[j]; + a[j] = T; + T = result[j]; + result[j] = result[i]; + result[i] = T; + } + final public void tableswitch( + CaseLabel defaultLabel, + int low, + int high, + int[] keys, + int[] sortedIndexes, + CaseLabel[] casesLabel) { + countLabels = 0; + stackDepth--; + int length = casesLabel.length; + int pos = position; + defaultLabel.placeInstruction(); + for (int i = 0; i < length; i++) + casesLabel[i].placeInstruction(); + try { + position++; + bCodeStream[classFileOffset++] = OPC_tableswitch; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_tableswitch); + } + for (int i = (3 - (pos % 4)); i > 0; i--) { + position++; // Padding + classFileOffset++; + } + defaultLabel.branch(); + writeSignedWord(low); + writeSignedWord(high); + int i = low, j = low; + // the index j is used to know if the index i is one of the missing entries in case of an + // optimized tableswitch + while (true) { + int index; + int key = keys[index = sortedIndexes[j - low]]; + if (key == i) { + casesLabel[index].branch(); + j++; + if (i == high) + break; // if high is maxint, then avoids wrapping to minint. + } else { + defaultLabel.branch(); + } + i++; + } + } + public String toString() { + StringBuffer buffer = new StringBuffer("( position:"); //$NON-NLS-1$ + buffer.append(position); + buffer.append(",\nstackDepth:"); //$NON-NLS-1$ + buffer.append(stackDepth); + buffer.append(",\nmaxStack:"); //$NON-NLS-1$ + buffer.append(stackMax); + buffer.append(",\nmaxLocals:"); //$NON-NLS-1$ + buffer.append(maxLocals); + buffer.append(")"); //$NON-NLS-1$ + return buffer.toString(); + } + public void updateLastRecordedEndPC(int pos) { -public void generateWideConditionalBranch(byte opcode, Label lbl) { - /* we handle the goto_w problem inside an if.... with some macro expansion - * at the bytecode level - * instead of: - * if_...... lbl - * we have: - * ifne - * goto - * l1 gotow // l3 is a wide target - * l2 .... - */ - Label l1 = new Label(this); - try { - position++; - bCodeStream[classFileOffset++] = opcode; - } catch (IndexOutOfBoundsException e) { - resizeByteArray(opcode); - } - l1.branch(); - Label l2 = new Label(this); - this.internal_goto_(l2); - l1.place(); - this.goto_w(lbl); - l2.place(); -} + /* Tune positions in the table, this is due to some + * extra bytecodes being + * added to some user code (jumps). */ + /** OLD CODE + if (!generateLineNumberAttributes) + return; + pcToSourceMap[pcToSourceMapSize - 1][1] = position; + // need to update the initialization endPC in case of generation of local variable attributes. + updateLocalVariablesAttribute(pos); + */ + + if (!generateLineNumberAttributes) + return; + // need to update the initialization endPC in case of generation of local variable attributes. + updateLocalVariablesAttribute(pos); + } + public void updateLocalVariablesAttribute(int pos) { + // need to update the initialization endPC in case of generation of local variable attributes. + if (generateLocalVariableTableAttributes) { + for (int i = 0, max = locals.length; i < max; i++) { + LocalVariableBinding local = locals[i]; + if ((local != null) && (local.initializationCount > 0)) { + if (local.initializationPCs[((local.initializationCount - 1) << 1) + 1] == pos) { + local.initializationPCs[((local.initializationCount - 1) << 1) + 1] = position; + } + } + } + } + } + final public void wide() { + countLabels = 0; + try { + position++; + bCodeStream[classFileOffset++] = OPC_wide; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(OPC_wide); + } + } + public final void writeByte(byte b) { + try { + position++; + bCodeStream[classFileOffset++] = b; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(b); + } + } + public final void writeByteAtPos(int pos, byte b) { + try { + bCodeStream[pos] = b; + } catch (IndexOutOfBoundsException ex) { + resizeByteArray(); + bCodeStream[pos] = b; + } + } + /** + * Write a unsigned 8 bits value into the byte array + * @param b the signed byte + */ + public final void writeSignedByte(int b) { + try { + position++; + bCodeStream[classFileOffset++] = (byte) b; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) b); + } + } + /** + * Write a signed 16 bits value into the byte array + * @param b the signed short + */ + public final void writeSignedShort(int b) { + try { + position++; + bCodeStream[classFileOffset++] = (byte) (b >> 8); + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) (b >> 8)); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) b; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) b); + } + } + public final void writeSignedShort(int pos, int b) { + int currentOffset = startingClassFileOffset + pos; + try { + bCodeStream[currentOffset] = (byte) (b >> 8); + } catch (IndexOutOfBoundsException e) { + resizeByteArray(); + bCodeStream[currentOffset] = (byte) (b >> 8); + } + try { + bCodeStream[currentOffset + 1] = (byte) b; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(); + bCodeStream[currentOffset + 1] = (byte) b; + } + } + public final void writeSignedWord(int value) { + try { + position++; + bCodeStream[classFileOffset++] = (byte) ((value & 0xFF000000) >> 24); + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) ((value & 0xFF000000) >> 24)); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) ((value & 0xFF0000) >> 16); + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) ((value & 0xFF0000) >> 16)); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) ((value & 0xFF00) >> 8); + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) ((value & 0xFF00) >> 8)); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) (value & 0xFF); + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) (value & 0xFF)); + } + } + public final void writeSignedWord(int pos, int value) { + int currentOffset = startingClassFileOffset + pos; + try { + bCodeStream[currentOffset++] = (byte) ((value & 0xFF000000) >> 24); + } catch (IndexOutOfBoundsException e) { + resizeByteArray(); + bCodeStream[currentOffset - 1] = (byte) ((value & 0xFF000000) >> 24); + } + try { + bCodeStream[currentOffset++] = (byte) ((value & 0xFF0000) >> 16); + } catch (IndexOutOfBoundsException e) { + resizeByteArray(); + bCodeStream[currentOffset - 1] = (byte) ((value & 0xFF0000) >> 16); + } + try { + bCodeStream[currentOffset++] = (byte) ((value & 0xFF00) >> 8); + } catch (IndexOutOfBoundsException e) { + resizeByteArray(); + bCodeStream[currentOffset - 1] = (byte) ((value & 0xFF00) >> 8); + } + try { + bCodeStream[currentOffset++] = (byte) (value & 0xFF); + } catch (IndexOutOfBoundsException e) { + resizeByteArray(); + bCodeStream[currentOffset - 1] = (byte) (value & 0xFF); + } + } + /** + * Write a unsigned 8 bits value into the byte array + * @param b the unsigned byte + */ + public final void writeUnsignedByte(int b) { + try { + position++; + bCodeStream[classFileOffset++] = (byte) b; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) b); + } + } + /** + * Write a unsigned 16 bits value into the byte array + * @param b the unsigned short + */ + public final void writeUnsignedShort(int b) { + try { + position++; + bCodeStream[classFileOffset++] = (byte) (b >>> 8); + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) (b >>> 8)); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) b; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) b); + } + } + /** + * Write a unsigned 32 bits value into the byte array + * @param value the unsigned word + */ + public final void writeUnsignedWord(int value) { + try { + position++; + bCodeStream[classFileOffset++] = (byte) (value >>> 24); + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) (value >>> 24)); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) (value >>> 16); + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) (value >>> 16)); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) (value >>> 8); + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) (value >>> 8)); + } + try { + position++; + bCodeStream[classFileOffset++] = (byte) value; + } catch (IndexOutOfBoundsException e) { + resizeByteArray((byte) value); + } + } + + public void generateWideConditionalBranch(byte opcode, Label lbl) { + /* we handle the goto_w problem inside an if.... with some macro expansion + * at the bytecode level + * instead of: + * if_...... lbl + * we have: + * ifne + * goto + * l1 gotow // l3 is a wide target + * l2 .... + */ + Label l1 = new Label(this); + try { + position++; + bCodeStream[classFileOffset++] = opcode; + } catch (IndexOutOfBoundsException e) { + resizeByteArray(opcode); + } + l1.branch(); + Label l2 = new Label(this); + this.internal_goto_(l2); + l1.place(); + this.goto_w(lbl); + l2.place(); + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java index d46b0a2..299d267 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpdt/internal/compiler/parser/Parser.java @@ -13,9 +13,9 @@ package net.sourceforge.phpdt.internal.compiler.parser; import net.sourceforge.phpdt.core.compiler.*; import net.sourceforge.phpdt.core.compiler.InvalidInputException; import net.sourceforge.phpdt.internal.compiler.*; -import net.sourceforge.phpdt.internal.compiler.env.*; +import net.sourceforge.phpdt.internal.compiler.env.*; import net.sourceforge.phpdt.internal.compiler.impl.*; -import net.sourceforge.phpdt.internal.compiler.ast.*; +import net.sourceforge.phpdt.internal.compiler.ast.*; import net.sourceforge.phpdt.internal.compiler.lookup.*; import net.sourceforge.phpdt.internal.compiler.problem.*; import net.sourceforge.phpdt.internal.compiler.util.*; @@ -24,7430 +24,7531 @@ import java.io.*; import java.util.ArrayList; public class Parser implements BindingIds, ParserBasicInformation, ITerminalSymbols, CompilerModifiers, OperatorIds, TypeIds { - protected ProblemReporter problemReporter; - public int firstToken ; // handle for multiple parsing goals - public int lastAct ; //handle for multiple parsing goals - protected ReferenceContext referenceContext; - public int currentToken; - private int synchronizedBlockSourceStart; - - //error recovery management - protected int lastCheckPoint; - protected RecoveredElement currentElement; - public static boolean VERBOSE_RECOVERY = false; - protected boolean restartRecovery; - protected int listLength; // for recovering some incomplete list (interfaces, throws or parameters) - protected boolean hasReportedError; - protected int recoveredStaticInitializerStart; - protected int lastIgnoredToken, nextIgnoredToken; - protected int lastErrorEndPosition; - - // 1.4 feature - protected boolean assertMode = false; - - //internal data for the automat - protected final static int StackIncrement = 255; - protected int stateStackTop; - protected int[] stack = new int[StackIncrement]; - //scanner token - public Scanner scanner; - //ast stack - final static int AstStackIncrement = 100; - protected int astPtr; - protected AstNode[] astStack = new AstNode[AstStackIncrement]; - protected int astLengthPtr; - protected int[] astLengthStack; - public CompilationUnitDeclaration compilationUnit; /*the result from parse()*/ - AstNode [] noAstNodes = new AstNode[AstStackIncrement]; - //expression stack - final static int ExpressionStackIncrement = 100; - protected int expressionPtr; - protected Expression[] expressionStack = new Expression[ExpressionStackIncrement]; - protected int expressionLengthPtr; - protected int[] expressionLengthStack; - Expression [] noExpressions = new Expression[ExpressionStackIncrement]; - //identifiers stacks - protected int identifierPtr; - protected char[][] identifierStack; - protected int identifierLengthPtr; - protected int[] identifierLengthStack; - protected long[] identifierPositionStack; - //positions , dimensions , .... (what ever is int) ..... stack - protected int intPtr; - protected int[] intStack; - protected int endPosition; //accurate only when used ! (the start position is pushed into intStack while the end the current one) - protected int endStatementPosition; - protected int lParenPos,rParenPos; //accurate only when used ! - //modifiers dimensions nestedType etc....... - protected boolean optimizeStringLiterals =true; - protected int modifiers; - protected int modifiersSourceStart; - protected int nestedType, dimensions; - protected int[] nestedMethod; //the ptr is nestedType - protected int[] realBlockStack; - protected int realBlockPtr; - protected boolean diet = false; //tells the scanner to jump over some parts of the code/expressions like method bodies - protected int dietInt = 0; // if > 0 force the none-diet-parsing mode (even if diet if requested) [field parsing with anonymous inner classes...] - protected int[] variablesCounter; - //===DATA===DATA===DATA===DATA===DATA===DATA===// - public final static byte rhs[] = {0, - 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, - 2,2,2,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 2,2,1,1,1,1,3,4,0,1,2,1,1,1,1, - 1,1,1,1,1,5,1,2,1,2,2,2,1,1,2, - 2,2,4,1,1,1,1,2,1,1,1,1,1,1,1, - 1,1,1,1,2,3,3,2,2,1,3,1,3,1,2, - 1,1,1,3,0,3,1,1,1,1,1,1,1,4,1, - 3,3,7,0,0,0,0,0,2,1,1,1,2,2,4, - 4,5,4,4,2,1,2,3,3,1,3,3,1,3,1, - 4,0,2,1,2,2,4,1,1,2,5,5,7,7,7, - 7,2,2,3,2,2,3,1,2,1,2,1,1,2,2, - 1,1,1,1,1,3,3,4,1,3,4,0,1,2,1, - 1,1,1,2,3,4,0,1,1,1,1,1,1,1,1, - 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,3,3,2,1,1,1,1,1,1,1,5,7,7,6, - 2,3,3,4,1,2,2,1,2,3,2,5,5,7,9, - 9,1,1,1,1,3,3,5,2,3,2,3,3,3,5, - 1,3,4,1,2,5,2,1,1,1,1,1,1,3,1, - 1,3,3,3,3,3,1,1,5,6,8,7,2,0,2, - 0,1,3,4,4,1,2,3,2,1,1,2,2,3,3, - 4,6,6,4,4,1,1,1,1,2,2,0,1,1,3, - 3,1,3,3,1,3,3,1,5,5,4,1,3,3,3, - 1,3,3,1,3,3,3,1,3,3,3,3,3,1,3, - 3,1,3,1,3,1,3,1,3,1,3,1,5,1,1, - 3,3,1,1,1,1,1,1,1,1,1,1,1,1,1, - 1,1,1,1,1,0,1,0,1,0,1,0,1,0,1, - 0,1,0,2,0,1,0,1,0,1,0,1,0,1,0, - 1,0,1,0,2,0,0,1,0,1,0,1,0,1,0, - 1 + protected ProblemReporter problemReporter; + public int firstToken; // handle for multiple parsing goals + public int lastAct; //handle for multiple parsing goals + protected ReferenceContext referenceContext; + public int currentToken; + private int synchronizedBlockSourceStart; + + //error recovery management + protected int lastCheckPoint; + protected RecoveredElement currentElement; + public static boolean VERBOSE_RECOVERY = false; + protected boolean restartRecovery; + protected int listLength; // for recovering some incomplete list (interfaces, throws or parameters) + protected boolean hasReportedError; + protected int recoveredStaticInitializerStart; + protected int lastIgnoredToken, nextIgnoredToken; + protected int lastErrorEndPosition; + + // 1.4 feature + protected boolean assertMode = false; + + //internal data for the automat + protected final static int StackIncrement = 255; + protected int stateStackTop; + protected int[] stack = new int[StackIncrement]; + //scanner token + public Scanner scanner; + //ast stack + final static int AstStackIncrement = 100; + protected int astPtr; + protected AstNode[] astStack = new AstNode[AstStackIncrement]; + protected int astLengthPtr; + protected int[] astLengthStack; + public CompilationUnitDeclaration compilationUnit; /*the result from parse()*/ + AstNode[] noAstNodes = new AstNode[AstStackIncrement]; + //expression stack + final static int ExpressionStackIncrement = 100; + protected int expressionPtr; + protected Expression[] expressionStack = new Expression[ExpressionStackIncrement]; + protected int expressionLengthPtr; + protected int[] expressionLengthStack; + Expression[] noExpressions = new Expression[ExpressionStackIncrement]; + //identifiers stacks + protected int identifierPtr; + protected char[][] identifierStack; + protected int identifierLengthPtr; + protected int[] identifierLengthStack; + protected long[] identifierPositionStack; + //positions , dimensions , .... (what ever is int) ..... stack + protected int intPtr; + protected int[] intStack; + protected int endPosition; //accurate only when used ! (the start position is pushed into intStack while the end the current one) + protected int endStatementPosition; + protected int lParenPos, rParenPos; //accurate only when used ! + //modifiers dimensions nestedType etc....... + protected boolean optimizeStringLiterals = true; + protected int modifiers; + protected int modifiersSourceStart; + protected int nestedType, dimensions; + protected int[] nestedMethod; //the ptr is nestedType + protected int[] realBlockStack; + protected int realBlockPtr; + protected boolean diet = false; //tells the scanner to jump over some parts of the code/expressions like method bodies + protected int dietInt = 0; + // if > 0 force the none-diet-parsing mode (even if diet if requested) [field parsing with anonymous inner classes...] + protected int[] variablesCounter; + //===DATA===DATA===DATA===DATA===DATA===DATA===// + public final static byte rhs[] = + { + 0, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 2, + 1, + 1, + 1, + 1, + 3, + 4, + 0, + 1, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 5, + 1, + 2, + 1, + 2, + 2, + 2, + 1, + 1, + 2, + 2, + 2, + 4, + 1, + 1, + 1, + 1, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 2, + 3, + 3, + 2, + 2, + 1, + 3, + 1, + 3, + 1, + 2, + 1, + 1, + 1, + 3, + 0, + 3, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 4, + 1, + 3, + 3, + 7, + 0, + 0, + 0, + 0, + 0, + 2, + 1, + 1, + 1, + 2, + 2, + 4, + 4, + 5, + 4, + 4, + 2, + 1, + 2, + 3, + 3, + 1, + 3, + 3, + 1, + 3, + 1, + 4, + 0, + 2, + 1, + 2, + 2, + 4, + 1, + 1, + 2, + 5, + 5, + 7, + 7, + 7, + 7, + 2, + 2, + 3, + 2, + 2, + 3, + 1, + 2, + 1, + 2, + 1, + 1, + 2, + 2, + 1, + 1, + 1, + 1, + 1, + 3, + 3, + 4, + 1, + 3, + 4, + 0, + 1, + 2, + 1, + 1, + 1, + 1, + 2, + 3, + 4, + 0, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 3, + 3, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 5, + 7, + 7, + 6, + 2, + 3, + 3, + 4, + 1, + 2, + 2, + 1, + 2, + 3, + 2, + 5, + 5, + 7, + 9, + 9, + 1, + 1, + 1, + 1, + 3, + 3, + 5, + 2, + 3, + 2, + 3, + 3, + 3, + 5, + 1, + 3, + 4, + 1, + 2, + 5, + 2, + 1, + 1, + 1, + 1, + 1, + 1, + 3, + 1, + 1, + 3, + 3, + 3, + 3, + 3, + 1, + 1, + 5, + 6, + 8, + 7, + 2, + 0, + 2, + 0, + 1, + 3, + 4, + 4, + 1, + 2, + 3, + 2, + 1, + 1, + 2, + 2, + 3, + 3, + 4, + 6, + 6, + 4, + 4, + 1, + 1, + 1, + 1, + 2, + 2, + 0, + 1, + 1, + 3, + 3, + 1, + 3, + 3, + 1, + 3, + 3, + 1, + 5, + 5, + 4, + 1, + 3, + 3, + 3, + 1, + 3, + 3, + 1, + 3, + 3, + 3, + 1, + 3, + 3, + 3, + 3, + 3, + 1, + 3, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 3, + 1, + 5, + 1, + 1, + 3, + 3, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 2, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 2, + 0, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1, + 0, + 1 }; + + public static char asb[] = null; + public static char asr[] = null; + public static char symbol_index[] = null; + private static final String UNEXPECTED_EOF = "Unexpected End Of File"; //$NON-NLS-1$ + + public final static String name[] = { null, "++", + //$NON-NLS-1$ + "--", //$NON-NLS-1$ + "==", //$NON-NLS-1$ + "<=", //$NON-NLS-1$ + ">=", //$NON-NLS-1$ + "!=", //$NON-NLS-1$ + "<<", //$NON-NLS-1$ + ">>", //$NON-NLS-1$ + ">>>", //$NON-NLS-1$ + "+=", //$NON-NLS-1$ + "-=", //$NON-NLS-1$ + "*=", //$NON-NLS-1$ + "/=", //$NON-NLS-1$ + "&=", //$NON-NLS-1$ + "|=", //$NON-NLS-1$ + "^=", //$NON-NLS-1$ + "%=", //$NON-NLS-1$ + "<<=", //$NON-NLS-1$ + ">>=", //$NON-NLS-1$ + ">>>=", //$NON-NLS-1$ + "||", //$NON-NLS-1$ + "&&", //$NON-NLS-1$ + "+", //$NON-NLS-1$ + "-", //$NON-NLS-1$ + "!", //$NON-NLS-1$ + "%", //$NON-NLS-1$ + "^", //$NON-NLS-1$ + "&", //$NON-NLS-1$ + "*", //$NON-NLS-1$ + "|", //$NON-NLS-1$ + "~", //$NON-NLS-1$ + "/", //$NON-NLS-1$ + ">", //$NON-NLS-1$ + "<", //$NON-NLS-1$ + "(", //$NON-NLS-1$ + ")", //$NON-NLS-1$ + "{", //$NON-NLS-1$ + "}", //$NON-NLS-1$ + "[", //$NON-NLS-1$ + "]", //$NON-NLS-1$ + ";", //$NON-NLS-1$ + "?", //$NON-NLS-1$ + ":", //$NON-NLS-1$ + ",", //$NON-NLS-1$ + ".", //$NON-NLS-1$ + "=", //$NON-NLS-1$ + "", //$NON-NLS-1$ + "$empty", //$NON-NLS-1$ + "Identifier", //$NON-NLS-1$ + "abstract", //$NON-NLS-1$ + "assert", //$NON-NLS-1$ + "boolean", //$NON-NLS-1$ + "break", //$NON-NLS-1$ + "byte", //$NON-NLS-1$ + "case", //$NON-NLS-1$ + "catch", //$NON-NLS-1$ + "char", //$NON-NLS-1$ + "class", //$NON-NLS-1$ + "continue", //$NON-NLS-1$ + "default", //$NON-NLS-1$ + "do", //$NON-NLS-1$ + "double", //$NON-NLS-1$ + "else", //$NON-NLS-1$ + "extends", //$NON-NLS-1$ + "false", //$NON-NLS-1$ + "final", //$NON-NLS-1$ + "finally", //$NON-NLS-1$ + "float", //$NON-NLS-1$ + "for", //$NON-NLS-1$ + "if", //$NON-NLS-1$ + "implements", //$NON-NLS-1$ + "import", //$NON-NLS-1$ + "instanceof", //$NON-NLS-1$ + "int", //$NON-NLS-1$ + "interface", //$NON-NLS-1$ + "long", //$NON-NLS-1$ + "native", //$NON-NLS-1$ + "new", //$NON-NLS-1$ + "null", //$NON-NLS-1$ + "package", //$NON-NLS-1$ + "private", //$NON-NLS-1$ + "protected", //$NON-NLS-1$ + "public", //$NON-NLS-1$ + "return", //$NON-NLS-1$ + "short", //$NON-NLS-1$ + "static", //$NON-NLS-1$ + "strictfp", //$NON-NLS-1$ + "super", //$NON-NLS-1$ + "switch", //$NON-NLS-1$ + "synchronized", //$NON-NLS-1$ + "this", //$NON-NLS-1$ + "throw", //$NON-NLS-1$ + "throws", //$NON-NLS-1$ + "transient", //$NON-NLS-1$ + "true", //$NON-NLS-1$ + "try", //$NON-NLS-1$ + "void", //$NON-NLS-1$ + "volatile", //$NON-NLS-1$ + "while", //$NON-NLS-1$ + "IntegerLiteral", //$NON-NLS-1$ + "LongLiteral", //$NON-NLS-1$ + "FloatingPointLiteral", //$NON-NLS-1$ + "DoubleLiteral", //$NON-NLS-1$ + "CharacterLiteral", //$NON-NLS-1$ + "StringLiteral", //$NON-NLS-1$ + UNEXPECTED_EOF, "Invalid Character", + //$NON-NLS-1$ + "Goal", //$NON-NLS-1$ + "MethodBody", //$NON-NLS-1$ + "ConstructorBody", //$NON-NLS-1$ + "StaticInitializer", //$NON-NLS-1$ + "Initializer", //$NON-NLS-1$ + "Headers", //$NON-NLS-1$ + "BlockStatements", //$NON-NLS-1$ + "MethodPushModifiersHeader", //$NON-NLS-1$ + "CatchHeader", //$NON-NLS-1$ + "FieldDeclaration", //$NON-NLS-1$ + "ImportDeclaration", //$NON-NLS-1$ + "PackageDeclaration", //$NON-NLS-1$ + "TypeDeclaration", //$NON-NLS-1$ + "GenericMethodDeclaration", //$NON-NLS-1$ + "ClassBodyDeclaration", //$NON-NLS-1$ + "Expression", //$NON-NLS-1$ + "Type", //$NON-NLS-1$ + "PrimitiveType", //$NON-NLS-1$ + "ReferenceType", //$NON-NLS-1$ + "ClassOrInterfaceType", //$NON-NLS-1$ + "ArrayType", //$NON-NLS-1$ + "Name", //$NON-NLS-1$ + "Dims", //$NON-NLS-1$ + "ClassType", //$NON-NLS-1$ + "SimpleName", //$NON-NLS-1$ + "Header", //$NON-NLS-1$ + "ClassHeader", //$NON-NLS-1$ + "InterfaceHeader", //$NON-NLS-1$ + "MethodHeader", //$NON-NLS-1$ + "ConstructorHeader", //$NON-NLS-1$ + "FormalParameter", //$NON-NLS-1$ + "ImportDeclarations", //$NON-NLS-1$ + "TypeDeclarations", //$NON-NLS-1$ + "PackageDeclarationName", //$NON-NLS-1$ + "SingleTypeImportDeclarationName", //$NON-NLS-1$ + "TypeImportOnDemandDeclarationName", //$NON-NLS-1$ + "Modifiers", //$NON-NLS-1$ + "Modifier", //$NON-NLS-1$ + "ClassBody", //$NON-NLS-1$ + "ClassHeaderName", //$NON-NLS-1$ + "InterfaceTypeList", //$NON-NLS-1$ + "InterfaceType", //$NON-NLS-1$ + "ClassBodyDeclarations", //$NON-NLS-1$ + "Block", //$NON-NLS-1$ + "VariableDeclarators", //$NON-NLS-1$ + "VariableDeclarator", //$NON-NLS-1$ + "VariableDeclaratorId", //$NON-NLS-1$ + "VariableInitializer", //$NON-NLS-1$ + "ArrayInitializer", //$NON-NLS-1$ + "MethodHeaderName", //$NON-NLS-1$ + "MethodHeaderParameters", //$NON-NLS-1$ + "MethodPushModifiersHeaderName", //$NON-NLS-1$ + "ClassTypeList", //$NON-NLS-1$ + "ConstructorHeaderName", //$NON-NLS-1$ + "FormalParameterList", //$NON-NLS-1$ + "ClassTypeElt", //$NON-NLS-1$ + "StaticOnly", //$NON-NLS-1$ + "ExplicitConstructorInvocation", //$NON-NLS-1$ + "Primary", //$NON-NLS-1$ + "InterfaceBody", //$NON-NLS-1$ + "InterfaceHeaderName", //$NON-NLS-1$ + "InterfaceMemberDeclarations", //$NON-NLS-1$ + "InterfaceMemberDeclaration", //$NON-NLS-1$ + "VariableInitializers", //$NON-NLS-1$ + "BlockStatement", //$NON-NLS-1$ + "Statement", //$NON-NLS-1$ + "LocalVariableDeclaration", //$NON-NLS-1$ + "StatementWithoutTrailingSubstatement", //$NON-NLS-1$ + "StatementNoShortIf", //$NON-NLS-1$ + "StatementExpression", //$NON-NLS-1$ + "PostIncrementExpression", //$NON-NLS-1$ + "PostDecrementExpression", //$NON-NLS-1$ + "MethodInvocation", //$NON-NLS-1$ + "ClassInstanceCreationExpression", //$NON-NLS-1$ + "SwitchBlock", //$NON-NLS-1$ + "SwitchBlockStatements", //$NON-NLS-1$ + "SwitchLabels", //$NON-NLS-1$ + "SwitchBlockStatement", //$NON-NLS-1$ + "SwitchLabel", //$NON-NLS-1$ + "ConstantExpression", //$NON-NLS-1$ + "StatementExpressionList", //$NON-NLS-1$ + "OnlySynchronized", //$NON-NLS-1$ + "Catches", //$NON-NLS-1$ + "Finally", //$NON-NLS-1$ + "CatchClause", //$NON-NLS-1$ + "PushLPAREN", //$NON-NLS-1$ + "PushRPAREN", //$NON-NLS-1$ + "PrimaryNoNewArray", //$NON-NLS-1$ + "FieldAccess", //$NON-NLS-1$ + "ArrayAccess", //$NON-NLS-1$ + "ClassInstanceCreationExpressionName", //$NON-NLS-1$ + "ArgumentList", //$NON-NLS-1$ + "DimWithOrWithOutExprs", //$NON-NLS-1$ + "DimWithOrWithOutExpr", //$NON-NLS-1$ + "DimsLoop", //$NON-NLS-1$ + "OneDimLoop", //$NON-NLS-1$ + "PostfixExpression", //$NON-NLS-1$ + "UnaryExpression", //$NON-NLS-1$ + "UnaryExpressionNotPlusMinus", //$NON-NLS-1$ + "MultiplicativeExpression", //$NON-NLS-1$ + "AdditiveExpression", //$NON-NLS-1$ + "ShiftExpression", //$NON-NLS-1$ + "RelationalExpression", //$NON-NLS-1$ + "EqualityExpression", //$NON-NLS-1$ + "AndExpression", //$NON-NLS-1$ + "ExclusiveOrExpression", //$NON-NLS-1$ + "InclusiveOrExpression", //$NON-NLS-1$ + "ConditionalAndExpression", //$NON-NLS-1$ + "ConditionalOrExpression", //$NON-NLS-1$ + "ConditionalExpression", //$NON-NLS-1$ + "AssignmentExpression", //$NON-NLS-1$ + "LeftHandSide", //$NON-NLS-1$ + "AssignmentOperator" //$NON-NLS-1$ + }; + + public static short check_table[] = null; + public static char lhs[] = null; + public static char action[] = lhs; + private final static String FILEPREFIX = "parser"; //$NON-NLS-1$ + + static { + try { + initTables(); + } catch (java.io.IOException ex) { + throw new ExceptionInInitializerError(ex.getMessage()); + } + } + + public static final int RoundBracket = 0; + public static final int SquareBracket = 1; + public static final int CurlyBracket = 2; + public static final int BracketKinds = 3; + + public Parser(ProblemReporter problemReporter, boolean optimizeStringLiterals, boolean assertMode) { + + this.problemReporter = problemReporter; + this.optimizeStringLiterals = optimizeStringLiterals; + this.assertMode = assertMode; + this.initializeScanner(); + astLengthStack = new int[50]; + expressionLengthStack = new int[30]; + intStack = new int[50]; + identifierStack = new char[30][]; + identifierLengthStack = new int[30]; + nestedMethod = new int[30]; + realBlockStack = new int[30]; + identifierPositionStack = new long[30]; + variablesCounter = new int[30]; + } + /** + * + * INTERNAL USE-ONLY + */ + protected void adjustInterfaceModifiers() { + intStack[intPtr - 1] |= AccInterface; + } + public final void arrayInitializer(int length) { + //length is the size of the array Initializer + //expressionPtr points on the last elt of the arrayInitializer + //i.e. it has not been decremented yet. + + ArrayInitializer ai = new ArrayInitializer(); + if (length != 0) { + expressionPtr -= length; + System.arraycopy(expressionStack, expressionPtr + 1, ai.expressions = new Expression[length], 0, length); + } + pushOnExpressionStack(ai); + //positionning + ai.sourceEnd = endStatementPosition; + int searchPosition = length == 0 ? endPosition : ai.expressions[0].sourceStart; + try { + //does not work with comments(that contain '{') nor '{' describes as a unicode.... + while (scanner.source[--searchPosition] != '{') { + } + } catch (IndexOutOfBoundsException ex) { + //should never occur (except for strange cases like whose describe above) + searchPosition = (length == 0 ? endPosition : ai.expressions[0].sourceStart) - 1; + } + ai.sourceStart = searchPosition; + } + protected static int asi(int state) { + + return asb[original_state(state)]; + } + protected void blockReal() { + // See consumeLocalVariableDeclarationStatement in case of change: duplicated code + // increment the amount of declared variables for this block + realBlockStack[realBlockPtr]++; + } + private final static void buildFileFor(String filename, String tag, String[] tokens, boolean isShort) + throws java.io.IOException { + + //transform the String tokens into chars before dumping then into file + + int i = 0; + //read upto the tag + while (!tokens[i++].equals(tag)) { + } + //read upto the } + char[] chars = new char[tokens.length]; //can't be bigger + int ic = 0; + String token; + while (!(token = tokens[i++]).equals("}")) { //$NON-NLS-1$ + int c = Integer.parseInt(token); + if (isShort) + c += 32768; + chars[ic++] = (char) c; + } + + //resize + System.arraycopy(chars, 0, chars = new char[ic], 0, ic); + + buildFileForTable(filename, chars); + } + private final static void buildFileForTable(String filename, char[] chars) throws java.io.IOException { + + byte[] bytes = new byte[chars.length * 2]; + for (int i = 0; i < chars.length; i++) { + bytes[2 * i] = (byte) (chars[i] >>> 8); + bytes[2 * i + 1] = (byte) (chars[i] & 0xFF); + } + + java.io.FileOutputStream stream = new java.io.FileOutputStream(filename); + stream.write(bytes); + stream.close(); + System.out.println(filename + " creation complete"); //$NON-NLS-1$ + } + public final static void buildFilesFromLPG(String dataFilename) throws java.io.IOException { + + //RUN THIS METHOD TO GENERATE PARSER*.RSC FILES + + //build from the lpg javadcl.java files that represents the parser tables + //lhs check_table asb asr symbol_index + + //[org.eclipse.jdt.internal.compiler.parser.Parser.buildFilesFromLPG("d:/leapfrog/grammar/javadcl.java")] + + char[] contents = new char[] { }; - - - public static char asb[] = null; - public static char asr[] = null; - public static char symbol_index[] = null; - private static final String UNEXPECTED_EOF = "Unexpected End Of File" ; //$NON-NLS-1$ - - public final static String name[] = { null, - "++",//$NON-NLS-1$ - "--",//$NON-NLS-1$ - "==",//$NON-NLS-1$ - "<=",//$NON-NLS-1$ - ">=",//$NON-NLS-1$ - "!=",//$NON-NLS-1$ - "<<",//$NON-NLS-1$ - ">>",//$NON-NLS-1$ - ">>>",//$NON-NLS-1$ - "+=",//$NON-NLS-1$ - "-=",//$NON-NLS-1$ - "*=",//$NON-NLS-1$ - "/=",//$NON-NLS-1$ - "&=",//$NON-NLS-1$ - "|=",//$NON-NLS-1$ - "^=",//$NON-NLS-1$ - "%=",//$NON-NLS-1$ - "<<=",//$NON-NLS-1$ - ">>=",//$NON-NLS-1$ - ">>>=",//$NON-NLS-1$ - "||",//$NON-NLS-1$ - "&&",//$NON-NLS-1$ - "+",//$NON-NLS-1$ - "-",//$NON-NLS-1$ - "!",//$NON-NLS-1$ - "%",//$NON-NLS-1$ - "^",//$NON-NLS-1$ - "&",//$NON-NLS-1$ - "*",//$NON-NLS-1$ - "|",//$NON-NLS-1$ - "~",//$NON-NLS-1$ - "/",//$NON-NLS-1$ - ">",//$NON-NLS-1$ - "<",//$NON-NLS-1$ - "(",//$NON-NLS-1$ - ")",//$NON-NLS-1$ - "{",//$NON-NLS-1$ - "}",//$NON-NLS-1$ - "[",//$NON-NLS-1$ - "]",//$NON-NLS-1$ - ";",//$NON-NLS-1$ - "?",//$NON-NLS-1$ - ":",//$NON-NLS-1$ - ",",//$NON-NLS-1$ - ".",//$NON-NLS-1$ - "=",//$NON-NLS-1$ - "",//$NON-NLS-1$ - "$empty",//$NON-NLS-1$ - "Identifier",//$NON-NLS-1$ - "abstract",//$NON-NLS-1$ - "assert",//$NON-NLS-1$ - "boolean",//$NON-NLS-1$ - "break",//$NON-NLS-1$ - "byte",//$NON-NLS-1$ - "case",//$NON-NLS-1$ - "catch",//$NON-NLS-1$ - "char",//$NON-NLS-1$ - "class",//$NON-NLS-1$ - "continue",//$NON-NLS-1$ - "default",//$NON-NLS-1$ - "do",//$NON-NLS-1$ - "double",//$NON-NLS-1$ - "else",//$NON-NLS-1$ - "extends",//$NON-NLS-1$ - "false",//$NON-NLS-1$ - "final",//$NON-NLS-1$ - "finally",//$NON-NLS-1$ - "float",//$NON-NLS-1$ - "for",//$NON-NLS-1$ - "if",//$NON-NLS-1$ - "implements",//$NON-NLS-1$ - "import",//$NON-NLS-1$ - "instanceof",//$NON-NLS-1$ - "int",//$NON-NLS-1$ - "interface",//$NON-NLS-1$ - "long",//$NON-NLS-1$ - "native",//$NON-NLS-1$ - "new",//$NON-NLS-1$ - "null",//$NON-NLS-1$ - "package",//$NON-NLS-1$ - "private",//$NON-NLS-1$ - "protected",//$NON-NLS-1$ - "public",//$NON-NLS-1$ - "return",//$NON-NLS-1$ - "short",//$NON-NLS-1$ - "static",//$NON-NLS-1$ - "strictfp",//$NON-NLS-1$ - "super",//$NON-NLS-1$ - "switch",//$NON-NLS-1$ - "synchronized",//$NON-NLS-1$ - "this",//$NON-NLS-1$ - "throw",//$NON-NLS-1$ - "throws",//$NON-NLS-1$ - "transient",//$NON-NLS-1$ - "true",//$NON-NLS-1$ - "try",//$NON-NLS-1$ - "void",//$NON-NLS-1$ - "volatile",//$NON-NLS-1$ - "while",//$NON-NLS-1$ - "IntegerLiteral",//$NON-NLS-1$ - "LongLiteral",//$NON-NLS-1$ - "FloatingPointLiteral",//$NON-NLS-1$ - "DoubleLiteral",//$NON-NLS-1$ - "CharacterLiteral",//$NON-NLS-1$ - "StringLiteral",//$NON-NLS-1$ - UNEXPECTED_EOF, - "Invalid Character",//$NON-NLS-1$ - "Goal",//$NON-NLS-1$ - "MethodBody",//$NON-NLS-1$ - "ConstructorBody",//$NON-NLS-1$ - "StaticInitializer",//$NON-NLS-1$ - "Initializer",//$NON-NLS-1$ - "Headers",//$NON-NLS-1$ - "BlockStatements",//$NON-NLS-1$ - "MethodPushModifiersHeader",//$NON-NLS-1$ - "CatchHeader",//$NON-NLS-1$ - "FieldDeclaration",//$NON-NLS-1$ - "ImportDeclaration",//$NON-NLS-1$ - "PackageDeclaration",//$NON-NLS-1$ - "TypeDeclaration",//$NON-NLS-1$ - "GenericMethodDeclaration",//$NON-NLS-1$ - "ClassBodyDeclaration",//$NON-NLS-1$ - "Expression",//$NON-NLS-1$ - "Type",//$NON-NLS-1$ - "PrimitiveType",//$NON-NLS-1$ - "ReferenceType",//$NON-NLS-1$ - "ClassOrInterfaceType",//$NON-NLS-1$ - "ArrayType",//$NON-NLS-1$ - "Name",//$NON-NLS-1$ - "Dims",//$NON-NLS-1$ - "ClassType",//$NON-NLS-1$ - "SimpleName",//$NON-NLS-1$ - "Header",//$NON-NLS-1$ - "ClassHeader",//$NON-NLS-1$ - "InterfaceHeader",//$NON-NLS-1$ - "MethodHeader",//$NON-NLS-1$ - "ConstructorHeader",//$NON-NLS-1$ - "FormalParameter",//$NON-NLS-1$ - "ImportDeclarations",//$NON-NLS-1$ - "TypeDeclarations",//$NON-NLS-1$ - "PackageDeclarationName",//$NON-NLS-1$ - "SingleTypeImportDeclarationName",//$NON-NLS-1$ - "TypeImportOnDemandDeclarationName",//$NON-NLS-1$ - "Modifiers",//$NON-NLS-1$ - "Modifier",//$NON-NLS-1$ - "ClassBody",//$NON-NLS-1$ - "ClassHeaderName",//$NON-NLS-1$ - "InterfaceTypeList",//$NON-NLS-1$ - "InterfaceType",//$NON-NLS-1$ - "ClassBodyDeclarations",//$NON-NLS-1$ - "Block",//$NON-NLS-1$ - "VariableDeclarators",//$NON-NLS-1$ - "VariableDeclarator",//$NON-NLS-1$ - "VariableDeclaratorId",//$NON-NLS-1$ - "VariableInitializer",//$NON-NLS-1$ - "ArrayInitializer",//$NON-NLS-1$ - "MethodHeaderName",//$NON-NLS-1$ - "MethodHeaderParameters",//$NON-NLS-1$ - "MethodPushModifiersHeaderName",//$NON-NLS-1$ - "ClassTypeList",//$NON-NLS-1$ - "ConstructorHeaderName",//$NON-NLS-1$ - "FormalParameterList",//$NON-NLS-1$ - "ClassTypeElt",//$NON-NLS-1$ - "StaticOnly",//$NON-NLS-1$ - "ExplicitConstructorInvocation",//$NON-NLS-1$ - "Primary",//$NON-NLS-1$ - "InterfaceBody",//$NON-NLS-1$ - "InterfaceHeaderName",//$NON-NLS-1$ - "InterfaceMemberDeclarations",//$NON-NLS-1$ - "InterfaceMemberDeclaration",//$NON-NLS-1$ - "VariableInitializers",//$NON-NLS-1$ - "BlockStatement",//$NON-NLS-1$ - "Statement",//$NON-NLS-1$ - "LocalVariableDeclaration",//$NON-NLS-1$ - "StatementWithoutTrailingSubstatement",//$NON-NLS-1$ - "StatementNoShortIf",//$NON-NLS-1$ - "StatementExpression",//$NON-NLS-1$ - "PostIncrementExpression",//$NON-NLS-1$ - "PostDecrementExpression",//$NON-NLS-1$ - "MethodInvocation",//$NON-NLS-1$ - "ClassInstanceCreationExpression",//$NON-NLS-1$ - "SwitchBlock",//$NON-NLS-1$ - "SwitchBlockStatements",//$NON-NLS-1$ - "SwitchLabels",//$NON-NLS-1$ - "SwitchBlockStatement",//$NON-NLS-1$ - "SwitchLabel",//$NON-NLS-1$ - "ConstantExpression",//$NON-NLS-1$ - "StatementExpressionList",//$NON-NLS-1$ - "OnlySynchronized",//$NON-NLS-1$ - "Catches",//$NON-NLS-1$ - "Finally",//$NON-NLS-1$ - "CatchClause",//$NON-NLS-1$ - "PushLPAREN",//$NON-NLS-1$ - "PushRPAREN",//$NON-NLS-1$ - "PrimaryNoNewArray",//$NON-NLS-1$ - "FieldAccess",//$NON-NLS-1$ - "ArrayAccess",//$NON-NLS-1$ - "ClassInstanceCreationExpressionName",//$NON-NLS-1$ - "ArgumentList",//$NON-NLS-1$ - "DimWithOrWithOutExprs",//$NON-NLS-1$ - "DimWithOrWithOutExpr",//$NON-NLS-1$ - "DimsLoop",//$NON-NLS-1$ - "OneDimLoop",//$NON-NLS-1$ - "PostfixExpression",//$NON-NLS-1$ - "UnaryExpression",//$NON-NLS-1$ - "UnaryExpressionNotPlusMinus",//$NON-NLS-1$ - "MultiplicativeExpression",//$NON-NLS-1$ - "AdditiveExpression",//$NON-NLS-1$ - "ShiftExpression",//$NON-NLS-1$ - "RelationalExpression",//$NON-NLS-1$ - "EqualityExpression",//$NON-NLS-1$ - "AndExpression",//$NON-NLS-1$ - "ExclusiveOrExpression",//$NON-NLS-1$ - "InclusiveOrExpression",//$NON-NLS-1$ - "ConditionalAndExpression",//$NON-NLS-1$ - "ConditionalOrExpression",//$NON-NLS-1$ - "ConditionalExpression",//$NON-NLS-1$ - "AssignmentExpression",//$NON-NLS-1$ - "LeftHandSide",//$NON-NLS-1$ - "AssignmentOperator"//$NON-NLS-1$ + try { + contents = Util.getFileCharContent(new File(dataFilename), null); + } catch (IOException ex) { + System.out.println(Util.bind("parser.incorrectPath")); //$NON-NLS-1$ + return; + } + java.util.StringTokenizer st = new java.util.StringTokenizer(new String(contents), " \t\n\r[]={,;"); //$NON-NLS-1$ + String[] tokens = new String[st.countTokens()]; + int i = 0; + while (st.hasMoreTokens()) { + tokens[i++] = st.nextToken(); + } + final String prefix = FILEPREFIX; + i = 0; + buildFileFor(prefix + (++i) + ".rsc", "lhs", tokens, false); //$NON-NLS-2$ //$NON-NLS-1$ + buildFileFor(prefix + (++i) + ".rsc", "check_table", tokens, true); //$NON-NLS-2$ //$NON-NLS-1$ + buildFileFor(prefix + (++i) + ".rsc", "asb", tokens, false); //$NON-NLS-2$ //$NON-NLS-1$ + buildFileFor(prefix + (++i) + ".rsc", "asr", tokens, false); //$NON-NLS-2$ //$NON-NLS-1$ + buildFileFor(prefix + (++i) + ".rsc", "symbol_index", tokens, false); //$NON-NLS-2$ //$NON-NLS-1$ + System.out.println(Util.bind("parser.moveFiles")); //$NON-NLS-1$ + } + /* + * Build initial recovery state. + * Recovery state is inferred from the current state of the parser (reduced node stack). + */ + public RecoveredElement buildInitialRecoveryState() { + + /* initialize recovery by retrieving available reduced nodes + * also rebuild bracket balance + */ + lastCheckPoint = 0; + + RecoveredElement element = null; + if (referenceContext instanceof CompilationUnitDeclaration) { + element = new RecoveredUnit(compilationUnit, 0, this); + + /* ignore current stack state, since restarting from the beginnning + since could not trust simple brace count */ + if (true) { // experimenting restart recovery from scratch + compilationUnit.currentPackage = null; + compilationUnit.imports = null; + compilationUnit.types = null; + currentToken = 0; + listLength = 0; + return element; + } + if (compilationUnit.currentPackage != null) { + lastCheckPoint = compilationUnit.currentPackage.declarationSourceEnd + 1; + } + if (compilationUnit.imports != null) { + lastCheckPoint = compilationUnit.imports[compilationUnit.imports.length - 1].declarationSourceEnd + 1; + } + } else { + if (referenceContext instanceof AbstractMethodDeclaration) { + element = new RecoveredMethod((AbstractMethodDeclaration) referenceContext, null, 0, this); + lastCheckPoint = ((AbstractMethodDeclaration) referenceContext).bodyStart; + } else { + /* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */ + if (referenceContext instanceof TypeDeclaration) { + TypeDeclaration type = (TypeDeclaration) referenceContext; + for (int i = 0; i < type.fields.length; i++) { + FieldDeclaration field = type.fields[i]; + if (!field.isField() + && field.declarationSourceStart <= scanner.initialPosition + && scanner.initialPosition <= field.declarationSourceEnd + && scanner.eofPosition <= field.declarationSourceEnd + 1) { + element = new RecoveredInitializer((Initializer) field, null, 1, this); + lastCheckPoint = field.declarationSourceStart; + break; + } + } + } + } + } + + if (element == null) + return element; + + for (int i = 0; i <= astPtr; i++) { + AstNode node = astStack[i]; + if (node instanceof AbstractMethodDeclaration) { + AbstractMethodDeclaration method = (AbstractMethodDeclaration) node; + if (method.declarationSourceEnd == 0) { + element = element.add(method, 0); + lastCheckPoint = method.bodyStart; + } else { + element = element.add(method, 0); + lastCheckPoint = method.declarationSourceEnd + 1; + } + continue; + } + if (node instanceof Initializer) { + Initializer initializer = (Initializer) node; + if (initializer.declarationSourceEnd == 0) { + element = element.add(initializer, 1); + lastCheckPoint = initializer.bodyStart; + } else { + element = element.add(initializer, 0); + lastCheckPoint = initializer.declarationSourceEnd + 1; + } + continue; + } + if (node instanceof FieldDeclaration) { + FieldDeclaration field = (FieldDeclaration) node; + if (field.declarationSourceEnd == 0) { + element = element.add(field, 0); + if (field.initialization == null) { + lastCheckPoint = field.sourceEnd + 1; + } else { + lastCheckPoint = field.initialization.sourceEnd + 1; + } + } else { + element = element.add(field, 0); + lastCheckPoint = field.declarationSourceEnd + 1; + } + continue; + } + if (node instanceof TypeDeclaration) { + TypeDeclaration type = (TypeDeclaration) node; + if (type.declarationSourceEnd == 0) { + element = element.add(type, 0); + lastCheckPoint = type.bodyStart; + } else { + element = element.add(type, 0); + lastCheckPoint = type.declarationSourceEnd + 1; + } + continue; + } + if (node instanceof ImportReference) { + ImportReference importRef = (ImportReference) node; + element = element.add(importRef, 0); + lastCheckPoint = importRef.declarationSourceEnd + 1; + } + } + return element; + } + protected static short check(int i) { + return check_table[i - (NUM_RULES + 1)]; + } + /* + * Reconsider the entire source looking for inconsistencies in {} () [] + */ + public boolean checkAndReportBracketAnomalies(ProblemReporter problemReporter) { + + scanner.wasAcr = false; + boolean anomaliesDetected = false; + try { + char[] source = scanner.source; + int[] leftCount = { 0, 0, 0 }; + int[] rightCount = { 0, 0, 0 }; + int[] depths = { 0, 0, 0 }; + int[][] leftPositions = new int[][] { new int[10], new int[10], new int[10] }; + int[][] leftDepths = new int[][] { new int[10], new int[10], new int[10] }; + int[][] rightPositions = new int[][] { new int[10], new int[10], new int[10] }; + int[][] rightDepths = new int[][] { new int[10], new int[10], new int[10] }; + scanner.currentPosition = scanner.initialPosition; //starting point (first-zero-based char) + while (scanner.currentPosition < scanner.eofPosition) { //loop for jumping over comments + try { + // ---------Consume white space and handles startPosition--------- + boolean isWhiteSpace; + do { + scanner.startPosition = scanner.currentPosition; + if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') + && (source[scanner.currentPosition] == 'u')) { + isWhiteSpace = scanner.jumpOverUnicodeWhiteSpace(); + } else { + if (scanner.recordLineSeparator && ((scanner.currentCharacter == '\r') || (scanner.currentCharacter == '\n'))) { + if (scanner.lineEnds[scanner.linePtr] < scanner.startPosition) { + // only record line positions we have not recorded yet + scanner.pushLineSeparator(); + } + } + isWhiteSpace = Character.isWhitespace(scanner.currentCharacter); + } + } while (isWhiteSpace && (scanner.currentPosition < scanner.eofPosition)); + + // -------consume token until } is found--------- + + switch (scanner.currentCharacter) { + case '{' : + { + int index = leftCount[CurlyBracket]++; + if (index == leftPositions[CurlyBracket].length) { + System.arraycopy(leftPositions[CurlyBracket], 0, (leftPositions[CurlyBracket] = new int[index * 2]), 0, index); + System.arraycopy(leftDepths[CurlyBracket], 0, (leftDepths[CurlyBracket] = new int[index * 2]), 0, index); + } + leftPositions[CurlyBracket][index] = scanner.startPosition; + leftDepths[CurlyBracket][index] = depths[CurlyBracket]++; + } + break; + case '}' : + { + int index = rightCount[CurlyBracket]++; + if (index == rightPositions[CurlyBracket].length) { + System.arraycopy(rightPositions[CurlyBracket], 0, (rightPositions[CurlyBracket] = new int[index * 2]), 0, index); + System.arraycopy(rightDepths[CurlyBracket], 0, (rightDepths[CurlyBracket] = new int[index * 2]), 0, index); + } + rightPositions[CurlyBracket][index] = scanner.startPosition; + rightDepths[CurlyBracket][index] = --depths[CurlyBracket]; + } + break; + case '(' : + { + int index = leftCount[RoundBracket]++; + if (index == leftPositions[RoundBracket].length) { + System.arraycopy(leftPositions[RoundBracket], 0, (leftPositions[RoundBracket] = new int[index * 2]), 0, index); + System.arraycopy(leftDepths[RoundBracket], 0, (leftDepths[RoundBracket] = new int[index * 2]), 0, index); + } + leftPositions[RoundBracket][index] = scanner.startPosition; + leftDepths[RoundBracket][index] = depths[RoundBracket]++; + } + break; + case ')' : + { + int index = rightCount[RoundBracket]++; + if (index == rightPositions[RoundBracket].length) { + System.arraycopy(rightPositions[RoundBracket], 0, (rightPositions[RoundBracket] = new int[index * 2]), 0, index); + System.arraycopy(rightDepths[RoundBracket], 0, (rightDepths[RoundBracket] = new int[index * 2]), 0, index); + } + rightPositions[RoundBracket][index] = scanner.startPosition; + rightDepths[RoundBracket][index] = --depths[RoundBracket]; + } + break; + case '[' : + { + int index = leftCount[SquareBracket]++; + if (index == leftPositions[SquareBracket].length) { + System.arraycopy(leftPositions[SquareBracket], 0, (leftPositions[SquareBracket] = new int[index * 2]), 0, index); + System.arraycopy(leftDepths[SquareBracket], 0, (leftDepths[SquareBracket] = new int[index * 2]), 0, index); + } + leftPositions[SquareBracket][index] = scanner.startPosition; + leftDepths[SquareBracket][index] = depths[SquareBracket]++; + } + break; + case ']' : + { + int index = rightCount[SquareBracket]++; + if (index == rightPositions[SquareBracket].length) { + System.arraycopy( + rightPositions[SquareBracket], + 0, + (rightPositions[SquareBracket] = new int[index * 2]), + 0, + index); + System.arraycopy(rightDepths[SquareBracket], 0, (rightDepths[SquareBracket] = new int[index * 2]), 0, index); + } + rightPositions[SquareBracket][index] = scanner.startPosition; + rightDepths[SquareBracket][index] = --depths[SquareBracket]; + } + break; + case '\'' : + { + if (scanner.getNextChar('\\')) { + scanner.scanEscapeCharacter(); + } else { // consume next character + scanner.unicodeAsBackSlash = false; + if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') + && (source[scanner.currentPosition] == 'u')) { + scanner.getNextUnicodeChar(); + } else { + if (scanner.withoutUnicodePtr != 0) { + scanner.withoutUnicodeBuffer[++scanner.withoutUnicodePtr] = scanner.currentCharacter; + } + } + } + scanner.getNextChar('\''); + break; + } + case '"' : // consume next character + scanner.unicodeAsBackSlash = false; + if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') + && (source[scanner.currentPosition] == 'u')) { + scanner.getNextUnicodeChar(); + } else { + if (scanner.withoutUnicodePtr != 0) { + scanner.withoutUnicodeBuffer[++scanner.withoutUnicodePtr] = scanner.currentCharacter; + } + } + while (scanner.currentCharacter != '"') { + if (scanner.currentCharacter == '\r') { + if (source[scanner.currentPosition] == '\n') + scanner.currentPosition++; + break; // the string cannot go further that the line + } + if (scanner.currentCharacter == '\n') { + break; // the string cannot go further that the line + } + if (scanner.currentCharacter == '\\') { + scanner.scanEscapeCharacter(); + } + // consume next character + scanner.unicodeAsBackSlash = false; + if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') + && (source[scanner.currentPosition] == 'u')) { + scanner.getNextUnicodeChar(); + } else { + if (scanner.withoutUnicodePtr != 0) { + scanner.withoutUnicodeBuffer[++scanner.withoutUnicodePtr] = scanner.currentCharacter; + } + } + } + break; + case '/' : + { + int test; + if ((test = scanner.getNextChar('/', '*')) == 0) { //line comment + //get the next char + if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') + && (source[scanner.currentPosition] == 'u')) { + //-------------unicode traitement ------------ + int c1 = 0, c2 = 0, c3 = 0, c4 = 0; + scanner.currentPosition++; + while (source[scanner.currentPosition] == 'u') { + scanner.currentPosition++; + } + if ((c1 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c1 < 0 + || (c2 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c2 < 0 + || (c3 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c3 < 0 + || (c4 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c4 < 0) { //error don't care of the value + scanner.currentCharacter = 'A'; + } //something different from \n and \r + else { + scanner.currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4); + } + } + while (scanner.currentCharacter != '\r' && scanner.currentCharacter != '\n') { + //get the next char + scanner.startPosition = scanner.currentPosition; + if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') + && (source[scanner.currentPosition] == 'u')) { + //-------------unicode traitement ------------ + int c1 = 0, c2 = 0, c3 = 0, c4 = 0; + scanner.currentPosition++; + while (source[scanner.currentPosition] == 'u') { + scanner.currentPosition++; + } + if ((c1 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c1 < 0 + || (c2 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c2 < 0 + || (c3 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c3 < 0 + || (c4 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c4 < 0) { //error don't care of the value + scanner.currentCharacter = 'A'; + } //something different from \n and \r + else { + scanner.currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4); + } + } + } + if (scanner.recordLineSeparator && ((scanner.currentCharacter == '\r') || (scanner.currentCharacter == '\n'))) { + if (scanner.lineEnds[scanner.linePtr] < scanner.startPosition) { + // only record line positions we have not recorded yet + scanner.pushLineSeparator(); + } + } + break; + } + if (test > 0) { //traditional and annotation comment + boolean star = false; + // consume next character + scanner.unicodeAsBackSlash = false; + if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') + && (source[scanner.currentPosition] == 'u')) { + scanner.getNextUnicodeChar(); + } else { + if (scanner.withoutUnicodePtr != 0) { + scanner.withoutUnicodeBuffer[++scanner.withoutUnicodePtr] = scanner.currentCharacter; + } + } + if (scanner.currentCharacter == '*') { + star = true; + } + //get the next char + if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') + && (source[scanner.currentPosition] == 'u')) { + //-------------unicode traitement ------------ + int c1 = 0, c2 = 0, c3 = 0, c4 = 0; + scanner.currentPosition++; + while (source[scanner.currentPosition] == 'u') { + scanner.currentPosition++; + } + if ((c1 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c1 < 0 + || (c2 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c2 < 0 + || (c3 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c3 < 0 + || (c4 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c4 < 0) { //error don't care of the value + scanner.currentCharacter = 'A'; + } //something different from * and / + else { + scanner.currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4); + } + } + //loop until end of comment */ + while ((scanner.currentCharacter != '/') || (!star)) { + star = scanner.currentCharacter == '*'; + //get next char + if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') + && (source[scanner.currentPosition] == 'u')) { + //-------------unicode traitement ------------ + int c1 = 0, c2 = 0, c3 = 0, c4 = 0; + scanner.currentPosition++; + while (source[scanner.currentPosition] == 'u') { + scanner.currentPosition++; + } + if ((c1 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c1 < 0 + || (c2 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c2 < 0 + || (c3 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c3 < 0 + || (c4 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 + || c4 < 0) { //error don't care of the value + scanner.currentCharacter = 'A'; + } //something different from * and / + else { + scanner.currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4); + } + } + } + break; + } + break; + } + default : + if (Character.isJavaIdentifierStart(scanner.currentCharacter)) { + scanner.scanIdentifierOrKeyword(); + break; + } + if (Character.isDigit(scanner.currentCharacter)) { + scanner.scanNumber(false); + break; + } + } + //-----------------end switch while try-------------------- + } catch (IndexOutOfBoundsException e) { + break; // read until EOF + } catch (InvalidInputException e) { + return false; // no clue + } + } + if (scanner.recordLineSeparator) { + compilationUnit.compilationResult.lineSeparatorPositions = scanner.getLineEnds(); + } + + // check placement anomalies against other kinds of brackets + for (int kind = 0; kind < BracketKinds; kind++) { + for (int leftIndex = leftCount[kind] - 1; leftIndex >= 0; leftIndex--) { + int start = leftPositions[kind][leftIndex]; // deepest first + // find matching closing bracket + int depth = leftDepths[kind][leftIndex]; + int end = -1; + for (int i = 0; i < rightCount[kind]; i++) { + int pos = rightPositions[kind][i]; + // want matching bracket further in source with same depth + if ((pos > start) && (depth == rightDepths[kind][i])) { + end = pos; + break; + } + } + if (end < 0) { // did not find a good closing match + problemReporter.unmatchedBracket(start, referenceContext, compilationUnit.compilationResult); + return true; + } + // check if even number of opening/closing other brackets in between this pair of brackets + int balance = 0; + for (int otherKind = 0;(balance == 0) && (otherKind < BracketKinds); otherKind++) { + for (int i = 0; i < leftCount[otherKind]; i++) { + int pos = leftPositions[otherKind][i]; + if ((pos > start) && (pos < end)) + balance++; + } + for (int i = 0; i < rightCount[otherKind]; i++) { + int pos = rightPositions[otherKind][i]; + if ((pos > start) && (pos < end)) + balance--; + } + if (balance != 0) { + problemReporter.unmatchedBracket(start, referenceContext, compilationUnit.compilationResult); //bracket anomaly + return true; + } + } + } + // too many opening brackets ? + for (int i = rightCount[kind]; i < leftCount[kind]; i++) { + anomaliesDetected = true; + problemReporter.unmatchedBracket( + leftPositions[kind][leftCount[kind] - i - 1], + referenceContext, + compilationUnit.compilationResult); + } + // too many closing brackets ? + for (int i = leftCount[kind]; i < rightCount[kind]; i++) { + anomaliesDetected = true; + problemReporter.unmatchedBracket(rightPositions[kind][i], referenceContext, compilationUnit.compilationResult); + } + if (anomaliesDetected) + return true; + } + + return anomaliesDetected; + } catch (ArrayStoreException e) { // jdk1.2.2 jit bug + return anomaliesDetected; + } catch (NullPointerException e) { // jdk1.2.2 jit bug + return anomaliesDetected; + } + } + public final void checkAndSetModifiers(int flag) { + /*modify the current modifiers buffer. + When the startPosition of the modifiers is 0 + it means that the modifier being parsed is the first + of a list of several modifiers. The startPosition + is zeroed when a copy of modifiers-buffer is push + onto the astStack. */ + + if ((modifiers & flag) != 0) { // duplicate modifier + modifiers |= AccAlternateModifierProblem; + } + modifiers |= flag; + + if (modifiersSourceStart < 0) + modifiersSourceStart = scanner.startPosition; + } + public void checkAnnotation() { + + boolean deprecated = false; + boolean checkDeprecated = false; + int lastAnnotationIndex = -1; + + //since jdk1.2 look only in the last java doc comment... + found : for (lastAnnotationIndex = scanner.commentPtr; lastAnnotationIndex >= 0; lastAnnotationIndex--) { + //look for @deprecated into the first javadoc comment preceeding the declaration + int commentSourceStart = scanner.commentStarts[lastAnnotationIndex]; + // javadoc only (non javadoc comment have negative end positions.) + if (modifiersSourceStart != -1 && modifiersSourceStart < commentSourceStart) { + continue; + } + if (scanner.commentStops[lastAnnotationIndex] < 0) { + break found; + } + checkDeprecated = true; + int commentSourceEnd = scanner.commentStops[lastAnnotationIndex] - 1; //stop is one over + char[] comment = scanner.source; + + for (int i = commentSourceStart + 3; i < commentSourceEnd - 10; i++) { + if ((comment[i] == '@') + && (comment[i + 1] == 'd') + && (comment[i + 2] == 'e') + && (comment[i + 3] == 'p') + && (comment[i + 4] == 'r') + && (comment[i + 5] == 'e') + && (comment[i + 6] == 'c') + && (comment[i + 7] == 'a') + && (comment[i + 8] == 't') + && (comment[i + 9] == 'e') + && (comment[i + 10] == 'd')) { + // ensure the tag is properly ended: either followed by a space, a tab, line end or asterisk. + int nextPos = i + 11; + deprecated = + (comment[nextPos] == ' ') + || (comment[nextPos] == '\t') + || (comment[nextPos] == '\n') + || (comment[nextPos] == '\r') + || (comment[nextPos] == '*'); + break found; + } + } + break found; + } + if (deprecated) { + checkAndSetModifiers(AccDeprecated); + } + // modify the modifier source start to point at the first comment + if (lastAnnotationIndex >= 0 && checkDeprecated) { + modifiersSourceStart = scanner.commentStarts[lastAnnotationIndex]; + } + } + protected void classInstanceCreation(boolean alwaysQualified) { + // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt + + // ClassBodyopt produces a null item on the astStak if it produces NO class body + // An empty class body produces a 0 on the length stack..... + + AllocationExpression alloc; + int length; + if (((length = astLengthStack[astLengthPtr--]) == 1) && (astStack[astPtr] == null)) { + //NO ClassBody + astPtr--; + if (alwaysQualified) { + alloc = new QualifiedAllocationExpression(); + } else { + alloc = new AllocationExpression(); + } + alloc.sourceEnd = endPosition; //the position has been stored explicitly + + if ((length = expressionLengthStack[expressionLengthPtr--]) != 0) { + expressionPtr -= length; + System.arraycopy(expressionStack, expressionPtr + 1, alloc.arguments = new Expression[length], 0, length); + } + alloc.type = getTypeReference(0); + //the default constructor with the correct number of argument + //will be created and added by the TC (see createsInternalConstructorWithBinding) + alloc.sourceStart = intStack[intPtr--]; + pushOnExpressionStack(alloc); + } else { + dispatchDeclarationInto(length); + AnonymousLocalTypeDeclaration anonymousTypeDeclaration = (AnonymousLocalTypeDeclaration) astStack[astPtr]; + anonymousTypeDeclaration.declarationSourceEnd = endStatementPosition; + anonymousTypeDeclaration.bodyEnd = endStatementPosition; + if (anonymousTypeDeclaration.allocation != null) { + anonymousTypeDeclaration.allocation.sourceEnd = endStatementPosition; + } + astPtr--; + astLengthPtr--; + + // mark fields and initializer with local type mark if needed + markFieldsWithLocalType(anonymousTypeDeclaration); + } + } + protected final void concatExpressionLists() { + expressionLengthStack[--expressionLengthPtr]++; + } + private final void concatNodeLists() { + /* + * This is a case where you have two sublists into the astStack that you want + * to merge in one list. There is no action required on the astStack. The only + * thing you need to do is merge the two lengths specified on the astStackLength. + * The top two length are for example: + * ... p n + * and you want to result in a list like: + * ... n+p + * This means that the p could be equals to 0 in case there is no astNode pushed + * on the astStack. + * Look at the InterfaceMemberDeclarations for an example. + */ + + astLengthStack[astLengthPtr - 1] += astLengthStack[astLengthPtr--]; + } + protected void consumeAllocationHeader() { + // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt + + // ClassBodyopt produces a null item on the astStak if it produces NO class body + // An empty class body produces a 0 on the length stack..... + + if (currentElement == null) { + return; // should never occur, this consumeRule is only used in recovery mode + } + if (currentToken == TokenNameLBRACE) { + // beginning of an anonymous type + AnonymousLocalTypeDeclaration anonymousType = new AnonymousLocalTypeDeclaration(this.compilationUnit.compilationResult); + anonymousType.sourceStart = intStack[intPtr--]; + anonymousType.sourceEnd = rParenPos; // closing parenthesis + lastCheckPoint = anonymousType.bodyStart = scanner.currentPosition; + currentElement = currentElement.add(anonymousType, 0); + lastIgnoredToken = -1; + currentToken = 0; // opening brace already taken into account + return; + } + lastCheckPoint = scanner.startPosition; // force to restart at this exact position + restartRecovery = true; // request to restart from here on + } + protected void consumeArgumentList() { + // ArgumentList ::= ArgumentList ',' Expression + concatExpressionLists(); + } + protected void consumeArrayAccess(boolean unspecifiedReference) { + // ArrayAccess ::= Name '[' Expression ']' ==> true + // ArrayAccess ::= PrimaryNoNewArray '[' Expression ']' ==> false + + //optimize push/pop + Expression exp; + if (unspecifiedReference) { + exp = expressionStack[expressionPtr] = new ArrayReference(getUnspecifiedReferenceOptimized(), expressionStack[expressionPtr]); + } else { + expressionPtr--; + expressionLengthPtr--; + exp = expressionStack[expressionPtr] = new ArrayReference(expressionStack[expressionPtr], expressionStack[expressionPtr + 1]); + } + exp.sourceEnd = endPosition; + } + protected void consumeArrayCreationExpression() { + // ArrayCreationExpression ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializeropt + // ArrayCreationExpression ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializeropt + + int length; + ArrayAllocationExpression aae = new ArrayAllocationExpression(); + if (expressionLengthStack[expressionLengthPtr] != 0) { + expressionLengthPtr--; + aae.initializer = (ArrayInitializer) expressionStack[expressionPtr--]; + } else { + expressionLengthPtr--; + } + + aae.type = getTypeReference(0); + length = (expressionLengthStack[expressionLengthPtr--]); + expressionPtr -= length; + System.arraycopy(expressionStack, expressionPtr + 1, aae.dimensions = new Expression[length], 0, length); + aae.sourceStart = intStack[intPtr--]; + if (aae.initializer == null) { + aae.sourceEnd = endPosition; + } else { + aae.sourceEnd = aae.initializer.sourceEnd; + } + pushOnExpressionStack(aae); + } + protected void consumeArrayInitializer() { + // ArrayInitializer ::= '{' VariableInitializers '}' + // ArrayInitializer ::= '{' VariableInitializers , '}' + + arrayInitializer(expressionLengthStack[expressionLengthPtr--]); + } + + protected void consumeAssertStatement() { + // AssertStatement ::= 'assert' Expression ':' Expression ';' + expressionLengthPtr -= 2; + pushOnAstStack(new AssertStatement(expressionStack[expressionPtr--], expressionStack[expressionPtr--], intStack[intPtr--])); + } + + protected void consumeAssignment() { + // Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression + //optimize the push/pop + + int op = intStack[intPtr--]; //<--the encoded operator + + expressionPtr--; + expressionLengthPtr--; + expressionStack[expressionPtr] = + (op != EQUAL) + ? new CompoundAssignment(expressionStack[expressionPtr], expressionStack[expressionPtr + 1], op, scanner.startPosition - 1) + : new Assignment(expressionStack[expressionPtr], expressionStack[expressionPtr + 1], scanner.startPosition - 1); + } + protected void consumeAssignmentOperator(int pos) { + // AssignmentOperator ::= '=' + // AssignmentOperator ::= '*=' + // AssignmentOperator ::= '/=' + // AssignmentOperator ::= '%=' + // AssignmentOperator ::= '+=' + // AssignmentOperator ::= '-=' + // AssignmentOperator ::= '<<=' + // AssignmentOperator ::= '>>=' + // AssignmentOperator ::= '>>>=' + // AssignmentOperator ::= '&=' + // AssignmentOperator ::= '^=' + // AssignmentOperator ::= '|=' + + try { + intStack[++intPtr] = pos; + } catch (IndexOutOfBoundsException e) { + //intPtr is correct + int oldStackLength = intStack.length; + int oldStack[] = intStack; + intStack = new int[oldStackLength + StackIncrement]; + System.arraycopy(oldStack, 0, intStack, 0, oldStackLength); + intStack[intPtr] = pos; + } + } + protected void consumeBinaryExpression(int op) { + // MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression + // MultiplicativeExpression ::= MultiplicativeExpression '/' UnaryExpression + // MultiplicativeExpression ::= MultiplicativeExpression '%' UnaryExpression + // AdditiveExpression ::= AdditiveExpression '+' MultiplicativeExpression + // AdditiveExpression ::= AdditiveExpression '-' MultiplicativeExpression + // ShiftExpression ::= ShiftExpression '<<' AdditiveExpression + // ShiftExpression ::= ShiftExpression '>>' AdditiveExpression + // ShiftExpression ::= ShiftExpression '>>>' AdditiveExpression + // RelationalExpression ::= RelationalExpression '<' ShiftExpression + // RelationalExpression ::= RelationalExpression '>' ShiftExpression + // RelationalExpression ::= RelationalExpression '<=' ShiftExpression + // RelationalExpression ::= RelationalExpression '>=' ShiftExpression + // AndExpression ::= AndExpression '&' EqualityExpression + // ExclusiveOrExpression ::= ExclusiveOrExpression '^' AndExpression + // InclusiveOrExpression ::= InclusiveOrExpression '|' ExclusiveOrExpression + // ConditionalAndExpression ::= ConditionalAndExpression '&&' InclusiveOrExpression + // ConditionalOrExpression ::= ConditionalOrExpression '||' ConditionalAndExpression + + //optimize the push/pop + + expressionPtr--; + expressionLengthPtr--; + if (op == OR_OR) { + expressionStack[expressionPtr] = new OR_OR_Expression(expressionStack[expressionPtr], expressionStack[expressionPtr + 1], op); + } else { + if (op == AND_AND) { + expressionStack[expressionPtr] = + new AND_AND_Expression(expressionStack[expressionPtr], expressionStack[expressionPtr + 1], op); + } else { + // look for "string1" + "string2" + if ((op == PLUS) && optimizeStringLiterals) { + Expression expr1, expr2; + expr1 = expressionStack[expressionPtr]; + expr2 = expressionStack[expressionPtr + 1]; + if (expr1 instanceof StringLiteral) { + if (expr2 instanceof CharLiteral) { // string+char + expressionStack[expressionPtr] = ((StringLiteral) expr1).extendWith((CharLiteral) expr2); + } else if (expr2 instanceof StringLiteral) { //string+string + expressionStack[expressionPtr] = ((StringLiteral) expr1).extendWith((StringLiteral) expr2); + } else { + expressionStack[expressionPtr] = new BinaryExpression(expr1, expr2, PLUS); + } + } else { + expressionStack[expressionPtr] = new BinaryExpression(expr1, expr2, PLUS); + } + } else { + expressionStack[expressionPtr] = + new BinaryExpression(expressionStack[expressionPtr], expressionStack[expressionPtr + 1], op); + } + } + } + } + protected void consumeBlock() { + // Block ::= OpenBlock '{' BlockStatementsopt '}' + // simpler action for empty blocks + + int length; + if ((length = astLengthStack[astLengthPtr--]) == 0) { // empty block + pushOnAstStack(Block.EmptyWith(intStack[intPtr--], endStatementPosition)); + realBlockPtr--; // still need to pop the block variable counter + } else { + Block bk = new Block(realBlockStack[realBlockPtr--]); + astPtr -= length; + System.arraycopy(astStack, astPtr + 1, bk.statements = new Statement[length], 0, length); + pushOnAstStack(bk); + bk.sourceStart = intStack[intPtr--]; + bk.sourceEnd = endStatementPosition; + } + } + protected void consumeBlockStatements() { + // BlockStatements ::= BlockStatements BlockStatement + concatNodeLists(); + } + protected void consumeCaseLabel() { + // SwitchLabel ::= 'case' ConstantExpression ':' + expressionLengthPtr--; + pushOnAstStack(new Case(intStack[intPtr--], expressionStack[expressionPtr--])); + } + protected void consumeCastExpression() { + // CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN UnaryExpression + // CastExpression ::= PushLPAREN Name Dims PushRPAREN UnaryExpressionNotPlusMinus + + //intStack : posOfLeftParen dim posOfRightParen + + //optimize the push/pop + + Expression exp, cast, castType; + int end = intStack[intPtr--]; + expressionStack[expressionPtr] = + cast = new CastExpression(exp = expressionStack[expressionPtr], castType = getTypeReference(intStack[intPtr--])); + castType.sourceEnd = end - 1; + castType.sourceStart = (cast.sourceStart = intStack[intPtr--]) + 1; + cast.sourceEnd = exp.sourceEnd; + } + protected void consumeCastExpressionLL1() { + //CastExpression ::= '(' Expression ')' UnaryExpressionNotPlusMinus + // Expression is used in order to make the grammar LL1 + + //optimize push/pop + + Expression castType, cast, exp; + expressionPtr--; + expressionStack[expressionPtr] = + cast = + new CastExpression(exp = expressionStack[expressionPtr + 1], castType = getTypeReference(expressionStack[expressionPtr])); + expressionLengthPtr--; + updateSourcePosition(castType); + cast.sourceStart = castType.sourceStart; + cast.sourceEnd = exp.sourceEnd; + castType.sourceStart++; + castType.sourceEnd--; + } + protected void consumeCatches() { + // Catches ::= Catches CatchClause + optimizedConcatNodeLists(); + } + protected void consumeCatchHeader() { + // CatchDeclaration ::= 'catch' '(' FormalParameter ')' '{' + + if (currentElement == null) { + return; // should never occur, this consumeRule is only used in recovery mode + } + // current element should be a block due to the presence of the opening brace + if (!(currentElement instanceof RecoveredBlock)) { + return; + } + // exception argument is already on astStack + ((RecoveredBlock) currentElement).attach(new RecoveredLocalVariable((Argument) astStack[astPtr--], currentElement, 0)); + // insert catch variable in catch block + lastCheckPoint = scanner.startPosition; // force to restart at this exact position + restartRecovery = true; // request to restart from here on + lastIgnoredToken = -1; + } + protected void consumeClassBodyDeclaration() { + // ClassBodyDeclaration ::= Diet Block + //push an Initializer + //optimize the push/pop + nestedMethod[nestedType]--; + Initializer initializer = new Initializer((Block) astStack[astPtr], 0); + intPtr--; // pop sourcestart left on the stack by consumeNestedMethod. + realBlockPtr--; // pop the block variable counter left on the stack by consumeNestedMethod + int javadocCommentStart = intStack[intPtr--]; + if (javadocCommentStart != -1) { + initializer.declarationSourceStart = javadocCommentStart; + } + astStack[astPtr] = initializer; + initializer.sourceEnd = endStatementPosition; + initializer.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); + } + protected void consumeClassBodyDeclarations() { + // ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration + concatNodeLists(); + } + protected void consumeClassBodyDeclarationsopt() { + // ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations + nestedType--; + } + protected void consumeClassBodyopt() { + // ClassBodyopt ::= $empty + pushOnAstStack(null); + endPosition = scanner.startPosition - 1; + } + protected void consumeClassDeclaration() { + // ClassDeclaration ::= ClassHeader ClassBody + + int length; + if ((length = astLengthStack[astLengthPtr--]) != 0) { + //there are length declarations + //dispatch according to the type of the declarations + dispatchDeclarationInto(length); + } + + TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; + + // mark fields and initializer with local type mark if needed + markFieldsWithLocalType(typeDecl); + + //convert constructor that do not have the type's name into methods + boolean hasConstructor = typeDecl.checkConstructors(this); + + //add the default constructor when needed (interface don't have it) + if (!hasConstructor) { + boolean insideFieldInitializer = false; + if (diet) { + for (int i = nestedType; i > 0; i--) { + if (variablesCounter[i] > 0) { + insideFieldInitializer = true; + break; + } + } + } + typeDecl.createsInternalConstructor(!diet || insideFieldInitializer, true); + } + + //always add (will be remove at code gen time if empty) + if (this.scanner.containsAssertKeyword) { + typeDecl.bits |= AstNode.AddAssertionMASK; + } + typeDecl.addClinit(); + typeDecl.bodyEnd = endStatementPosition; + typeDecl.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); + } + protected void consumeClassHeader() { + // ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt + + TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; + if (currentToken == TokenNameLBRACE) { + typeDecl.bodyStart = scanner.currentPosition; + } + if (currentElement != null) { + restartRecovery = true; // used to avoid branching back into the regular automaton + } + // flush the comments related to the class header + scanner.commentPtr = -1; + } + protected void consumeClassHeaderExtends() { + // ClassHeaderExtends ::= 'extends' ClassType + // There is a class declaration on the top of stack + TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; + //superclass + typeDecl.superclass = getTypeReference(0); + typeDecl.bodyStart = typeDecl.superclass.sourceEnd + 1; + // recovery + if (currentElement != null) { + lastCheckPoint = typeDecl.bodyStart; + } + } + protected void consumeClassHeaderImplements() { + // ClassHeaderImplements ::= 'implements' InterfaceTypeList + int length = astLengthStack[astLengthPtr--]; + //super interfaces + astPtr -= length; + // There is a class declaration on the top of stack + TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; + System.arraycopy(astStack, astPtr + 1, typeDecl.superInterfaces = new TypeReference[length], 0, length); + typeDecl.bodyStart = typeDecl.superInterfaces[length - 1].sourceEnd + 1; + listLength = 0; // reset after having read super-interfaces + // recovery + if (currentElement != null) { // is recovering + lastCheckPoint = typeDecl.bodyStart; + } + } + protected void consumeClassHeaderName() { + // ClassHeaderName ::= Modifiersopt 'class' 'Identifier' + TypeDeclaration typeDecl; + if (nestedMethod[nestedType] == 0) { + if (nestedType != 0) { + typeDecl = new MemberTypeDeclaration(this.compilationUnit.compilationResult); + } else { + typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult); + } + } else { + // Record that the block has a declaration for local types + typeDecl = new LocalTypeDeclaration(this.compilationUnit.compilationResult); + markCurrentMethodWithLocalType(); + blockReal(); + } + + //highlight the name of the type + long pos = identifierPositionStack[identifierPtr]; + typeDecl.sourceEnd = (int) pos; + typeDecl.sourceStart = (int) (pos >>> 32); + typeDecl.name = identifierStack[identifierPtr--]; + identifierLengthPtr--; + + //compute the declaration source too + // 'class' and 'interface' push two int positions: the beginning of the class token and its end. + // we want to keep the beginning position but get rid of the end position + // it is only used for the ClassLiteralAccess positions. + typeDecl.declarationSourceStart = intStack[intPtr--]; + intPtr--; // remove the end position of the class token + + typeDecl.modifiersSourceStart = intStack[intPtr--]; + typeDecl.modifiers = intStack[intPtr--]; + if (typeDecl.modifiersSourceStart >= 0) { + typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart; + } + typeDecl.bodyStart = typeDecl.sourceEnd + 1; + pushOnAstStack(typeDecl); + + listLength = 0; // will be updated when reading super-interfaces + // recovery + if (currentElement != null) { + lastCheckPoint = typeDecl.bodyStart; + currentElement = currentElement.add(typeDecl, 0); + lastIgnoredToken = -1; + } + } + protected void consumeClassInstanceCreationExpression() { + // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt + classInstanceCreation(false); + } + protected void consumeClassInstanceCreationExpressionName() { + // ClassInstanceCreationExpressionName ::= Name '.' + pushOnExpressionStack(getUnspecifiedReferenceOptimized()); + } + protected void consumeClassInstanceCreationExpressionQualified() { + // ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt + // ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt + + classInstanceCreation(true); // <-- push the Qualifed.... + + expressionLengthPtr--; + QualifiedAllocationExpression qae = (QualifiedAllocationExpression) expressionStack[expressionPtr--]; + qae.enclosingInstance = expressionStack[expressionPtr]; + expressionStack[expressionPtr] = qae; + qae.sourceStart = qae.enclosingInstance.sourceStart; + } + protected void consumeClassTypeElt() { + // ClassTypeElt ::= ClassType + pushOnAstStack(getTypeReference(0)); + /* if incomplete thrown exception list, listLength counter will not have been reset, + indicating that some items are available on the stack */ + listLength++; + } + protected void consumeClassTypeList() { + // ClassTypeList ::= ClassTypeList ',' ClassTypeElt + optimizedConcatNodeLists(); + } + protected void consumeCompilationUnit() { + // CompilationUnit ::= EnterCompilationUnit PackageDeclarationopt ImportDeclarationsopt + // do nothing by default + } + protected void consumeConditionalExpression(int op) { + // ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' ConditionalExpression + //optimize the push/pop + + expressionPtr -= 2; + expressionLengthPtr -= 2; + expressionStack[expressionPtr] = + new ConditionalExpression( + expressionStack[expressionPtr], + expressionStack[expressionPtr + 1], + expressionStack[expressionPtr + 2]); + } + protected void consumeConstructorBlockStatements() { + // ConstructorBody ::= NestedMethod '{' ExplicitConstructorInvocation BlockStatements '}' + concatNodeLists(); // explictly add the first statement into the list of statements + } + protected void consumeConstructorBody() { + // ConstructorBody ::= NestedMethod '{' BlockStatementsopt '}' + // ConstructorBody ::= NestedMethod '{' ExplicitConstructorInvocation '}' + nestedMethod[nestedType]--; + } + protected void consumeConstructorDeclaration() { + // ConstructorDeclaration ::= ConstructorHeader ConstructorBody + + /* + astStack : MethodDeclaration statements + identifierStack : name + ==> + astStack : MethodDeclaration + identifierStack : + */ + + //must provide a default constructor call when needed + + int length; + + // pop the position of the { (body of the method) pushed in block decl + intPtr--; + + //statements + realBlockPtr--; + ExplicitConstructorCall constructorCall = null; + Statement[] statements = null; + if ((length = astLengthStack[astLengthPtr--]) != 0) { + astPtr -= length; + if (astStack[astPtr + 1] instanceof ExplicitConstructorCall) { + //avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ? + System.arraycopy(astStack, astPtr + 2, statements = new Statement[length - 1], 0, length - 1); + constructorCall = (ExplicitConstructorCall) astStack[astPtr + 1]; + } else { //need to add explicitly the super(); + System.arraycopy(astStack, astPtr + 1, statements = new Statement[length], 0, length); + constructorCall = SuperReference.implicitSuperConstructorCall(); + } + } else { + if (!diet) { + // add it only in non-diet mode, if diet_bodies, then constructor call will be added elsewhere. + constructorCall = SuperReference.implicitSuperConstructorCall(); + } + } + + // now we know that the top of stack is a constructorDeclaration + ConstructorDeclaration cd = (ConstructorDeclaration) astStack[astPtr]; + cd.constructorCall = constructorCall; + cd.statements = statements; + + //highlight of the implicit call on the method name + if (constructorCall != null && cd.constructorCall.sourceEnd == 0) { + cd.constructorCall.sourceEnd = cd.sourceEnd; + cd.constructorCall.sourceStart = cd.sourceStart; + } + + //watch for } that could be given as a unicode ! ( u007D is '}' ) + // store the endPosition (position just before the '}') in case there is + // a trailing comment behind the end of the method + cd.bodyEnd = endPosition; + cd.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); + } + + protected void consumeInvalidConstructorDeclaration() { + // ConstructorDeclaration ::= ConstructorHeader ';' + // now we know that the top of stack is a constructorDeclaration + ConstructorDeclaration cd = (ConstructorDeclaration) astStack[astPtr]; + + cd.bodyEnd = endPosition; // position just before the trailing semi-colon + cd.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); + // report the problem and continue the parsing - narrowing the problem onto the method + } + protected void consumeConstructorHeader() { + // ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters MethodHeaderThrowsClauseopt + + AbstractMethodDeclaration method = (AbstractMethodDeclaration) astStack[astPtr]; + + if (currentToken == TokenNameLBRACE) { + method.bodyStart = scanner.currentPosition; + } + // recovery + if (currentElement != null) { + restartRecovery = true; // used to avoid branching back into the regular automaton + } + } + protected void consumeConstructorHeaderName() { + + /* recovering - might be an empty message send */ + if (currentElement != null) { + if (lastIgnoredToken == TokenNamenew) { // was an allocation expression + lastCheckPoint = scanner.startPosition; // force to restart at this exact position + restartRecovery = true; + return; + } + } + + // ConstructorHeaderName ::= Modifiersopt 'Identifier' '(' + ConstructorDeclaration cd = new ConstructorDeclaration(this.compilationUnit.compilationResult); + + //name -- this is not really revelant but we do ..... + cd.selector = identifierStack[identifierPtr]; + long selectorSource = identifierPositionStack[identifierPtr--]; + identifierLengthPtr--; + + //modifiers + cd.declarationSourceStart = intStack[intPtr--]; + cd.modifiers = intStack[intPtr--]; + + //highlight starts at the selector starts + cd.sourceStart = (int) (selectorSource >>> 32); + pushOnAstStack(cd); + cd.sourceEnd = lParenPos; + cd.bodyStart = lParenPos + 1; + listLength = 0; // initialize listLength before reading parameters/throws + + // recovery + if (currentElement != null) { + lastCheckPoint = cd.bodyStart; + if ((currentElement instanceof RecoveredType && lastIgnoredToken != TokenNameDOT) || cd.modifiers != 0) { + currentElement = currentElement.add(cd, 0); + lastIgnoredToken = -1; + } + } + } + protected void consumeDefaultLabel() { + // SwitchLabel ::= 'default' ':' + pushOnAstStack(new DefaultCase(intStack[intPtr--], intStack[intPtr--])); + } + protected void consumeDefaultModifiers() { + checkAnnotation(); // might update modifiers with AccDeprecated + pushOnIntStack(modifiers); // modifiers + pushOnIntStack(modifiersSourceStart >= 0 ? modifiersSourceStart : scanner.startPosition); + resetModifiers(); + } + protected void consumeDiet() { + // Diet ::= $empty + checkAnnotation(); + pushOnIntStack(modifiersSourceStart); // push the start position of a javadoc comment if there is one + jumpOverMethodBody(); + } + protected void consumeDims() { + // Dims ::= DimsLoop + pushOnIntStack(dimensions); + dimensions = 0; + } + protected void consumeDimWithOrWithOutExpr() { + // DimWithOrWithOutExpr ::= '[' ']' + pushOnExpressionStack(null); + } + protected void consumeDimWithOrWithOutExprs() { + // DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr + concatExpressionLists(); + } + protected void consumeEmptyArgumentListopt() { + // ArgumentListopt ::= $empty + pushOnExpressionStackLengthStack(0); + } + protected void consumeEmptyArrayInitializer() { + // ArrayInitializer ::= '{' ,opt '}' + arrayInitializer(0); + } + protected void consumeEmptyArrayInitializeropt() { + // ArrayInitializeropt ::= $empty + pushOnExpressionStackLengthStack(0); + } + protected void consumeEmptyBlockStatementsopt() { + // BlockStatementsopt ::= $empty + pushOnAstLengthStack(0); + } + protected void consumeEmptyCatchesopt() { + // Catchesopt ::= $empty + pushOnAstLengthStack(0); + } + protected void consumeEmptyClassBodyDeclarationsopt() { + // ClassBodyDeclarationsopt ::= $empty + pushOnAstLengthStack(0); + } + protected void consumeEmptyClassMemberDeclaration() { + // ClassMemberDeclaration ::= ';' + pushOnAstLengthStack(0); + } + protected void consumeEmptyDimsopt() { + // Dimsopt ::= $empty + pushOnIntStack(0); + } + protected void consumeEmptyExpression() { + // Expressionopt ::= $empty + pushOnExpressionStackLengthStack(0); + } + protected void consumeEmptyForInitopt() { + // ForInitopt ::= $empty + pushOnAstLengthStack(0); + } + protected void consumeEmptyForUpdateopt() { + // ForUpdateopt ::= $empty + pushOnExpressionStackLengthStack(0); + } + protected void consumeEmptyImportDeclarationsopt() { + // ImportDeclarationsopt ::= $empty + pushOnAstLengthStack(0); + } + protected void consumeEmptyInterfaceMemberDeclaration() { + // InterfaceMemberDeclaration ::= ';' + pushOnAstLengthStack(0); + } + protected void consumeEmptyInterfaceMemberDeclarationsopt() { + // InterfaceMemberDeclarationsopt ::= $empty + pushOnAstLengthStack(0); + } + protected void consumeEmptyStatement() { + // EmptyStatement ::= ';' + if (this.scanner.source[endStatementPosition] == ';') { + pushOnAstStack(new EmptyStatement(endStatementPosition, endStatementPosition)); + } else { + // we have a Unicode for the ';' (/u003B) + pushOnAstStack(new EmptyStatement(endStatementPosition - 5, endStatementPosition)); + } + } + protected void consumeEmptySwitchBlock() { + // SwitchBlock ::= '{' '}' + pushOnAstLengthStack(0); + } + protected void consumeEmptyTypeDeclaration() { + // TypeDeclaration ::= ';' + pushOnAstLengthStack(0); + } + protected void consumeEmptyTypeDeclarationsopt() { + // TypeDeclarationsopt ::= $empty + pushOnAstLengthStack(0); + } + protected void consumeEnterAnonymousClassBody() { + // EnterAnonymousClassBody ::= $empty + QualifiedAllocationExpression alloc; + AnonymousLocalTypeDeclaration anonymousType = new AnonymousLocalTypeDeclaration(this.compilationUnit.compilationResult); + alloc = anonymousType.allocation = new QualifiedAllocationExpression(anonymousType); + markCurrentMethodWithLocalType(); + pushOnAstStack(anonymousType); + + alloc.sourceEnd = rParenPos; //the position has been stored explicitly + int argumentLength; + if ((argumentLength = expressionLengthStack[expressionLengthPtr--]) != 0) { + expressionPtr -= argumentLength; + System.arraycopy(expressionStack, expressionPtr + 1, alloc.arguments = new Expression[argumentLength], 0, argumentLength); + } + alloc.type = getTypeReference(0); + + anonymousType.sourceEnd = alloc.sourceEnd; + //position at the type while it impacts the anonymous declaration + anonymousType.sourceStart = anonymousType.declarationSourceStart = alloc.type.sourceStart; + alloc.sourceStart = intStack[intPtr--]; + pushOnExpressionStack(alloc); + + anonymousType.bodyStart = scanner.currentPosition; + listLength = 0; // will be updated when reading super-interfaces + // recovery + if (currentElement != null) { + lastCheckPoint = anonymousType.bodyStart; + // the recoveryTokenCheck will deal with the open brace + currentElement = currentElement.add(anonymousType, 0); + currentToken = 0; // opening brace already taken into account + lastIgnoredToken = -1; + } + } + protected void consumeEnterCompilationUnit() { + // EnterCompilationUnit ::= $empty + // do nothing by default + } + protected void consumeEnterVariable() { + // EnterVariable ::= $empty + // do nothing by default + + char[] name = identifierStack[identifierPtr]; + long namePosition = identifierPositionStack[identifierPtr]; + int extendedDimension = intStack[intPtr--]; + AbstractVariableDeclaration declaration; + // create the ast node + boolean isLocalDeclaration = nestedMethod[nestedType] != 0; + if (isLocalDeclaration) { + // create the local variable declarations + declaration = this.createLocalDeclaration(null, name, (int) (namePosition >>> 32), (int) namePosition); + } else { + // create the field declaration + declaration = this.createFieldDeclaration(null, name, (int) (namePosition >>> 32), (int) namePosition); + } + + identifierPtr--; + identifierLengthPtr--; + TypeReference type; + int variableIndex = variablesCounter[nestedType]; + int typeDim = 0; + if (variableIndex == 0) { + // first variable of the declaration (FieldDeclaration or LocalDeclaration) + if (isLocalDeclaration) { + declaration.declarationSourceStart = intStack[intPtr--]; + declaration.modifiers = intStack[intPtr--]; + type = getTypeReference(typeDim = intStack[intPtr--]); // type dimension + if (declaration.declarationSourceStart == -1) { + // this is true if there is no modifiers for the local variable declaration + declaration.declarationSourceStart = type.sourceStart; + } + pushOnAstStack(type); + } else { + type = getTypeReference(typeDim = intStack[intPtr--]); // type dimension + pushOnAstStack(type); + declaration.declarationSourceStart = intStack[intPtr--]; + declaration.modifiers = intStack[intPtr--]; + } + } else { + type = (TypeReference) astStack[astPtr - variableIndex]; + typeDim = type.dimensions(); + AbstractVariableDeclaration previousVariable = (AbstractVariableDeclaration) astStack[astPtr]; + declaration.declarationSourceStart = previousVariable.declarationSourceStart; + declaration.modifiers = previousVariable.modifiers; + } + + if (extendedDimension == 0) { + declaration.type = type; + } else { + int dimension = typeDim + extendedDimension; + //on the identifierLengthStack there is the information about the type.... + int baseType; + if ((baseType = identifierLengthStack[identifierLengthPtr + 1]) < 0) { + //it was a baseType + int typeSourceStart = type.sourceStart; + int typeSourceEnd = type.sourceEnd; + type = TypeReference.baseTypeReference(-baseType, dimension); + type.sourceStart = typeSourceStart; + type.sourceEnd = typeSourceEnd; + declaration.type = type; + } else { + declaration.type = this.copyDims(type, dimension); + } + } + variablesCounter[nestedType]++; + pushOnAstStack(declaration); + // recovery + if (currentElement != null) { + if (!(currentElement instanceof RecoveredType) + && (currentToken == TokenNameDOT //|| declaration.modifiers != 0 + || (scanner.getLineNumber(declaration.type.sourceStart) != scanner.getLineNumber((int) (namePosition >>> 32))))) { + lastCheckPoint = (int) (namePosition >>> 32); + restartRecovery = true; + return; + } + if (isLocalDeclaration) { + LocalDeclaration localDecl = (LocalDeclaration) astStack[astPtr]; + lastCheckPoint = localDecl.sourceEnd + 1; + currentElement = currentElement.add(localDecl, 0); + } else { + FieldDeclaration fieldDecl = (FieldDeclaration) astStack[astPtr]; + lastCheckPoint = fieldDecl.sourceEnd + 1; + currentElement = currentElement.add(fieldDecl, 0); + } + lastIgnoredToken = -1; + } + } + protected void consumeEqualityExpression(int op) { + // EqualityExpression ::= EqualityExpression '==' RelationalExpression + // EqualityExpression ::= EqualityExpression '!=' RelationalExpression + + //optimize the push/pop + + expressionPtr--; + expressionLengthPtr--; + expressionStack[expressionPtr] = new EqualExpression(expressionStack[expressionPtr], expressionStack[expressionPtr + 1], op); + } + protected void consumeExitVariableWithInitialization() { + // ExitVariableWithInitialization ::= $empty + // do nothing by default + expressionLengthPtr--; + AbstractVariableDeclaration variableDecl = (AbstractVariableDeclaration) astStack[astPtr]; + variableDecl.initialization = expressionStack[expressionPtr--]; + // we need to update the declarationSourceEnd of the local variable declaration to the + // source end position of the initialization expression + variableDecl.declarationSourceEnd = variableDecl.initialization.sourceEnd; + variableDecl.declarationEnd = variableDecl.initialization.sourceEnd; + } + protected void consumeExitVariableWithoutInitialization() { + // ExitVariableWithoutInitialization ::= $empty + // do nothing by default + } + protected void consumeExplicitConstructorInvocation(int flag, int recFlag) { + + /* flag allows to distinguish 3 cases : + (0) : + ExplicitConstructorInvocation ::= 'this' '(' ArgumentListopt ')' ';' + ExplicitConstructorInvocation ::= 'super' '(' ArgumentListopt ')' ';' + (1) : + ExplicitConstructorInvocation ::= Primary '.' 'super' '(' ArgumentListopt ')' ';' + ExplicitConstructorInvocation ::= Primary '.' 'this' '(' ArgumentListopt ')' ';' + (2) : + ExplicitConstructorInvocation ::= Name '.' 'super' '(' ArgumentListopt ')' ';' + ExplicitConstructorInvocation ::= Name '.' 'this' '(' ArgumentListopt ')' ';' + */ + int startPosition = intStack[intPtr--]; + ExplicitConstructorCall ecc = new ExplicitConstructorCall(recFlag); + int length; + if ((length = expressionLengthStack[expressionLengthPtr--]) != 0) { + expressionPtr -= length; + System.arraycopy(expressionStack, expressionPtr + 1, ecc.arguments = new Expression[length], 0, length); + } + switch (flag) { + case 0 : + ecc.sourceStart = startPosition; + break; + case 1 : + expressionLengthPtr--; + ecc.sourceStart = (ecc.qualification = expressionStack[expressionPtr--]).sourceStart; + break; + case 2 : + ecc.sourceStart = (ecc.qualification = getUnspecifiedReferenceOptimized()).sourceStart; + break; }; - - public static short check_table[] = null; - public static char lhs[] = null; - public static char action[] = lhs; - private final static String FILEPREFIX = "parser"; //$NON-NLS-1$ - - static { - try{ - initTables(); - } catch(java.io.IOException ex){ - throw new ExceptionInInitializerError(ex.getMessage()); - } - } - - public static final int RoundBracket = 0; - public static final int SquareBracket = 1; - public static final int CurlyBracket = 2; - public static final int BracketKinds = 3; - -public Parser(ProblemReporter problemReporter, boolean optimizeStringLiterals, boolean assertMode) { - - this.problemReporter = problemReporter; - this.optimizeStringLiterals = optimizeStringLiterals; - this.assertMode = assertMode; - this.initializeScanner(); - astLengthStack = new int[50]; - expressionLengthStack = new int[30]; - intStack = new int[50]; - identifierStack = new char[30][]; - identifierLengthStack = new int[30]; - nestedMethod = new int[30]; - realBlockStack = new int[30]; - identifierPositionStack = new long[30]; - variablesCounter = new int[30]; -} -/** - * - * INTERNAL USE-ONLY - */ -protected void adjustInterfaceModifiers() { - intStack[intPtr - 1] |= AccInterface; -} -public final void arrayInitializer(int length) { - //length is the size of the array Initializer - //expressionPtr points on the last elt of the arrayInitializer - //i.e. it has not been decremented yet. - - ArrayInitializer ai = new ArrayInitializer(); - if (length != 0) { - expressionPtr -= length; - System.arraycopy(expressionStack, expressionPtr + 1, ai.expressions = new Expression[length], 0, length); - } - pushOnExpressionStack(ai); - //positionning - ai.sourceEnd = endStatementPosition; - int searchPosition = length == 0 ? endPosition : ai.expressions[0].sourceStart; - try { - //does not work with comments(that contain '{') nor '{' describes as a unicode.... - while (scanner.source[--searchPosition] != '{') { - } - } catch (IndexOutOfBoundsException ex) { - //should never occur (except for strange cases like whose describe above) - searchPosition = (length == 0 ? endPosition : ai.expressions[0].sourceStart) - 1; - } - ai.sourceStart = searchPosition; -} -protected static int asi(int state) { + pushOnAstStack(ecc); + ecc.sourceEnd = endPosition; + } + protected void consumeExpressionStatement() { + // ExpressionStatement ::= StatementExpression ';' + expressionLengthPtr--; + pushOnAstStack(expressionStack[expressionPtr--]); + } + protected void consumeFieldAccess(boolean isSuperAccess) { + // FieldAccess ::= Primary '.' 'Identifier' + // FieldAccess ::= 'super' '.' 'Identifier' + + FieldReference fr = new FieldReference(identifierStack[identifierPtr], identifierPositionStack[identifierPtr--]); + identifierLengthPtr--; + if (isSuperAccess) { + //considerates the fieldReference beginning at the 'super' .... + fr.sourceStart = intStack[intPtr--]; + fr.receiver = new SuperReference(fr.sourceStart, endPosition); + pushOnExpressionStack(fr); + } else { + //optimize push/pop + if ((fr.receiver = expressionStack[expressionPtr]).isThis()) { + //fieldreference begins at the this + fr.sourceStart = fr.receiver.sourceStart; + } + expressionStack[expressionPtr] = fr; + } + } + protected void consumeFieldDeclaration() { + // See consumeLocalVariableDeclarationDefaultModifier() in case of change: duplicated code + // FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';' + + /* + astStack : + expressionStack: Expression Expression ...... Expression + identifierStack : type identifier identifier ...... identifier + intStack : typeDim dim dim dim + ==> + astStack : FieldDeclaration FieldDeclaration ...... FieldDeclaration + expressionStack : + identifierStack : + intStack : + + */ + int variableDeclaratorsCounter = astLengthStack[astLengthPtr]; + + for (int i = variableDeclaratorsCounter - 1; i >= 0; i--) { + FieldDeclaration fieldDeclaration = (FieldDeclaration) astStack[astPtr - i]; + fieldDeclaration.declarationSourceEnd = endStatementPosition; + fieldDeclaration.declarationEnd = endStatementPosition; // semi-colon included + } + updateSourceDeclarationParts(variableDeclaratorsCounter); + int endPos = flushAnnotationsDefinedPriorTo(endStatementPosition); + if (endPos != endStatementPosition) { + for (int i = 0; i < variableDeclaratorsCounter; i++) { + FieldDeclaration fieldDeclaration = (FieldDeclaration) astStack[astPtr - i]; + fieldDeclaration.declarationSourceEnd = endPos; + } + } + // update the astStack, astPtr and astLengthStack + int startIndex = astPtr - variablesCounter[nestedType] + 1; + System.arraycopy(astStack, startIndex, astStack, startIndex - 1, variableDeclaratorsCounter); + astPtr--; // remove the type reference + astLengthStack[--astLengthPtr] = variableDeclaratorsCounter; + + // recovery + if (currentElement != null) { + lastCheckPoint = endPos + 1; + if (currentElement.parent != null && currentElement instanceof RecoveredField) { + currentElement = currentElement.parent; + } + restartRecovery = true; + } + variablesCounter[nestedType] = 0; + } + protected void consumeForceNoDiet() { + // ForceNoDiet ::= $empty + dietInt++; + } + protected void consumeForInit() { + // ForInit ::= StatementExpressionList + pushOnAstLengthStack(-1); + } + protected void consumeFormalParameter() { + // FormalParameter ::= Type VariableDeclaratorId ==> false + // FormalParameter ::= Modifiers Type VariableDeclaratorId ==> true + /* + astStack : + identifierStack : type identifier + intStack : dim dim + ==> + astStack : Argument + identifierStack : + intStack : + */ + + identifierLengthPtr--; + char[] name = identifierStack[identifierPtr]; + long namePositions = identifierPositionStack[identifierPtr--]; + TypeReference type = getTypeReference(intStack[intPtr--] + intStack[intPtr--]); + int modifierPositions = intStack[intPtr--]; + intPtr--; + Argument arg = new Argument(name, namePositions, type, intStack[intPtr + 1] & ~AccDeprecated); // modifiers + arg.declarationSourceStart = modifierPositions; + pushOnAstStack(arg); + + /* if incomplete method header, listLength counter will not have been reset, + indicating that some arguments are available on the stack */ + listLength++; + } + protected void consumeFormalParameterList() { + // FormalParameterList ::= FormalParameterList ',' FormalParameter + optimizedConcatNodeLists(); + } + protected void consumeFormalParameterListopt() { + // FormalParameterListopt ::= $empty + pushOnAstLengthStack(0); + } + protected void consumeImportDeclarations() { + // ImportDeclarations ::= ImportDeclarations ImportDeclaration + optimizedConcatNodeLists(); + } + protected void consumeImportDeclarationsopt() { + // ImportDeclarationsopt ::= ImportDeclarations + int length; + if ((length = astLengthStack[astLengthPtr--]) != 0) { + astPtr -= length; + System.arraycopy(astStack, astPtr + 1, compilationUnit.imports = new ImportReference[length], 0, length); + } + } + protected void consumeInstanceOfExpression(int op) { + // RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType + //optimize the push/pop + + //by construction, no base type may be used in getTypeReference + Expression exp; + expressionStack[expressionPtr] = + exp = new InstanceOfExpression(expressionStack[expressionPtr], getTypeReference(intStack[intPtr--]), op); + if (exp.sourceEnd == 0) { + //array on base type.... + exp.sourceEnd = scanner.startPosition - 1; + } + //the scanner is on the next token already.... + } + protected void consumeInterfaceDeclaration() { + // see consumeClassDeclaration in case of changes: duplicated code + // InterfaceDeclaration ::= InterfaceHeader InterfaceBody + int length; + if ((length = astLengthStack[astLengthPtr--]) != 0) { + //there are length declarations + //dispatch.....according to the type of the declarations + dispatchDeclarationInto(length); + } + + TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; + + // mark fields and initializer with local type mark if needed + markFieldsWithLocalType(typeDecl); + + //convert constructor that do not have the type's name into methods + typeDecl.checkConstructors(this); + + //always add (will be remove at code gen time if empty) + if (this.scanner.containsAssertKeyword) { + typeDecl.bits |= AstNode.AddAssertionMASK; + } + typeDecl.addClinit(); + typeDecl.bodyEnd = endStatementPosition; + typeDecl.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); + } + protected void consumeInterfaceHeader() { + // InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt + + TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; + if (currentToken == TokenNameLBRACE) { + typeDecl.bodyStart = scanner.currentPosition; + } + if (currentElement != null) { + restartRecovery = true; // used to avoid branching back into the regular automaton + } + // flush the comments related to the interface header + scanner.commentPtr = -1; + } + protected void consumeInterfaceHeaderExtends() { + // InterfaceHeaderExtends ::= 'extends' InterfaceTypeList + int length = astLengthStack[astLengthPtr--]; + //super interfaces + astPtr -= length; + TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; + System.arraycopy(astStack, astPtr + 1, typeDecl.superInterfaces = new TypeReference[length], 0, length); + typeDecl.bodyStart = typeDecl.superInterfaces[length - 1].sourceEnd + 1; + listLength = 0; // reset after having read super-interfaces + // recovery + if (currentElement != null) { + lastCheckPoint = typeDecl.bodyStart; + } + } + protected void consumeInterfaceHeaderName() { + // InterfaceHeaderName ::= Modifiersopt 'interface' 'Identifier' + TypeDeclaration typeDecl; + if (nestedMethod[nestedType] == 0) { + if (nestedType != 0) { + typeDecl = new MemberTypeDeclaration(this.compilationUnit.compilationResult); + } else { + typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult); + } + } else { + // Record that the block has a declaration for local types + typeDecl = new LocalTypeDeclaration(this.compilationUnit.compilationResult); + markCurrentMethodWithLocalType(); + blockReal(); + } + + //highlight the name of the type + long pos = identifierPositionStack[identifierPtr]; + typeDecl.sourceEnd = (int) pos; + typeDecl.sourceStart = (int) (pos >>> 32); + typeDecl.name = identifierStack[identifierPtr--]; + identifierLengthPtr--; + + //compute the declaration source too + // 'class' and 'interface' push two int positions: the beginning of the class token and its end. + // we want to keep the beginning position but get rid of the end position + // it is only used for the ClassLiteralAccess positions. + typeDecl.declarationSourceStart = intStack[intPtr--]; + intPtr--; // remove the end position of the class token + typeDecl.modifiersSourceStart = intStack[intPtr--]; + typeDecl.modifiers = intStack[intPtr--]; + if (typeDecl.modifiersSourceStart >= 0) { + typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart; + } + typeDecl.bodyStart = typeDecl.sourceEnd + 1; + pushOnAstStack(typeDecl); + listLength = 0; // will be updated when reading super-interfaces + // recovery + if (currentElement != null) { // is recovering + lastCheckPoint = typeDecl.bodyStart; + currentElement = currentElement.add(typeDecl, 0); + lastIgnoredToken = -1; + } + } + protected void consumeInterfaceMemberDeclarations() { + // InterfaceMemberDeclarations ::= InterfaceMemberDeclarations InterfaceMemberDeclaration + concatNodeLists(); + } + protected void consumeInterfaceMemberDeclarationsopt() { + // InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations + nestedType--; + } + protected void consumeInterfaceType() { + // InterfaceType ::= ClassOrInterfaceType + pushOnAstStack(getTypeReference(0)); + /* if incomplete type header, listLength counter will not have been reset, + indicating that some interfaces are available on the stack */ + listLength++; + } + protected void consumeInterfaceTypeList() { + // InterfaceTypeList ::= InterfaceTypeList ',' InterfaceType + optimizedConcatNodeLists(); + } + protected void consumeLeftHandSide() { + // LeftHandSide ::= Name + + pushOnExpressionStack(getUnspecifiedReferenceOptimized()); + } + protected void consumeLeftParen() { + // PushLPAREN ::= '(' + pushOnIntStack(lParenPos); + } + protected void consumeLocalVariableDeclaration() { + // LocalVariableDeclaration ::= Modifiers Type VariableDeclarators ';' + + /* + astStack : + expressionStack: Expression Expression ...... Expression + identifierStack : type identifier identifier ...... identifier + intStack : typeDim dim dim dim + ==> + astStack : FieldDeclaration FieldDeclaration ...... FieldDeclaration + expressionStack : + identifierStack : + intStack : + + */ + int variableDeclaratorsCounter = astLengthStack[astLengthPtr]; + + // update the astStack, astPtr and astLengthStack + int startIndex = astPtr - variablesCounter[nestedType] + 1; + System.arraycopy(astStack, startIndex, astStack, startIndex - 1, variableDeclaratorsCounter); + astPtr--; // remove the type reference + astLengthStack[--astLengthPtr] = variableDeclaratorsCounter; + variablesCounter[nestedType] = 0; + } + protected void consumeLocalVariableDeclarationStatement() { + // LocalVariableDeclarationStatement ::= LocalVariableDeclaration ';' + // see blockReal in case of change: duplicated code + // increment the amount of declared variables for this block + realBlockStack[realBlockPtr]++; + } + protected void consumeMethodBody() { + // MethodBody ::= NestedMethod '{' BlockStatementsopt '}' + nestedMethod[nestedType]--; + } + protected void consumeMethodDeclaration(boolean isNotAbstract) { + // MethodDeclaration ::= MethodHeader MethodBody + // AbstractMethodDeclaration ::= MethodHeader ';' + + /* + astStack : modifiers arguments throws statements + identifierStack : type name + intStack : dim dim dim + ==> + astStack : MethodDeclaration + identifierStack : + intStack : + */ + + int length; + if (isNotAbstract) { + // pop the position of the { (body of the method) pushed in block decl + intPtr--; + } + + int explicitDeclarations = 0; + Statement[] statements = null; + if (isNotAbstract) { + //statements + explicitDeclarations = realBlockStack[realBlockPtr--]; + if ((length = astLengthStack[astLengthPtr--]) != 0) + System.arraycopy(astStack, (astPtr -= length) + 1, statements = new Statement[length], 0, length); + } + + // now we know that we have a method declaration at the top of the ast stack + MethodDeclaration md = (MethodDeclaration) astStack[astPtr]; + md.statements = statements; + md.explicitDeclarations = explicitDeclarations; + + // cannot be done in consumeMethodHeader because we have no idea whether or not there + // is a body when we reduce the method header + if (!isNotAbstract) { //remember the fact that the method has a semicolon body + md.modifiers |= AccSemicolonBody; + } + // store the endPosition (position just before the '}') in case there is + // a trailing comment behind the end of the method + md.bodyEnd = endPosition; + md.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); + } + protected void consumeMethodHeader() { + // MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims ThrowsClauseopt + // retrieve end position of method declarator + AbstractMethodDeclaration method = (AbstractMethodDeclaration) astStack[astPtr]; + + if (currentToken == TokenNameLBRACE) { + method.bodyStart = scanner.currentPosition; + } + // recovery + if (currentElement != null) { + if (currentToken == TokenNameSEMICOLON) { + method.modifiers |= AccSemicolonBody; + method.declarationSourceEnd = scanner.currentPosition - 1; + method.bodyEnd = scanner.currentPosition - 1; + if (currentElement.parent != null) { + currentElement = currentElement.parent; + } + } + restartRecovery = true; // used to avoid branching back into the regular automaton + } + } + protected void consumeMethodHeaderExtendedDims() { + // MethodHeaderExtendedDims ::= Dimsopt + // now we update the returnType of the method + MethodDeclaration md = (MethodDeclaration) astStack[astPtr]; + int extendedDims = intStack[intPtr--]; + if (extendedDims != 0) { + TypeReference returnType = md.returnType; + md.sourceEnd = endPosition; + int dims = returnType.dimensions() + extendedDims; + int baseType; + if ((baseType = identifierLengthStack[identifierLengthPtr + 1]) < 0) { + //it was a baseType + int sourceStart = returnType.sourceStart; + int sourceEnd = returnType.sourceEnd; + returnType = TypeReference.baseTypeReference(-baseType, dims); + returnType.sourceStart = sourceStart; + returnType.sourceEnd = sourceEnd; + md.returnType = returnType; + } else { + md.returnType = this.copyDims(md.returnType, dims); + } + if (currentToken == TokenNameLBRACE) { + md.bodyStart = endPosition + 1; + } + // recovery + if (currentElement != null) { + lastCheckPoint = md.bodyStart; + } + } + } + protected void consumeMethodHeaderName() { + // MethodHeaderName ::= Modifiersopt Type 'Identifier' '(' + MethodDeclaration md = new MethodDeclaration(this.compilationUnit.compilationResult); + + //name + md.selector = identifierStack[identifierPtr]; + long selectorSource = identifierPositionStack[identifierPtr--]; + identifierLengthPtr--; + //type + md.returnType = getTypeReference(intStack[intPtr--]); + //modifiers + md.declarationSourceStart = intStack[intPtr--]; + md.modifiers = intStack[intPtr--]; + + //highlight starts at selector start + md.sourceStart = (int) (selectorSource >>> 32); + pushOnAstStack(md); + md.sourceEnd = lParenPos; + md.bodyStart = lParenPos + 1; + listLength = 0; // initialize listLength before reading parameters/throws + + // recovery + if (currentElement != null) { + if (currentElement instanceof RecoveredType //|| md.modifiers != 0 + || (scanner.getLineNumber(md.returnType.sourceStart) == scanner.getLineNumber(md.sourceStart))) { + lastCheckPoint = md.bodyStart; + currentElement = currentElement.add(md, 0); + lastIgnoredToken = -1; + } else { + lastCheckPoint = md.sourceStart; + restartRecovery = true; + } + } + } + protected void consumeMethodHeaderParameters() { + // MethodHeaderParameters ::= FormalParameterListopt ')' + int length = astLengthStack[astLengthPtr--]; + astPtr -= length; + AbstractMethodDeclaration md = (AbstractMethodDeclaration) astStack[astPtr]; + md.sourceEnd = rParenPos; + //arguments + if (length != 0) { + System.arraycopy(astStack, astPtr + 1, md.arguments = new Argument[length], 0, length); + } + md.bodyStart = rParenPos + 1; + listLength = 0; // reset listLength after having read all parameters + // recovery + if (currentElement != null) { + lastCheckPoint = md.bodyStart; + if (currentElement.parseTree() == md) + return; + + // might not have been attached yet - in some constructor scenarii + if (md.isConstructor()) { + if ((length != 0) || (currentToken == TokenNameLBRACE) // || (currentToken == TokenNamethrows) + ) { + currentElement = currentElement.add(md, 0); + lastIgnoredToken = -1; + } + } + } + } + protected void consumeMethodHeaderThrowsClause() { + // MethodHeaderThrowsClause ::= 'throws' ClassTypeList + int length = astLengthStack[astLengthPtr--]; + astPtr -= length; + AbstractMethodDeclaration md = (AbstractMethodDeclaration) astStack[astPtr]; + System.arraycopy(astStack, astPtr + 1, md.thrownExceptions = new TypeReference[length], 0, length); + md.sourceEnd = md.thrownExceptions[length - 1].sourceEnd; + md.bodyStart = md.thrownExceptions[length - 1].sourceEnd + 1; + listLength = 0; // reset listLength after having read all thrown exceptions + // recovery + if (currentElement != null) { + lastCheckPoint = md.bodyStart; + } + } + protected void consumeMethodInvocationName() { + // MethodInvocation ::= Name '(' ArgumentListopt ')' + + // when the name is only an identifier...we have a message send to "this" (implicit) + + MessageSend m = newMessageSend(); + m.sourceEnd = rParenPos; + m.sourceStart = (int) ((m.nameSourcePosition = identifierPositionStack[identifierPtr]) >>> 32); + m.selector = identifierStack[identifierPtr--]; + if (identifierLengthStack[identifierLengthPtr] == 1) { + m.receiver = ThisReference.ThisImplicit; + identifierLengthPtr--; + } else { + identifierLengthStack[identifierLengthPtr]--; + m.receiver = getUnspecifiedReference(); + m.sourceStart = m.receiver.sourceStart; + } + pushOnExpressionStack(m); + } + protected void consumeMethodInvocationPrimary() { + //optimize the push/pop + //MethodInvocation ::= Primary '.' 'Identifier' '(' ArgumentListopt ')' + + MessageSend m = newMessageSend(); + m.sourceStart = (int) ((m.nameSourcePosition = identifierPositionStack[identifierPtr]) >>> 32); + m.selector = identifierStack[identifierPtr--]; + identifierLengthPtr--; + m.receiver = expressionStack[expressionPtr]; + m.sourceStart = m.receiver.sourceStart; + m.sourceEnd = rParenPos; + expressionStack[expressionPtr] = m; + } + protected void consumeMethodInvocationSuper() { + // MethodInvocation ::= 'super' '.' 'Identifier' '(' ArgumentListopt ')' + + MessageSend m = newMessageSend(); + m.sourceStart = intStack[intPtr--]; + m.sourceEnd = rParenPos; + m.nameSourcePosition = identifierPositionStack[identifierPtr]; + m.selector = identifierStack[identifierPtr--]; + identifierLengthPtr--; + m.receiver = new SuperReference(m.sourceStart, endPosition); + pushOnExpressionStack(m); + } + protected void consumeMethodPushModifiersHeaderName() { + // MethodPushModifiersHeaderName ::= Modifiers Type PushModifiers 'Identifier' '(' + // MethodPushModifiersHeaderName ::= Type PushModifiers 'Identifier' '(' + MethodDeclaration md = new MethodDeclaration(this.compilationUnit.compilationResult); + + //name + md.selector = identifierStack[identifierPtr]; + long selectorSource = identifierPositionStack[identifierPtr--]; + identifierLengthPtr--; + + //modifiers + md.declarationSourceStart = intStack[intPtr--]; + md.modifiers = intStack[intPtr--]; + + //type + md.returnType = getTypeReference(intStack[intPtr--]); + + //highlight starts at selector start + md.sourceStart = (int) (selectorSource >>> 32); + pushOnAstStack(md); + md.sourceEnd = lParenPos; + md.bodyStart = lParenPos + 1; + listLength = 0; // initialize listLength before reading parameters/throws + + // recovery + if (currentElement != null) { + lastCheckPoint = md.bodyStart; + currentElement = currentElement.add(md, 0); + lastIgnoredToken = -1; + } + } + protected void consumeModifiers() { + int savedModifiersSourceStart = modifiersSourceStart; + checkAnnotation(); // might update modifiers with AccDeprecated + pushOnIntStack(modifiers); // modifiers + if (modifiersSourceStart >= savedModifiersSourceStart) { + modifiersSourceStart = savedModifiersSourceStart; + } + pushOnIntStack(modifiersSourceStart); + resetModifiers(); + } + protected void consumeNestedMethod() { + // NestedMethod ::= $empty + jumpOverMethodBody(); + nestedMethod[nestedType]++; + consumeOpenBlock(); + } + protected void consumeNestedType() { + // NestedType ::= $empty + nestedType++; + try { + nestedMethod[nestedType] = 0; + } catch (IndexOutOfBoundsException e) { + //except in test's cases, it should never raise + int oldL = nestedMethod.length; + System.arraycopy(nestedMethod, 0, (nestedMethod = new int[oldL + 30]), 0, oldL); + nestedMethod[nestedType] = 0; + // increase the size of the fieldsCounter as well. It has to be consistent with the size of the nestedMethod collection + System.arraycopy(variablesCounter, 0, (variablesCounter = new int[oldL + 30]), 0, oldL); + } + variablesCounter[nestedType] = 0; + } + protected void consumeOneDimLoop() { + // OneDimLoop ::= '[' ']' + dimensions++; + } + protected void consumeOnlySynchronized() { + // OnlySynchronized ::= 'synchronized' + pushOnIntStack(this.synchronizedBlockSourceStart); + resetModifiers(); + } + protected void consumeOpenBlock() { + // OpenBlock ::= $empty + + pushOnIntStack(scanner.startPosition); + try { + realBlockStack[++realBlockPtr] = 0; + } catch (IndexOutOfBoundsException e) { + //realBlockPtr is correct + int oldStackLength = realBlockStack.length; + int oldStack[] = realBlockStack; + realBlockStack = new int[oldStackLength + StackIncrement]; + System.arraycopy(oldStack, 0, realBlockStack, 0, oldStackLength); + realBlockStack[realBlockPtr] = 0; + } + } + protected void consumePackageDeclaration() { + // PackageDeclaration ::= 'package' Name ';' + /* build an ImportRef build from the last name + stored in the identifier stack. */ + + ImportReference impt = compilationUnit.currentPackage; + // flush annotations defined prior to import statements + impt.declarationEnd = endStatementPosition; + impt.declarationSourceEnd = this.flushAnnotationsDefinedPriorTo(impt.declarationSourceEnd); + } + protected void consumePackageDeclarationName() { + // PackageDeclarationName ::= 'package' Name + /* build an ImportRef build from the last name + stored in the identifier stack. */ + + ImportReference impt; + int length; + char[][] tokens = new char[length = identifierLengthStack[identifierLengthPtr--]][]; + identifierPtr -= length; + long[] positions = new long[length]; + System.arraycopy(identifierStack, ++identifierPtr, tokens, 0, length); + System.arraycopy(identifierPositionStack, identifierPtr--, positions, 0, length); + compilationUnit.currentPackage = impt = new ImportReference(tokens, positions, true); + + if (currentToken == TokenNameSEMICOLON) { + impt.declarationSourceEnd = scanner.currentPosition - 1; + } else { + impt.declarationSourceEnd = impt.sourceEnd; + } + impt.declarationEnd = impt.declarationSourceEnd; + //endPosition is just before the ; + impt.declarationSourceStart = intStack[intPtr--]; + + // recovery + if (currentElement != null) { + lastCheckPoint = impt.declarationSourceEnd + 1; + restartRecovery = true; // used to avoid branching back into the regular automaton + } + } + protected void consumePostfixExpression() { + // PostfixExpression ::= Name + pushOnExpressionStack(getUnspecifiedReferenceOptimized()); + } + protected void consumePrimaryNoNewArray() { + // PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN + updateSourcePosition(expressionStack[expressionPtr]); + } + protected void consumePrimaryNoNewArrayArrayType() { + // PrimaryNoNewArray ::= ArrayType '.' 'class' + intPtr--; + pushOnExpressionStack(new ClassLiteralAccess(intStack[intPtr--], getTypeReference(intStack[intPtr--]))); + } + protected void consumePrimaryNoNewArrayName() { + // PrimaryNoNewArray ::= Name '.' 'class' + intPtr--; + pushOnExpressionStack(new ClassLiteralAccess(intStack[intPtr--], getTypeReference(0))); + } + protected void consumePrimaryNoNewArrayNameSuper() { + // PrimaryNoNewArray ::= Name '.' 'super' + pushOnExpressionStack(new QualifiedSuperReference(getTypeReference(0), intStack[intPtr--], endPosition)); + } + protected void consumePrimaryNoNewArrayNameThis() { + // PrimaryNoNewArray ::= Name '.' 'this' + pushOnExpressionStack(new QualifiedThisReference(getTypeReference(0), intStack[intPtr--], endPosition)); + } + protected void consumePrimaryNoNewArrayPrimitiveType() { + // PrimaryNoNewArray ::= PrimitiveType '.' 'class' + intPtr--; + pushOnExpressionStack(new ClassLiteralAccess(intStack[intPtr--], getTypeReference(0))); + } + protected void consumePrimaryNoNewArrayThis() { + // PrimaryNoNewArray ::= 'this' + pushOnExpressionStack(new ThisReference(intStack[intPtr--], endPosition)); + } + protected void consumePrimitiveType() { + // Type ::= PrimitiveType + pushOnIntStack(0); + } + protected void consumePushModifiers() { + if ((modifiers & AccSynchronized) != 0) { + /* remove the starting position of the synchronized keyword + * we don't need it when synchronized is part of the modifiers + */ + intPtr--; + } + pushOnIntStack(modifiers); // modifiers + pushOnIntStack(modifiersSourceStart); + resetModifiers(); + } + protected void consumePushPosition() { + // for source managment purpose + // PushPosition ::= $empty + pushOnIntStack(endPosition); + } + protected void consumeQualifiedName() { + // QualifiedName ::= Name '.' SimpleName + /*back from the recursive loop of QualifiedName. + Updates identifier length into the length stack*/ + + identifierLengthStack[--identifierLengthPtr]++; + } + protected void consumeReferenceType() { + // ReferenceType ::= ClassOrInterfaceType + pushOnIntStack(0); + } + protected void consumeRestoreDiet() { + // RestoreDiet ::= $empty + dietInt--; + } + protected void consumeRightParen() { + // PushRPAREN ::= ')' + pushOnIntStack(rParenPos); + } + // This method is part of an automatic generation : do NOT edit-modify + // This method is part of an automatic generation : do NOT edit-modify + protected void consumeRule(int act) { + switch (act) { + case 29 : // System.out.println("Type ::= PrimitiveType"); + consumePrimitiveType(); + break; + + case 43 : // System.out.println("ReferenceType ::= ClassOrInterfaceType"); + consumeReferenceType(); + break; + + case 52 : // System.out.println("QualifiedName ::= Name DOT SimpleName"); + consumeQualifiedName(); + break; + + case 53 : // System.out.println("CompilationUnit ::= EnterCompilationUnit PackageDeclarationopt ImportDeclarationsopt"); + consumeCompilationUnit(); + break; + + case 54 : // System.out.println("EnterCompilationUnit ::="); + consumeEnterCompilationUnit(); + break; + + case 66 : // System.out.println("CatchHeader ::= catch LPAREN FormalParameter RPAREN LBRACE"); + consumeCatchHeader(); + break; + + case 68 : // System.out.println("ImportDeclarations ::= ImportDeclarations ImportDeclaration"); + consumeImportDeclarations(); + break; + + case 70 : // System.out.println("TypeDeclarations ::= TypeDeclarations TypeDeclaration"); + consumeTypeDeclarations(); + break; + + case 71 : // System.out.println("PackageDeclaration ::= PackageDeclarationName SEMICOLON"); + consumePackageDeclaration(); + break; + + case 72 : // System.out.println("PackageDeclarationName ::= package Name"); + consumePackageDeclarationName(); + break; + + case 75 : // System.out.println("SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName SEMICOLON"); + consumeSingleTypeImportDeclaration(); + break; + + case 76 : // System.out.println("SingleTypeImportDeclarationName ::= import Name"); + consumeSingleTypeImportDeclarationName(); + break; + + case 77 : // System.out.println("TypeImportOnDemandDeclaration ::= TypeImportOnDemandDeclarationName SEMICOLON"); + consumeTypeImportOnDemandDeclaration(); + break; + + case 78 : // System.out.println("TypeImportOnDemandDeclarationName ::= import Name DOT MULTIPLY"); + consumeTypeImportOnDemandDeclarationName(); + break; + + case 81 : // System.out.println("TypeDeclaration ::= SEMICOLON"); + consumeEmptyTypeDeclaration(); + break; + + case 95 : // System.out.println("ClassDeclaration ::= ClassHeader ClassBody"); + consumeClassDeclaration(); + break; + + case 96 : // System.out.println("ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt"); + consumeClassHeader(); + break; + + case 97 : // System.out.println("ClassHeaderName ::= Modifiersopt class Identifier"); + consumeClassHeaderName(); + break; + + case 98 : // System.out.println("ClassHeaderExtends ::= extends ClassType"); + consumeClassHeaderExtends(); + break; + + case 99 : // System.out.println("ClassHeaderImplements ::= implements InterfaceTypeList"); + consumeClassHeaderImplements(); + break; + + case 101 : // System.out.println("InterfaceTypeList ::= InterfaceTypeList COMMA InterfaceType"); + consumeInterfaceTypeList(); + break; + + case 102 : // System.out.println("InterfaceType ::= ClassOrInterfaceType"); + consumeInterfaceType(); + break; + + case 105 : // System.out.println("ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration"); + consumeClassBodyDeclarations(); + break; + + case 109 : // System.out.println("ClassBodyDeclaration ::= Diet NestedMethod Block"); + consumeClassBodyDeclaration(); + break; + + case 110 : // System.out.println("Diet ::="); + consumeDiet(); + break; + + case 111 : // System.out.println("Initializer ::= Diet NestedMethod Block"); + consumeClassBodyDeclaration(); + break; - return asb[original_state(state)]; -} -protected void blockReal() { - // See consumeLocalVariableDeclarationStatement in case of change: duplicated code - // increment the amount of declared variables for this block - realBlockStack[realBlockPtr]++; -} -private final static void buildFileFor(String filename, String tag, String[] tokens, boolean isShort) throws java.io.IOException { - - //transform the String tokens into chars before dumping then into file - - int i = 0; - //read upto the tag - while (!tokens[i++].equals(tag)) {} - //read upto the } - char[] chars = new char[tokens.length]; //can't be bigger - int ic = 0; - String token; - while (!(token = tokens[i++]).equals("}")) { //$NON-NLS-1$ - int c = Integer.parseInt(token); - if (isShort) - c += 32768; - chars[ic++] = (char) c; - } - - //resize - System.arraycopy(chars, 0, chars = new char[ic], 0, ic); - - buildFileForTable(filename, chars); -} -private final static void buildFileForTable(String filename, char[] chars) throws java.io.IOException { - - byte[] bytes = new byte[chars.length * 2]; - for (int i = 0; i < chars.length; i++) { - bytes[2 * i] = (byte) (chars[i] >>> 8); - bytes[2 * i + 1] = (byte) (chars[i] & 0xFF); - } - - java.io.FileOutputStream stream = new java.io.FileOutputStream(filename); - stream.write(bytes); - stream.close(); - System.out.println(filename + " creation complete"); //$NON-NLS-1$ -} -public final static void buildFilesFromLPG(String dataFilename) throws java.io.IOException { - - //RUN THIS METHOD TO GENERATE PARSER*.RSC FILES - - //build from the lpg javadcl.java files that represents the parser tables - //lhs check_table asb asr symbol_index - - //[org.eclipse.jdt.internal.compiler.parser.Parser.buildFilesFromLPG("d:/leapfrog/grammar/javadcl.java")] - - char[] contents = new char[] {}; - try { - contents = Util.getFileCharContent(new File(dataFilename), null); - } catch (IOException ex) { - System.out.println(Util.bind("parser.incorrectPath")); //$NON-NLS-1$ - return; - } - java.util.StringTokenizer st = - new java.util.StringTokenizer(new String(contents), " \t\n\r[]={,;"); //$NON-NLS-1$ - String[] tokens = new String[st.countTokens()]; - int i = 0; - while (st.hasMoreTokens()) { - tokens[i++] = st.nextToken(); - } - final String prefix = FILEPREFIX; - i = 0; - buildFileFor(prefix + (++i) + ".rsc", "lhs", tokens, false); //$NON-NLS-2$ //$NON-NLS-1$ - buildFileFor(prefix + (++i) + ".rsc", "check_table", tokens, true); //$NON-NLS-2$ //$NON-NLS-1$ - buildFileFor(prefix + (++i) + ".rsc", "asb", tokens, false); //$NON-NLS-2$ //$NON-NLS-1$ - buildFileFor(prefix + (++i) + ".rsc", "asr", tokens, false); //$NON-NLS-2$ //$NON-NLS-1$ - buildFileFor(prefix + (++i) + ".rsc", "symbol_index", tokens, false); //$NON-NLS-2$ //$NON-NLS-1$ - System.out.println(Util.bind("parser.moveFiles")); //$NON-NLS-1$ -} -/* - * Build initial recovery state. - * Recovery state is inferred from the current state of the parser (reduced node stack). - */ -public RecoveredElement buildInitialRecoveryState(){ - - /* initialize recovery by retrieving available reduced nodes - * also rebuild bracket balance - */ - lastCheckPoint = 0; - - RecoveredElement element = null; - if (referenceContext instanceof CompilationUnitDeclaration){ - element = new RecoveredUnit(compilationUnit, 0, this); - - /* ignore current stack state, since restarting from the beginnning - since could not trust simple brace count */ - if (true){ // experimenting restart recovery from scratch - compilationUnit.currentPackage = null; - compilationUnit.imports = null; - compilationUnit.types = null; - currentToken = 0; - listLength = 0; - return element; - } - if (compilationUnit.currentPackage != null){ - lastCheckPoint = compilationUnit.currentPackage.declarationSourceEnd+1; - } - if (compilationUnit.imports != null){ - lastCheckPoint = compilationUnit.imports[compilationUnit.imports.length -1].declarationSourceEnd+1; - } - } else { - if (referenceContext instanceof AbstractMethodDeclaration){ - element = new RecoveredMethod((AbstractMethodDeclaration) referenceContext, null, 0, this); - lastCheckPoint = ((AbstractMethodDeclaration) referenceContext).bodyStart; - } else { - /* Initializer bodies are parsed in the context of the type declaration, we must thus search it inside */ - if (referenceContext instanceof TypeDeclaration){ - TypeDeclaration type = (TypeDeclaration) referenceContext; - for (int i = 0; i < type.fields.length; i++){ - FieldDeclaration field = type.fields[i]; - if (!field.isField() - && field.declarationSourceStart <= scanner.initialPosition - && scanner.initialPosition <= field.declarationSourceEnd - && scanner.eofPosition <= field.declarationSourceEnd+1){ - element = new RecoveredInitializer((Initializer) field, null, 1, this); - lastCheckPoint = field.declarationSourceStart; - break; - } - } - } - } - } - - if (element == null) return element; - - for(int i = 0; i <= astPtr; i++){ - AstNode node = astStack[i]; - if (node instanceof AbstractMethodDeclaration){ - AbstractMethodDeclaration method = (AbstractMethodDeclaration) node; - if (method.declarationSourceEnd == 0){ - element = element.add(method, 0); - lastCheckPoint = method.bodyStart; - } else { - element = element.add(method, 0); - lastCheckPoint = method.declarationSourceEnd + 1; - } - continue; - } - if (node instanceof Initializer){ - Initializer initializer = (Initializer) node; - if (initializer.declarationSourceEnd == 0){ - element = element.add(initializer, 1); - lastCheckPoint = initializer.bodyStart; - } else { - element = element.add(initializer, 0); - lastCheckPoint = initializer.declarationSourceEnd + 1; - } - continue; - } - if (node instanceof FieldDeclaration){ - FieldDeclaration field = (FieldDeclaration) node; - if (field.declarationSourceEnd == 0){ - element = element.add(field, 0); - if (field.initialization == null){ - lastCheckPoint = field.sourceEnd + 1; - } else { - lastCheckPoint = field.initialization.sourceEnd + 1; - } - } else { - element = element.add(field, 0); - lastCheckPoint = field.declarationSourceEnd + 1; - } - continue; - } - if (node instanceof TypeDeclaration){ - TypeDeclaration type = (TypeDeclaration) node; - if (type.declarationSourceEnd == 0){ - element = element.add(type, 0); - lastCheckPoint = type.bodyStart; - } else { - element = element.add(type, 0); - lastCheckPoint = type.declarationSourceEnd + 1; - } - continue; - } - if (node instanceof ImportReference){ - ImportReference importRef = (ImportReference) node; - element = element.add(importRef, 0); - lastCheckPoint = importRef.declarationSourceEnd + 1; - } - } - return element; -} -protected static short check(int i) { - return check_table[i - (NUM_RULES + 1)]; -} -/* - * Reconsider the entire source looking for inconsistencies in {} () [] - */ -public boolean checkAndReportBracketAnomalies(ProblemReporter problemReporter) { - - scanner.wasAcr = false; - boolean anomaliesDetected = false; - try { - char[] source = scanner.source; - int[] leftCount = {0, 0, 0}; - int[] rightCount = {0, 0, 0}; - int[] depths = {0, 0, 0}; - int[][] leftPositions = new int[][] {new int[10], new int[10], new int[10]}; - int[][] leftDepths = new int[][] {new int[10], new int[10], new int[10]}; - int[][] rightPositions = new int[][] {new int[10], new int[10], new int[10]}; - int[][] rightDepths = new int[][] {new int[10], new int[10], new int[10]}; - scanner.currentPosition = scanner.initialPosition; //starting point (first-zero-based char) - while (scanner.currentPosition < scanner.eofPosition) { //loop for jumping over comments - try { - // ---------Consume white space and handles startPosition--------- - boolean isWhiteSpace; - do { - scanner.startPosition = scanner.currentPosition; - if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') && (source[scanner.currentPosition] == 'u')) { - isWhiteSpace = scanner.jumpOverUnicodeWhiteSpace(); - } else { - if (scanner.recordLineSeparator && ((scanner.currentCharacter == '\r') || (scanner.currentCharacter == '\n'))) { - if (scanner.lineEnds[scanner.linePtr] < scanner.startPosition) { - // only record line positions we have not recorded yet - scanner.pushLineSeparator(); - } - } - isWhiteSpace = Character.isWhitespace(scanner.currentCharacter); - } - } while (isWhiteSpace && (scanner.currentPosition < scanner.eofPosition)); - - // -------consume token until } is found--------- - - switch (scanner.currentCharacter) { - case '{' : - { - int index = leftCount[CurlyBracket] ++; - if (index == leftPositions[CurlyBracket].length) { - System.arraycopy(leftPositions[CurlyBracket], 0, (leftPositions[CurlyBracket] = new int[index * 2]), 0, index); - System.arraycopy(leftDepths[CurlyBracket], 0, (leftDepths[CurlyBracket] = new int[index * 2]), 0, index); - } - leftPositions[CurlyBracket][index] = scanner.startPosition; - leftDepths[CurlyBracket][index] = depths[CurlyBracket] ++; - } - break; - case '}' : - { - int index = rightCount[CurlyBracket] ++; - if (index == rightPositions[CurlyBracket].length) { - System.arraycopy(rightPositions[CurlyBracket], 0, (rightPositions[CurlyBracket] = new int[index * 2]), 0, index); - System.arraycopy(rightDepths[CurlyBracket], 0, (rightDepths[CurlyBracket] = new int[index * 2]), 0, index); - } - rightPositions[CurlyBracket][index] = scanner.startPosition; - rightDepths[CurlyBracket][index] = --depths[CurlyBracket]; - } - break; - case '(' : - { - int index = leftCount[RoundBracket] ++; - if (index == leftPositions[RoundBracket].length) { - System.arraycopy(leftPositions[RoundBracket], 0, (leftPositions[RoundBracket] = new int[index * 2]), 0, index); - System.arraycopy(leftDepths[RoundBracket], 0, (leftDepths[RoundBracket] = new int[index * 2]), 0, index); - } - leftPositions[RoundBracket][index] = scanner.startPosition; - leftDepths[RoundBracket][index] = depths[RoundBracket] ++; - } - break; - case ')' : - { - int index = rightCount[RoundBracket] ++; - if (index == rightPositions[RoundBracket].length) { - System.arraycopy(rightPositions[RoundBracket], 0, (rightPositions[RoundBracket] = new int[index * 2]), 0, index); - System.arraycopy(rightDepths[RoundBracket], 0, (rightDepths[RoundBracket] = new int[index * 2]), 0, index); - } - rightPositions[RoundBracket][index] = scanner.startPosition; - rightDepths[RoundBracket][index] = --depths[RoundBracket]; - } - break; - case '[' : - { - int index = leftCount[SquareBracket] ++; - if (index == leftPositions[SquareBracket].length) { - System.arraycopy(leftPositions[SquareBracket], 0, (leftPositions[SquareBracket] = new int[index * 2]), 0, index); - System.arraycopy(leftDepths[SquareBracket], 0, (leftDepths[SquareBracket] = new int[index * 2]), 0, index); - } - leftPositions[SquareBracket][index] = scanner.startPosition; - leftDepths[SquareBracket][index] = depths[SquareBracket] ++; - } - break; - case ']' : - { - int index = rightCount[SquareBracket] ++; - if (index == rightPositions[SquareBracket].length) { - System.arraycopy(rightPositions[SquareBracket], 0, (rightPositions[SquareBracket] = new int[index * 2]), 0, index); - System.arraycopy(rightDepths[SquareBracket], 0, (rightDepths[SquareBracket] = new int[index * 2]), 0, index); - } - rightPositions[SquareBracket][index] = scanner.startPosition; - rightDepths[SquareBracket][index] = --depths[SquareBracket]; - } - break; - case '\'' : - { - if (scanner.getNextChar('\\')) { - scanner.scanEscapeCharacter(); - } else { // consume next character - scanner.unicodeAsBackSlash = false; - if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') && (source[scanner.currentPosition] == 'u')) { - scanner.getNextUnicodeChar(); - } else { - if (scanner.withoutUnicodePtr != 0) { - scanner.withoutUnicodeBuffer[++scanner.withoutUnicodePtr] = scanner.currentCharacter; - } - } - } - scanner.getNextChar('\''); - break; - } - case '"' : // consume next character - scanner.unicodeAsBackSlash = false; - if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') && (source[scanner.currentPosition] == 'u')) { - scanner.getNextUnicodeChar(); - } else { - if (scanner.withoutUnicodePtr != 0) { - scanner.withoutUnicodeBuffer[++scanner.withoutUnicodePtr] = scanner.currentCharacter; - } - } - while (scanner.currentCharacter != '"') { - if (scanner.currentCharacter == '\r') { - if (source[scanner.currentPosition] == '\n') - scanner.currentPosition++; - break; // the string cannot go further that the line - } - if (scanner.currentCharacter == '\n') { - break; // the string cannot go further that the line - } - if (scanner.currentCharacter == '\\') { - scanner.scanEscapeCharacter(); - } - // consume next character - scanner.unicodeAsBackSlash = false; - if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') && (source[scanner.currentPosition] == 'u')) { - scanner.getNextUnicodeChar(); - } else { - if (scanner.withoutUnicodePtr != 0) { - scanner.withoutUnicodeBuffer[++scanner.withoutUnicodePtr] = scanner.currentCharacter; - } - } - } - break; - case '/' : - { - int test; - if ((test = scanner.getNextChar('/', '*')) == 0) { //line comment - //get the next char - if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') && (source[scanner.currentPosition] == 'u')) { - //-------------unicode traitement ------------ - int c1 = 0, c2 = 0, c3 = 0, c4 = 0; - scanner.currentPosition++; - while (source[scanner.currentPosition] == 'u') { - scanner.currentPosition++; - } - if ((c1 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c1 < 0 || (c2 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c2 < 0 || (c3 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c3 < 0 || (c4 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c4 < 0) { //error don't care of the value - scanner.currentCharacter = 'A'; - } //something different from \n and \r - else { - scanner.currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4); - } - } - while (scanner.currentCharacter != '\r' && scanner.currentCharacter != '\n') { - //get the next char - scanner.startPosition = scanner.currentPosition; - if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') && (source[scanner.currentPosition] == 'u')) { - //-------------unicode traitement ------------ - int c1 = 0, c2 = 0, c3 = 0, c4 = 0; - scanner.currentPosition++; - while (source[scanner.currentPosition] == 'u') { - scanner.currentPosition++; - } - if ((c1 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c1 < 0 || (c2 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c2 < 0 || (c3 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c3 < 0 || (c4 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c4 < 0) { //error don't care of the value - scanner.currentCharacter = 'A'; - } //something different from \n and \r - else { - scanner.currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4); - } - } - } - if (scanner.recordLineSeparator && ((scanner.currentCharacter == '\r') || (scanner.currentCharacter == '\n'))) { - if (scanner.lineEnds[scanner.linePtr] < scanner.startPosition) { - // only record line positions we have not recorded yet - scanner.pushLineSeparator(); - } - } - break; - } - if (test > 0) { //traditional and annotation comment - boolean star = false; - // consume next character - scanner.unicodeAsBackSlash = false; - if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') && (source[scanner.currentPosition] == 'u')) { - scanner.getNextUnicodeChar(); - } else { - if (scanner.withoutUnicodePtr != 0) { - scanner.withoutUnicodeBuffer[++scanner.withoutUnicodePtr] = scanner.currentCharacter; - } - } - if (scanner.currentCharacter == '*') { - star = true; - } - //get the next char - if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') && (source[scanner.currentPosition] == 'u')) { - //-------------unicode traitement ------------ - int c1 = 0, c2 = 0, c3 = 0, c4 = 0; - scanner.currentPosition++; - while (source[scanner.currentPosition] == 'u') { - scanner.currentPosition++; - } - if ((c1 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c1 < 0 || (c2 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c2 < 0 || (c3 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c3 < 0 || (c4 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c4 < 0) { //error don't care of the value - scanner.currentCharacter = 'A'; - } //something different from * and / - else { - scanner.currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4); - } - } - //loop until end of comment */ - while ((scanner.currentCharacter != '/') || (!star)) { - star = scanner.currentCharacter == '*'; - //get next char - if (((scanner.currentCharacter = source[scanner.currentPosition++]) == '\\') && (source[scanner.currentPosition] == 'u')) { - //-------------unicode traitement ------------ - int c1 = 0, c2 = 0, c3 = 0, c4 = 0; - scanner.currentPosition++; - while (source[scanner.currentPosition] == 'u') { - scanner.currentPosition++; - } - if ((c1 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c1 < 0 || (c2 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c2 < 0 || (c3 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c3 < 0 || (c4 = Character.getNumericValue(source[scanner.currentPosition++])) > 15 || c4 < 0) { //error don't care of the value - scanner.currentCharacter = 'A'; - } //something different from * and / - else { - scanner.currentCharacter = (char) (((c1 * 16 + c2) * 16 + c3) * 16 + c4); - } - } - } - break; - } - break; - } - default : - if (Character.isJavaIdentifierStart(scanner.currentCharacter)) { - scanner.scanIdentifierOrKeyword(); - break; - } - if (Character.isDigit(scanner.currentCharacter)) { - scanner.scanNumber(false); - break; - } - } - //-----------------end switch while try-------------------- - } catch (IndexOutOfBoundsException e) { - break; // read until EOF - } catch (InvalidInputException e) { - return false; // no clue - } - } - if (scanner.recordLineSeparator) { - compilationUnit.compilationResult.lineSeparatorPositions = scanner.getLineEnds(); - } - - // check placement anomalies against other kinds of brackets - for (int kind = 0; kind < BracketKinds; kind++) { - for (int leftIndex = leftCount[kind] - 1; leftIndex >= 0; leftIndex--) { - int start = leftPositions[kind][leftIndex]; // deepest first - // find matching closing bracket - int depth = leftDepths[kind][leftIndex]; - int end = -1; - for (int i = 0; i < rightCount[kind]; i++) { - int pos = rightPositions[kind][i]; - // want matching bracket further in source with same depth - if ((pos > start) && (depth == rightDepths[kind][i])) { - end = pos; - break; - } - } - if (end < 0) { // did not find a good closing match - problemReporter.unmatchedBracket(start, referenceContext, compilationUnit.compilationResult); - return true; - } - // check if even number of opening/closing other brackets in between this pair of brackets - int balance = 0; - for (int otherKind = 0;(balance == 0) && (otherKind < BracketKinds); otherKind++) { - for (int i = 0; i < leftCount[otherKind]; i++) { - int pos = leftPositions[otherKind][i]; - if ((pos > start) && (pos < end)) - balance++; - } - for (int i = 0; i < rightCount[otherKind]; i++) { - int pos = rightPositions[otherKind][i]; - if ((pos > start) && (pos < end)) - balance--; - } - if (balance != 0) { - problemReporter.unmatchedBracket(start, referenceContext, compilationUnit.compilationResult); //bracket anomaly - return true; - } - } - } - // too many opening brackets ? - for (int i = rightCount[kind]; i < leftCount[kind]; i++) { - anomaliesDetected = true; - problemReporter.unmatchedBracket(leftPositions[kind][leftCount[kind] - i - 1], referenceContext, compilationUnit.compilationResult); - } - // too many closing brackets ? - for (int i = leftCount[kind]; i < rightCount[kind]; i++) { - anomaliesDetected = true; - problemReporter.unmatchedBracket(rightPositions[kind][i], referenceContext, compilationUnit.compilationResult); - } - if (anomaliesDetected) return true; - } - - return anomaliesDetected; - } catch (ArrayStoreException e) { // jdk1.2.2 jit bug - return anomaliesDetected; - } catch (NullPointerException e) { // jdk1.2.2 jit bug - return anomaliesDetected; - } -} -public final void checkAndSetModifiers(int flag){ - /*modify the current modifiers buffer. - When the startPosition of the modifiers is 0 - it means that the modifier being parsed is the first - of a list of several modifiers. The startPosition - is zeroed when a copy of modifiers-buffer is push - onto the astStack. */ - - if ((modifiers & flag) != 0){ // duplicate modifier - modifiers |= AccAlternateModifierProblem; - } - modifiers |= flag; - - if (modifiersSourceStart < 0) modifiersSourceStart = scanner.startPosition; -} -public void checkAnnotation() { - - boolean deprecated = false; - boolean checkDeprecated = false; - int lastAnnotationIndex = -1; - - //since jdk1.2 look only in the last java doc comment... - found : for (lastAnnotationIndex = scanner.commentPtr; lastAnnotationIndex >= 0; lastAnnotationIndex--){ - //look for @deprecated into the first javadoc comment preceeding the declaration - int commentSourceStart = scanner.commentStarts[lastAnnotationIndex]; - // javadoc only (non javadoc comment have negative end positions.) - if (modifiersSourceStart != -1 && modifiersSourceStart < commentSourceStart) { - continue; - } - if (scanner.commentStops[lastAnnotationIndex] < 0) { - break found; - } - checkDeprecated = true; - int commentSourceEnd = scanner.commentStops[lastAnnotationIndex] - 1; //stop is one over - char[] comment = scanner.source; - - for (int i = commentSourceStart + 3; i < commentSourceEnd - 10; i++) { - if ((comment[i] == '@') - && (comment[i + 1] == 'd') - && (comment[i + 2] == 'e') - && (comment[i + 3] == 'p') - && (comment[i + 4] == 'r') - && (comment[i + 5] == 'e') - && (comment[i + 6] == 'c') - && (comment[i + 7] == 'a') - && (comment[i + 8] == 't') - && (comment[i + 9] == 'e') - && (comment[i + 10] == 'd')) { - // ensure the tag is properly ended: either followed by a space, a tab, line end or asterisk. - int nextPos = i+11; - deprecated = (comment[nextPos] == ' ') || (comment[nextPos] == '\t') || (comment[nextPos] == '\n') || (comment[nextPos] == '\r') || (comment[nextPos] == '*'); - break found; - } - } - break found; - } - if (deprecated) { - checkAndSetModifiers(AccDeprecated); - } - // modify the modifier source start to point at the first comment - if (lastAnnotationIndex >= 0 && checkDeprecated) { - modifiersSourceStart = scanner.commentStarts[lastAnnotationIndex]; - } -} -protected void classInstanceCreation(boolean alwaysQualified) { - // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt - - // ClassBodyopt produces a null item on the astStak if it produces NO class body - // An empty class body produces a 0 on the length stack..... - - AllocationExpression alloc; - int length; - if (((length = astLengthStack[astLengthPtr--]) == 1) - && (astStack[astPtr] == null)) { - //NO ClassBody - astPtr--; - if (alwaysQualified) { - alloc = new QualifiedAllocationExpression(); - } else { - alloc = new AllocationExpression(); - } - alloc.sourceEnd = endPosition; //the position has been stored explicitly - - if ((length = expressionLengthStack[expressionLengthPtr--]) != 0) { - expressionPtr -= length; - System.arraycopy( - expressionStack, - expressionPtr + 1, - alloc.arguments = new Expression[length], - 0, - length); - } - alloc.type = getTypeReference(0); - //the default constructor with the correct number of argument - //will be created and added by the TC (see createsInternalConstructorWithBinding) - alloc.sourceStart = intStack[intPtr--]; - pushOnExpressionStack(alloc); - } else { - dispatchDeclarationInto(length); - AnonymousLocalTypeDeclaration anonymousTypeDeclaration = (AnonymousLocalTypeDeclaration) astStack[astPtr]; - anonymousTypeDeclaration.declarationSourceEnd = endStatementPosition; - anonymousTypeDeclaration.bodyEnd = endStatementPosition; - if (anonymousTypeDeclaration.allocation != null) { - anonymousTypeDeclaration.allocation.sourceEnd = endStatementPosition; - } - astPtr--; - astLengthPtr--; - - // mark fields and initializer with local type mark if needed - markFieldsWithLocalType(anonymousTypeDeclaration); - } -} -protected final void concatExpressionLists() { - expressionLengthStack[--expressionLengthPtr]++; -} -private final void concatNodeLists() { - /* - * This is a case where you have two sublists into the astStack that you want - * to merge in one list. There is no action required on the astStack. The only - * thing you need to do is merge the two lengths specified on the astStackLength. - * The top two length are for example: - * ... p n - * and you want to result in a list like: - * ... n+p - * This means that the p could be equals to 0 in case there is no astNode pushed - * on the astStack. - * Look at the InterfaceMemberDeclarations for an example. - */ - - astLengthStack[astLengthPtr - 1] += astLengthStack[astLengthPtr--]; -} -protected void consumeAllocationHeader() { - // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt - - // ClassBodyopt produces a null item on the astStak if it produces NO class body - // An empty class body produces a 0 on the length stack..... - - if (currentElement == null){ - return; // should never occur, this consumeRule is only used in recovery mode - } - if (currentToken == TokenNameLBRACE){ - // beginning of an anonymous type - AnonymousLocalTypeDeclaration anonymousType = new AnonymousLocalTypeDeclaration(this.compilationUnit.compilationResult); - anonymousType.sourceStart = intStack[intPtr--]; - anonymousType.sourceEnd = rParenPos; // closing parenthesis - lastCheckPoint = anonymousType.bodyStart = scanner.currentPosition; - currentElement = currentElement.add(anonymousType, 0); - lastIgnoredToken = -1; - currentToken = 0; // opening brace already taken into account - return; - } - lastCheckPoint = scanner.startPosition; // force to restart at this exact position - restartRecovery = true; // request to restart from here on -} -protected void consumeArgumentList() { - // ArgumentList ::= ArgumentList ',' Expression - concatExpressionLists(); -} -protected void consumeArrayAccess(boolean unspecifiedReference) { - // ArrayAccess ::= Name '[' Expression ']' ==> true - // ArrayAccess ::= PrimaryNoNewArray '[' Expression ']' ==> false - - - //optimize push/pop - Expression exp; - if (unspecifiedReference) { - exp = - expressionStack[expressionPtr] = - new ArrayReference( - getUnspecifiedReferenceOptimized(), - expressionStack[expressionPtr]); - } else { - expressionPtr--; - expressionLengthPtr--; - exp = - expressionStack[expressionPtr] = - new ArrayReference( - expressionStack[expressionPtr], - expressionStack[expressionPtr + 1]); - } - exp.sourceEnd = endPosition; -} -protected void consumeArrayCreationExpression() { - // ArrayCreationExpression ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializeropt - // ArrayCreationExpression ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializeropt - - int length; - ArrayAllocationExpression aae = new ArrayAllocationExpression(); - if (expressionLengthStack[expressionLengthPtr] != 0) { - expressionLengthPtr -- ; - aae.initializer = (ArrayInitializer) expressionStack[expressionPtr--]; - } else { - expressionLengthPtr--; - } - - aae.type = getTypeReference(0); - length = (expressionLengthStack[expressionLengthPtr--]); - expressionPtr -= length ; - System.arraycopy( - expressionStack, - expressionPtr+1, - aae.dimensions = new Expression[length], - 0, - length); - aae.sourceStart = intStack[intPtr--]; - if (aae.initializer == null) { - aae.sourceEnd = endPosition; - } else { - aae.sourceEnd = aae.initializer.sourceEnd ; - } - pushOnExpressionStack(aae); -} -protected void consumeArrayInitializer() { - // ArrayInitializer ::= '{' VariableInitializers '}' - // ArrayInitializer ::= '{' VariableInitializers , '}' + case 118 : // System.out.println("ClassMemberDeclaration ::= SEMICOLON"); + consumeEmptyClassMemberDeclaration(); + break; - arrayInitializer(expressionLengthStack[expressionLengthPtr--]); -} + case 119 : // System.out.println("FieldDeclaration ::= Modifiersopt Type VariableDeclarators SEMICOLON"); + consumeFieldDeclaration(); + break; -protected void consumeAssertStatement() { - // AssertStatement ::= 'assert' Expression ':' Expression ';' - expressionLengthPtr-=2; - pushOnAstStack(new AssertStatement(expressionStack[expressionPtr--], expressionStack[expressionPtr--], intStack[intPtr--])); -} + case 121 : // System.out.println("VariableDeclarators ::= VariableDeclarators COMMA VariableDeclarator"); + consumeVariableDeclarators(); + break; -protected void consumeAssignment() { - // Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression - //optimize the push/pop - - int op = intStack[intPtr--] ; //<--the encoded operator - - expressionPtr -- ; expressionLengthPtr -- ; - expressionStack[expressionPtr] = - (op != EQUAL ) ? - new CompoundAssignment( - expressionStack[expressionPtr] , - expressionStack[expressionPtr+1], - op, - scanner.startPosition - 1) : - new Assignment( - expressionStack[expressionPtr] , - expressionStack[expressionPtr+1], - scanner.startPosition - 1); -} -protected void consumeAssignmentOperator(int pos) { - // AssignmentOperator ::= '=' - // AssignmentOperator ::= '*=' - // AssignmentOperator ::= '/=' - // AssignmentOperator ::= '%=' - // AssignmentOperator ::= '+=' - // AssignmentOperator ::= '-=' - // AssignmentOperator ::= '<<=' - // AssignmentOperator ::= '>>=' - // AssignmentOperator ::= '>>>=' - // AssignmentOperator ::= '&=' - // AssignmentOperator ::= '^=' - // AssignmentOperator ::= '|=' - - try { - intStack[++intPtr] = pos; - } catch (IndexOutOfBoundsException e) { - //intPtr is correct - int oldStackLength = intStack.length; - int oldStack[] = intStack; - intStack = new int[oldStackLength + StackIncrement]; - System.arraycopy(oldStack, 0, intStack, 0, oldStackLength); - intStack[intPtr] = pos; - } -} -protected void consumeBinaryExpression(int op) { - // MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression - // MultiplicativeExpression ::= MultiplicativeExpression '/' UnaryExpression - // MultiplicativeExpression ::= MultiplicativeExpression '%' UnaryExpression - // AdditiveExpression ::= AdditiveExpression '+' MultiplicativeExpression - // AdditiveExpression ::= AdditiveExpression '-' MultiplicativeExpression - // ShiftExpression ::= ShiftExpression '<<' AdditiveExpression - // ShiftExpression ::= ShiftExpression '>>' AdditiveExpression - // ShiftExpression ::= ShiftExpression '>>>' AdditiveExpression - // RelationalExpression ::= RelationalExpression '<' ShiftExpression - // RelationalExpression ::= RelationalExpression '>' ShiftExpression - // RelationalExpression ::= RelationalExpression '<=' ShiftExpression - // RelationalExpression ::= RelationalExpression '>=' ShiftExpression - // AndExpression ::= AndExpression '&' EqualityExpression - // ExclusiveOrExpression ::= ExclusiveOrExpression '^' AndExpression - // InclusiveOrExpression ::= InclusiveOrExpression '|' ExclusiveOrExpression - // ConditionalAndExpression ::= ConditionalAndExpression '&&' InclusiveOrExpression - // ConditionalOrExpression ::= ConditionalOrExpression '||' ConditionalAndExpression - - //optimize the push/pop - - expressionPtr--; - expressionLengthPtr--; - if (op == OR_OR) { - expressionStack[expressionPtr] = - new OR_OR_Expression( - expressionStack[expressionPtr], - expressionStack[expressionPtr + 1], - op); - } else { - if (op == AND_AND) { - expressionStack[expressionPtr] = - new AND_AND_Expression( - expressionStack[expressionPtr], - expressionStack[expressionPtr + 1], - op); - } else { - // look for "string1" + "string2" - if ((op == PLUS) && optimizeStringLiterals) { - Expression expr1, expr2; - expr1 = expressionStack[expressionPtr]; - expr2 = expressionStack[expressionPtr + 1]; - if (expr1 instanceof StringLiteral) { - if (expr2 instanceof CharLiteral) { // string+char - expressionStack[expressionPtr] = - ((StringLiteral) expr1).extendWith((CharLiteral) expr2); - } else if (expr2 instanceof StringLiteral) { //string+string - expressionStack[expressionPtr] = - ((StringLiteral) expr1).extendWith((StringLiteral) expr2); - } else { - expressionStack[expressionPtr] = new BinaryExpression(expr1, expr2, PLUS); - } - } else { - expressionStack[expressionPtr] = new BinaryExpression(expr1, expr2, PLUS); - } - } else { - expressionStack[expressionPtr] = - new BinaryExpression( - expressionStack[expressionPtr], - expressionStack[expressionPtr + 1], - op); - } - } - } -} -protected void consumeBlock() { - // Block ::= OpenBlock '{' BlockStatementsopt '}' - // simpler action for empty blocks - - int length; - if ((length = astLengthStack[astLengthPtr--]) == 0) { // empty block - pushOnAstStack(Block.EmptyWith(intStack[intPtr--], endStatementPosition)); - realBlockPtr--; // still need to pop the block variable counter - } else { - Block bk = new Block(realBlockStack[realBlockPtr--]); - astPtr -= length; - System.arraycopy( - astStack, - astPtr + 1, - bk.statements = new Statement[length], - 0, - length); - pushOnAstStack(bk); - bk.sourceStart = intStack[intPtr--]; - bk.sourceEnd = endStatementPosition; - } -} -protected void consumeBlockStatements() { - // BlockStatements ::= BlockStatements BlockStatement - concatNodeLists(); -} -protected void consumeCaseLabel() { - // SwitchLabel ::= 'case' ConstantExpression ':' - expressionLengthPtr--; - pushOnAstStack(new Case(intStack[intPtr--], expressionStack[expressionPtr--])); -} -protected void consumeCastExpression() { - // CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN UnaryExpression - // CastExpression ::= PushLPAREN Name Dims PushRPAREN UnaryExpressionNotPlusMinus + case 124 : // System.out.println("EnterVariable ::="); + consumeEnterVariable(); + break; - //intStack : posOfLeftParen dim posOfRightParen + case 125 : // System.out.println("ExitVariableWithInitialization ::="); + consumeExitVariableWithInitialization(); + break; - //optimize the push/pop + case 126 : // System.out.println("ExitVariableWithoutInitialization ::="); + consumeExitVariableWithoutInitialization(); + break; - Expression exp, cast, castType; - int end = intStack[intPtr--]; - expressionStack[expressionPtr] = cast = new CastExpression(exp = expressionStack[expressionPtr], castType = getTypeReference(intStack[intPtr--])); - castType.sourceEnd = end - 1; - castType.sourceStart = (cast.sourceStart = intStack[intPtr--]) + 1; - cast.sourceEnd = exp.sourceEnd; -} -protected void consumeCastExpressionLL1() { - //CastExpression ::= '(' Expression ')' UnaryExpressionNotPlusMinus - // Expression is used in order to make the grammar LL1 - - //optimize push/pop - - Expression castType,cast,exp; - expressionPtr--; - expressionStack[expressionPtr] = - cast = new CastExpression( exp=expressionStack[expressionPtr+1] , - castType = getTypeReference(expressionStack[expressionPtr])); - expressionLengthPtr -- ; - updateSourcePosition(castType); - cast.sourceStart=castType.sourceStart; - cast.sourceEnd=exp.sourceEnd; - castType.sourceStart++; - castType.sourceEnd--; - } -protected void consumeCatches() { - // Catches ::= Catches CatchClause - optimizedConcatNodeLists(); -} -protected void consumeCatchHeader() { - // CatchDeclaration ::= 'catch' '(' FormalParameter ')' '{' - - if (currentElement == null){ - return; // should never occur, this consumeRule is only used in recovery mode - } - // current element should be a block due to the presence of the opening brace - if (!(currentElement instanceof RecoveredBlock)){ - return; - } - // exception argument is already on astStack - ((RecoveredBlock)currentElement).attach( - new RecoveredLocalVariable((Argument)astStack[astPtr--], currentElement, 0)); // insert catch variable in catch block - lastCheckPoint = scanner.startPosition; // force to restart at this exact position - restartRecovery = true; // request to restart from here on - lastIgnoredToken = -1; -} -protected void consumeClassBodyDeclaration() { - // ClassBodyDeclaration ::= Diet Block - //push an Initializer - //optimize the push/pop - nestedMethod[nestedType]--; - Initializer initializer = new Initializer((Block) astStack[astPtr], 0); - intPtr--; // pop sourcestart left on the stack by consumeNestedMethod. - realBlockPtr--; // pop the block variable counter left on the stack by consumeNestedMethod - int javadocCommentStart = intStack[intPtr--]; - if (javadocCommentStart != -1) { - initializer.declarationSourceStart = javadocCommentStart; - } - astStack[astPtr] = initializer; - initializer.sourceEnd = endStatementPosition; - initializer.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); -} -protected void consumeClassBodyDeclarations() { - // ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration - concatNodeLists(); -} -protected void consumeClassBodyDeclarationsopt() { - // ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations - nestedType-- ; -} -protected void consumeClassBodyopt() { - // ClassBodyopt ::= $empty - pushOnAstStack(null); - endPosition = scanner.startPosition - 1; -} -protected void consumeClassDeclaration() { - // ClassDeclaration ::= ClassHeader ClassBody - - int length; - if ((length = astLengthStack[astLengthPtr--]) != 0) { - //there are length declarations - //dispatch according to the type of the declarations - dispatchDeclarationInto(length); - } - - TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; - - // mark fields and initializer with local type mark if needed - markFieldsWithLocalType(typeDecl); - - //convert constructor that do not have the type's name into methods - boolean hasConstructor = typeDecl.checkConstructors(this); - - //add the default constructor when needed (interface don't have it) - if (!hasConstructor) { - boolean insideFieldInitializer = false; - if (diet) { - for (int i = nestedType; i > 0; i--){ - if (variablesCounter[i] > 0) { - insideFieldInitializer = true; - break; - } - } - } - typeDecl.createsInternalConstructor(!diet || insideFieldInitializer, true); - } - - //always add (will be remove at code gen time if empty) - if (this.scanner.containsAssertKeyword) { - typeDecl.bits |= AstNode.AddAssertionMASK; - } - typeDecl.addClinit(); - typeDecl.bodyEnd = endStatementPosition; - typeDecl.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); -} -protected void consumeClassHeader() { - // ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt - - TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; - if (currentToken == TokenNameLBRACE) { - typeDecl.bodyStart = scanner.currentPosition; - } - if (currentElement != null) { - restartRecovery = true; // used to avoid branching back into the regular automaton - } - // flush the comments related to the class header - scanner.commentPtr = -1; -} -protected void consumeClassHeaderExtends() { - // ClassHeaderExtends ::= 'extends' ClassType - // There is a class declaration on the top of stack - TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; - //superclass - typeDecl.superclass = getTypeReference(0); - typeDecl.bodyStart = typeDecl.superclass.sourceEnd + 1; - // recovery - if (currentElement != null){ - lastCheckPoint = typeDecl.bodyStart; - } -} -protected void consumeClassHeaderImplements() { - // ClassHeaderImplements ::= 'implements' InterfaceTypeList - int length = astLengthStack[astLengthPtr--]; - //super interfaces - astPtr -= length; - // There is a class declaration on the top of stack - TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; - System.arraycopy( - astStack, - astPtr + 1, - typeDecl.superInterfaces = new TypeReference[length], - 0, - length); - typeDecl.bodyStart = typeDecl.superInterfaces[length-1].sourceEnd + 1; - listLength = 0; // reset after having read super-interfaces - // recovery - if (currentElement != null) { // is recovering - lastCheckPoint = typeDecl.bodyStart; - } -} -protected void consumeClassHeaderName() { - // ClassHeaderName ::= Modifiersopt 'class' 'Identifier' - TypeDeclaration typeDecl; - if (nestedMethod[nestedType] == 0) { - if (nestedType != 0) { - typeDecl = new MemberTypeDeclaration(this.compilationUnit.compilationResult); - } else { - typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult); - } - } else { - // Record that the block has a declaration for local types - typeDecl = new LocalTypeDeclaration(this.compilationUnit.compilationResult); - markCurrentMethodWithLocalType(); - blockReal(); - } - - //highlight the name of the type - long pos = identifierPositionStack[identifierPtr]; - typeDecl.sourceEnd = (int) pos; - typeDecl.sourceStart = (int) (pos >>> 32); - typeDecl.name = identifierStack[identifierPtr--]; - identifierLengthPtr--; - - //compute the declaration source too - // 'class' and 'interface' push two int positions: the beginning of the class token and its end. - // we want to keep the beginning position but get rid of the end position - // it is only used for the ClassLiteralAccess positions. - typeDecl.declarationSourceStart = intStack[intPtr--]; - intPtr--; // remove the end position of the class token - - typeDecl.modifiersSourceStart = intStack[intPtr--]; - typeDecl.modifiers = intStack[intPtr--]; - if (typeDecl.modifiersSourceStart >= 0) { - typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart; - } - typeDecl.bodyStart = typeDecl.sourceEnd + 1; - pushOnAstStack(typeDecl); - - listLength = 0; // will be updated when reading super-interfaces - // recovery - if (currentElement != null){ - lastCheckPoint = typeDecl.bodyStart; - currentElement = currentElement.add(typeDecl, 0); - lastIgnoredToken = -1; - } -} -protected void consumeClassInstanceCreationExpression() { - // ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt - classInstanceCreation(false); -} -protected void consumeClassInstanceCreationExpressionName() { - // ClassInstanceCreationExpressionName ::= Name '.' - pushOnExpressionStack(getUnspecifiedReferenceOptimized()); -} -protected void consumeClassInstanceCreationExpressionQualified() { - // ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt - // ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt - - classInstanceCreation(true); // <-- push the Qualifed.... - - expressionLengthPtr--; - QualifiedAllocationExpression qae = - (QualifiedAllocationExpression) expressionStack[expressionPtr--]; - qae.enclosingInstance = expressionStack[expressionPtr]; - expressionStack[expressionPtr] = qae; - qae.sourceStart = qae.enclosingInstance.sourceStart; -} -protected void consumeClassTypeElt() { - // ClassTypeElt ::= ClassType - pushOnAstStack(getTypeReference(0)); - /* if incomplete thrown exception list, listLength counter will not have been reset, - indicating that some items are available on the stack */ - listLength++; -} -protected void consumeClassTypeList() { - // ClassTypeList ::= ClassTypeList ',' ClassTypeElt - optimizedConcatNodeLists(); -} -protected void consumeCompilationUnit() { - // CompilationUnit ::= EnterCompilationUnit PackageDeclarationopt ImportDeclarationsopt - // do nothing by default -} -protected void consumeConditionalExpression(int op) { - // ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' ConditionalExpression - //optimize the push/pop - - expressionPtr -= 2; - expressionLengthPtr -= 2; - expressionStack[expressionPtr] = - new ConditionalExpression( - expressionStack[expressionPtr], - expressionStack[expressionPtr + 1], - expressionStack[expressionPtr + 2]); -} -protected void consumeConstructorBlockStatements() { - // ConstructorBody ::= NestedMethod '{' ExplicitConstructorInvocation BlockStatements '}' - concatNodeLists(); // explictly add the first statement into the list of statements -} -protected void consumeConstructorBody() { - // ConstructorBody ::= NestedMethod '{' BlockStatementsopt '}' - // ConstructorBody ::= NestedMethod '{' ExplicitConstructorInvocation '}' - nestedMethod[nestedType] --; -} -protected void consumeConstructorDeclaration() { - // ConstructorDeclaration ::= ConstructorHeader ConstructorBody - - /* - astStack : MethodDeclaration statements - identifierStack : name - ==> - astStack : MethodDeclaration - identifierStack : - */ - - //must provide a default constructor call when needed - - int length; - - // pop the position of the { (body of the method) pushed in block decl - intPtr--; - - //statements - realBlockPtr--; - ExplicitConstructorCall constructorCall = null; - Statement[] statements = null; - if ((length = astLengthStack[astLengthPtr--]) != 0) { - astPtr -= length; - if (astStack[astPtr + 1] instanceof ExplicitConstructorCall) { - //avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ? - System.arraycopy( - astStack, - astPtr + 2, - statements = new Statement[length - 1], - 0, - length - 1); - constructorCall = (ExplicitConstructorCall) astStack[astPtr + 1]; - } else { //need to add explicitly the super(); - System.arraycopy( - astStack, - astPtr + 1, - statements = new Statement[length], - 0, - length); - constructorCall = SuperReference.implicitSuperConstructorCall(); - } - } else { - if (!diet){ - // add it only in non-diet mode, if diet_bodies, then constructor call will be added elsewhere. - constructorCall = SuperReference.implicitSuperConstructorCall(); - } - } - - // now we know that the top of stack is a constructorDeclaration - ConstructorDeclaration cd = (ConstructorDeclaration) astStack[astPtr]; - cd.constructorCall = constructorCall; - cd.statements = statements; - - //highlight of the implicit call on the method name - if (constructorCall != null && cd.constructorCall.sourceEnd == 0) { - cd.constructorCall.sourceEnd = cd.sourceEnd; - cd.constructorCall.sourceStart = cd.sourceStart; - } - - //watch for } that could be given as a unicode ! ( u007D is '}' ) - // store the endPosition (position just before the '}') in case there is - // a trailing comment behind the end of the method - cd.bodyEnd = endPosition; - cd.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); -} + case 127 : // System.out.println("ForceNoDiet ::="); + consumeForceNoDiet(); + break; -protected void consumeInvalidConstructorDeclaration() { - // ConstructorDeclaration ::= ConstructorHeader ';' - // now we know that the top of stack is a constructorDeclaration - ConstructorDeclaration cd = (ConstructorDeclaration) astStack[astPtr]; + case 128 : // System.out.println("RestoreDiet ::="); + consumeRestoreDiet(); + break; - cd.bodyEnd = endPosition; // position just before the trailing semi-colon - cd.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); - // report the problem and continue the parsing - narrowing the problem onto the method -} -protected void consumeConstructorHeader() { - // ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters MethodHeaderThrowsClauseopt - - AbstractMethodDeclaration method = (AbstractMethodDeclaration)astStack[astPtr]; - - if (currentToken == TokenNameLBRACE){ - method.bodyStart = scanner.currentPosition; - } - // recovery - if (currentElement != null){ - restartRecovery = true; // used to avoid branching back into the regular automaton - } -} -protected void consumeConstructorHeaderName() { - - /* recovering - might be an empty message send */ - if (currentElement != null){ - if (lastIgnoredToken == TokenNamenew){ // was an allocation expression - lastCheckPoint = scanner.startPosition; // force to restart at this exact position - restartRecovery = true; - return; - } - } - - // ConstructorHeaderName ::= Modifiersopt 'Identifier' '(' - ConstructorDeclaration cd = new ConstructorDeclaration(this.compilationUnit.compilationResult); - - //name -- this is not really revelant but we do ..... - cd.selector = identifierStack[identifierPtr]; - long selectorSource = identifierPositionStack[identifierPtr--]; - identifierLengthPtr--; - - //modifiers - cd.declarationSourceStart = intStack[intPtr--]; - cd.modifiers = intStack[intPtr--]; - - //highlight starts at the selector starts - cd.sourceStart = (int) (selectorSource >>> 32); - pushOnAstStack(cd); - cd.sourceEnd = lParenPos; - cd.bodyStart = lParenPos+1; - listLength = 0; // initialize listLength before reading parameters/throws - - // recovery - if (currentElement != null){ - lastCheckPoint = cd.bodyStart; - if ((currentElement instanceof RecoveredType && lastIgnoredToken != TokenNameDOT) - || cd.modifiers != 0){ - currentElement = currentElement.add(cd, 0); - lastIgnoredToken = -1; - } - } -} -protected void consumeDefaultLabel() { - // SwitchLabel ::= 'default' ':' - pushOnAstStack(new DefaultCase(intStack[intPtr--], intStack[intPtr--])); -} -protected void consumeDefaultModifiers() { - checkAnnotation(); // might update modifiers with AccDeprecated - pushOnIntStack(modifiers); // modifiers - pushOnIntStack( - modifiersSourceStart >= 0 ? modifiersSourceStart : scanner.startPosition); - resetModifiers(); -} -protected void consumeDiet() { - // Diet ::= $empty - checkAnnotation(); - pushOnIntStack(modifiersSourceStart); // push the start position of a javadoc comment if there is one - jumpOverMethodBody(); -} -protected void consumeDims() { - // Dims ::= DimsLoop - pushOnIntStack(dimensions); - dimensions = 0; -} -protected void consumeDimWithOrWithOutExpr() { - // DimWithOrWithOutExpr ::= '[' ']' - pushOnExpressionStack(null); -} -protected void consumeDimWithOrWithOutExprs() { - // DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr - concatExpressionLists(); -} -protected void consumeEmptyArgumentListopt() { - // ArgumentListopt ::= $empty - pushOnExpressionStackLengthStack(0); -} -protected void consumeEmptyArrayInitializer() { - // ArrayInitializer ::= '{' ,opt '}' - arrayInitializer(0); -} -protected void consumeEmptyArrayInitializeropt() { - // ArrayInitializeropt ::= $empty - pushOnExpressionStackLengthStack(0); -} -protected void consumeEmptyBlockStatementsopt() { - // BlockStatementsopt ::= $empty - pushOnAstLengthStack(0); -} -protected void consumeEmptyCatchesopt() { - // Catchesopt ::= $empty - pushOnAstLengthStack(0); -} -protected void consumeEmptyClassBodyDeclarationsopt() { - // ClassBodyDeclarationsopt ::= $empty - pushOnAstLengthStack(0); -} -protected void consumeEmptyClassMemberDeclaration() { - // ClassMemberDeclaration ::= ';' - pushOnAstLengthStack(0); -} -protected void consumeEmptyDimsopt() { - // Dimsopt ::= $empty - pushOnIntStack(0); -} -protected void consumeEmptyExpression() { - // Expressionopt ::= $empty - pushOnExpressionStackLengthStack(0); -} -protected void consumeEmptyForInitopt() { - // ForInitopt ::= $empty - pushOnAstLengthStack(0); -} -protected void consumeEmptyForUpdateopt() { - // ForUpdateopt ::= $empty - pushOnExpressionStackLengthStack(0); -} -protected void consumeEmptyImportDeclarationsopt() { - // ImportDeclarationsopt ::= $empty - pushOnAstLengthStack(0); -} -protected void consumeEmptyInterfaceMemberDeclaration() { - // InterfaceMemberDeclaration ::= ';' - pushOnAstLengthStack(0); -} -protected void consumeEmptyInterfaceMemberDeclarationsopt() { - // InterfaceMemberDeclarationsopt ::= $empty - pushOnAstLengthStack(0); -} -protected void consumeEmptyStatement() { - // EmptyStatement ::= ';' - if (this.scanner.source[endStatementPosition] == ';') { - pushOnAstStack(new EmptyStatement(endStatementPosition, endStatementPosition)); - } else { - // we have a Unicode for the ';' (/u003B) - pushOnAstStack(new EmptyStatement(endStatementPosition - 5, endStatementPosition)); - } -} -protected void consumeEmptySwitchBlock() { - // SwitchBlock ::= '{' '}' - pushOnAstLengthStack(0); -} -protected void consumeEmptyTypeDeclaration() { - // TypeDeclaration ::= ';' - pushOnAstLengthStack(0); -} -protected void consumeEmptyTypeDeclarationsopt() { - // TypeDeclarationsopt ::= $empty - pushOnAstLengthStack(0); -} -protected void consumeEnterAnonymousClassBody() { - // EnterAnonymousClassBody ::= $empty - QualifiedAllocationExpression alloc; - AnonymousLocalTypeDeclaration anonymousType = - new AnonymousLocalTypeDeclaration(this.compilationUnit.compilationResult); - alloc = - anonymousType.allocation = new QualifiedAllocationExpression(anonymousType); - markCurrentMethodWithLocalType(); - pushOnAstStack(anonymousType); - - alloc.sourceEnd = rParenPos; //the position has been stored explicitly - int argumentLength; - if ((argumentLength = expressionLengthStack[expressionLengthPtr--]) != 0) { - expressionPtr -= argumentLength; - System.arraycopy( - expressionStack, - expressionPtr + 1, - alloc.arguments = new Expression[argumentLength], - 0, - argumentLength); - } - alloc.type = getTypeReference(0); - - anonymousType.sourceEnd = alloc.sourceEnd; - //position at the type while it impacts the anonymous declaration - anonymousType.sourceStart = anonymousType.declarationSourceStart = alloc.type.sourceStart; - alloc.sourceStart = intStack[intPtr--]; - pushOnExpressionStack(alloc); - - anonymousType.bodyStart = scanner.currentPosition; - listLength = 0; // will be updated when reading super-interfaces - // recovery - if (currentElement != null){ - lastCheckPoint = anonymousType.bodyStart; - // the recoveryTokenCheck will deal with the open brace - currentElement = currentElement.add(anonymousType, 0); - currentToken = 0; // opening brace already taken into account - lastIgnoredToken = -1; - } -} -protected void consumeEnterCompilationUnit() { - // EnterCompilationUnit ::= $empty - // do nothing by default -} -protected void consumeEnterVariable() { - // EnterVariable ::= $empty - // do nothing by default - - char[] name = identifierStack[identifierPtr]; - long namePosition = identifierPositionStack[identifierPtr]; - int extendedDimension = intStack[intPtr--]; - AbstractVariableDeclaration declaration; - // create the ast node - boolean isLocalDeclaration = nestedMethod[nestedType] != 0; - if (isLocalDeclaration) { - // create the local variable declarations - declaration = - this.createLocalDeclaration(null, name, (int) (namePosition >>> 32), (int) namePosition); - } else { - // create the field declaration - declaration = - this.createFieldDeclaration(null, name, (int) (namePosition >>> 32), (int) namePosition); - } - - identifierPtr--; - identifierLengthPtr--; - TypeReference type; - int variableIndex = variablesCounter[nestedType]; - int typeDim = 0; - if (variableIndex == 0) { - // first variable of the declaration (FieldDeclaration or LocalDeclaration) - if (isLocalDeclaration) { - declaration.declarationSourceStart = intStack[intPtr--]; - declaration.modifiers = intStack[intPtr--]; - type = getTypeReference(typeDim = intStack[intPtr--]); // type dimension - if (declaration.declarationSourceStart == -1) { - // this is true if there is no modifiers for the local variable declaration - declaration.declarationSourceStart = type.sourceStart; - } - pushOnAstStack(type); - } else { - type = getTypeReference(typeDim = intStack[intPtr--]); // type dimension - pushOnAstStack(type); - declaration.declarationSourceStart = intStack[intPtr--]; - declaration.modifiers = intStack[intPtr--]; - } - } else { - type = (TypeReference) astStack[astPtr - variableIndex]; - typeDim = type.dimensions(); - AbstractVariableDeclaration previousVariable = - (AbstractVariableDeclaration) astStack[astPtr]; - declaration.declarationSourceStart = previousVariable.declarationSourceStart; - declaration.modifiers = previousVariable.modifiers; - } - - if (extendedDimension == 0) { - declaration.type = type; - } else { - int dimension = typeDim + extendedDimension; - //on the identifierLengthStack there is the information about the type.... - int baseType; - if ((baseType = identifierLengthStack[identifierLengthPtr + 1]) < 0) { - //it was a baseType - int typeSourceStart = type.sourceStart; - int typeSourceEnd = type.sourceEnd; - type = TypeReference.baseTypeReference(-baseType, dimension); - type.sourceStart = typeSourceStart; - type.sourceEnd = typeSourceEnd; - declaration.type = type; - } else { - declaration.type = this.copyDims(type, dimension); - } - } - variablesCounter[nestedType]++; - pushOnAstStack(declaration); - // recovery - if (currentElement != null) { - if (!(currentElement instanceof RecoveredType) - && (currentToken == TokenNameDOT - //|| declaration.modifiers != 0 - || (scanner.getLineNumber(declaration.type.sourceStart) - != scanner.getLineNumber((int) (namePosition >>> 32))))){ - lastCheckPoint = (int) (namePosition >>> 32); - restartRecovery = true; - return; - } - if (isLocalDeclaration){ - LocalDeclaration localDecl = (LocalDeclaration) astStack[astPtr]; - lastCheckPoint = localDecl.sourceEnd + 1; - currentElement = currentElement.add(localDecl, 0); - } else { - FieldDeclaration fieldDecl = (FieldDeclaration) astStack[astPtr]; - lastCheckPoint = fieldDecl.sourceEnd + 1; - currentElement = currentElement.add(fieldDecl, 0); - } - lastIgnoredToken = -1; - } -} -protected void consumeEqualityExpression(int op) { - // EqualityExpression ::= EqualityExpression '==' RelationalExpression - // EqualityExpression ::= EqualityExpression '!=' RelationalExpression - - //optimize the push/pop - - expressionPtr--; - expressionLengthPtr--; - expressionStack[expressionPtr] = - new EqualExpression( - expressionStack[expressionPtr], - expressionStack[expressionPtr + 1], - op); -} -protected void consumeExitVariableWithInitialization() { - // ExitVariableWithInitialization ::= $empty - // do nothing by default - expressionLengthPtr--; - AbstractVariableDeclaration variableDecl = (AbstractVariableDeclaration) astStack[astPtr]; - variableDecl.initialization = expressionStack[expressionPtr--]; - // we need to update the declarationSourceEnd of the local variable declaration to the - // source end position of the initialization expression - variableDecl.declarationSourceEnd = variableDecl.initialization.sourceEnd; - variableDecl.declarationEnd = variableDecl.initialization.sourceEnd; -} -protected void consumeExitVariableWithoutInitialization() { - // ExitVariableWithoutInitialization ::= $empty - // do nothing by default -} -protected void consumeExplicitConstructorInvocation(int flag, int recFlag) { - - /* flag allows to distinguish 3 cases : - (0) : - ExplicitConstructorInvocation ::= 'this' '(' ArgumentListopt ')' ';' - ExplicitConstructorInvocation ::= 'super' '(' ArgumentListopt ')' ';' - (1) : - ExplicitConstructorInvocation ::= Primary '.' 'super' '(' ArgumentListopt ')' ';' - ExplicitConstructorInvocation ::= Primary '.' 'this' '(' ArgumentListopt ')' ';' - (2) : - ExplicitConstructorInvocation ::= Name '.' 'super' '(' ArgumentListopt ')' ';' - ExplicitConstructorInvocation ::= Name '.' 'this' '(' ArgumentListopt ')' ';' - */ - int startPosition = intStack[intPtr--]; - ExplicitConstructorCall ecc = new ExplicitConstructorCall(recFlag); - int length; - if ((length = expressionLengthStack[expressionLengthPtr--]) != 0) { - expressionPtr -= length; - System.arraycopy(expressionStack, expressionPtr + 1, ecc.arguments = new Expression[length], 0, length); - } - switch (flag) { - case 0 : - ecc.sourceStart = startPosition; - break; - case 1 : - expressionLengthPtr--; - ecc.sourceStart = (ecc.qualification = expressionStack[expressionPtr--]).sourceStart; - break; - case 2 : - ecc.sourceStart = (ecc.qualification = getUnspecifiedReferenceOptimized()).sourceStart; - break; - }; - pushOnAstStack(ecc); - ecc.sourceEnd = endPosition; -} -protected void consumeExpressionStatement() { - // ExpressionStatement ::= StatementExpression ';' - expressionLengthPtr--; - pushOnAstStack(expressionStack[expressionPtr--]); -} -protected void consumeFieldAccess(boolean isSuperAccess) { - // FieldAccess ::= Primary '.' 'Identifier' - // FieldAccess ::= 'super' '.' 'Identifier' - - FieldReference fr = - new FieldReference( - identifierStack[identifierPtr], - identifierPositionStack[identifierPtr--]); - identifierLengthPtr--; - if (isSuperAccess) { - //considerates the fieldReference beginning at the 'super' .... - fr.sourceStart = intStack[intPtr--]; - fr.receiver = new SuperReference(fr.sourceStart, endPosition); - pushOnExpressionStack(fr); - } else { - //optimize push/pop - if ((fr.receiver = expressionStack[expressionPtr]).isThis()) { - //fieldreference begins at the this - fr.sourceStart = fr.receiver.sourceStart; - } - expressionStack[expressionPtr] = fr; - } -} -protected void consumeFieldDeclaration() { - // See consumeLocalVariableDeclarationDefaultModifier() in case of change: duplicated code - // FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';' - - /* - astStack : - expressionStack: Expression Expression ...... Expression - identifierStack : type identifier identifier ...... identifier - intStack : typeDim dim dim dim - ==> - astStack : FieldDeclaration FieldDeclaration ...... FieldDeclaration - expressionStack : - identifierStack : - intStack : - - */ - int variableDeclaratorsCounter = astLengthStack[astLengthPtr]; - - for (int i = variableDeclaratorsCounter - 1; i >= 0; i--) { - FieldDeclaration fieldDeclaration = (FieldDeclaration) astStack[astPtr - i]; - fieldDeclaration.declarationSourceEnd = endStatementPosition; - fieldDeclaration.declarationEnd = endStatementPosition; // semi-colon included - } - updateSourceDeclarationParts(variableDeclaratorsCounter); - int endPos = flushAnnotationsDefinedPriorTo(endStatementPosition); - if (endPos != endStatementPosition) { - for (int i = 0; i < variableDeclaratorsCounter; i++) { - FieldDeclaration fieldDeclaration = (FieldDeclaration) astStack[astPtr - i]; - fieldDeclaration.declarationSourceEnd = endPos; - } - } - // update the astStack, astPtr and astLengthStack - int startIndex = astPtr - variablesCounter[nestedType] + 1; - System.arraycopy( - astStack, - startIndex, - astStack, - startIndex - 1, - variableDeclaratorsCounter); - astPtr--; // remove the type reference - astLengthStack[--astLengthPtr] = variableDeclaratorsCounter; - - // recovery - if (currentElement != null) { - lastCheckPoint = endPos + 1; - if (currentElement.parent != null && currentElement instanceof RecoveredField){ - currentElement = currentElement.parent; - } - restartRecovery = true; - } - variablesCounter[nestedType] = 0; -} -protected void consumeForceNoDiet() { - // ForceNoDiet ::= $empty - dietInt++; -} -protected void consumeForInit() { - // ForInit ::= StatementExpressionList - pushOnAstLengthStack(-1); -} -protected void consumeFormalParameter() { - // FormalParameter ::= Type VariableDeclaratorId ==> false - // FormalParameter ::= Modifiers Type VariableDeclaratorId ==> true - /* - astStack : - identifierStack : type identifier - intStack : dim dim - ==> - astStack : Argument - identifierStack : - intStack : - */ - - identifierLengthPtr--; - char[] name = identifierStack[identifierPtr]; - long namePositions = identifierPositionStack[identifierPtr--]; - TypeReference type = getTypeReference(intStack[intPtr--] + intStack[intPtr--]); - int modifierPositions = intStack[intPtr--]; - intPtr--; - Argument arg = - new Argument( - name, - namePositions, - type, - intStack[intPtr + 1] & ~AccDeprecated); // modifiers - arg.declarationSourceStart = modifierPositions; - pushOnAstStack(arg); - - /* if incomplete method header, listLength counter will not have been reset, - indicating that some arguments are available on the stack */ - listLength++; -} -protected void consumeFormalParameterList() { - // FormalParameterList ::= FormalParameterList ',' FormalParameter - optimizedConcatNodeLists(); -} -protected void consumeFormalParameterListopt() { - // FormalParameterListopt ::= $empty - pushOnAstLengthStack(0); -} -protected void consumeImportDeclarations() { - // ImportDeclarations ::= ImportDeclarations ImportDeclaration - optimizedConcatNodeLists(); -} -protected void consumeImportDeclarationsopt() { - // ImportDeclarationsopt ::= ImportDeclarations - int length; - if ((length = astLengthStack[astLengthPtr--]) != 0) { - astPtr -= length; - System.arraycopy( - astStack, - astPtr + 1, - compilationUnit.imports = new ImportReference[length], - 0, - length); - } -} -protected void consumeInstanceOfExpression(int op) { - // RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType - //optimize the push/pop - - //by construction, no base type may be used in getTypeReference - Expression exp; - expressionStack[expressionPtr] = exp = - new InstanceOfExpression( - expressionStack[expressionPtr], - getTypeReference(intStack[intPtr--]), - op); - if (exp.sourceEnd == 0) { - //array on base type.... - exp.sourceEnd = scanner.startPosition - 1; - } - //the scanner is on the next token already.... -} -protected void consumeInterfaceDeclaration() { - // see consumeClassDeclaration in case of changes: duplicated code - // InterfaceDeclaration ::= InterfaceHeader InterfaceBody - int length; - if ((length = astLengthStack[astLengthPtr--]) != 0) { - //there are length declarations - //dispatch.....according to the type of the declarations - dispatchDeclarationInto(length); - } - - TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; - - // mark fields and initializer with local type mark if needed - markFieldsWithLocalType(typeDecl); - - //convert constructor that do not have the type's name into methods - typeDecl.checkConstructors(this); - - //always add (will be remove at code gen time if empty) - if (this.scanner.containsAssertKeyword) { - typeDecl.bits |= AstNode.AddAssertionMASK; - } - typeDecl.addClinit(); - typeDecl.bodyEnd = endStatementPosition; - typeDecl.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); -} -protected void consumeInterfaceHeader() { - // InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt - - TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; - if (currentToken == TokenNameLBRACE){ - typeDecl.bodyStart = scanner.currentPosition; - } - if (currentElement != null){ - restartRecovery = true; // used to avoid branching back into the regular automaton - } - // flush the comments related to the interface header - scanner.commentPtr = -1; -} -protected void consumeInterfaceHeaderExtends() { - // InterfaceHeaderExtends ::= 'extends' InterfaceTypeList - int length = astLengthStack[astLengthPtr--]; - //super interfaces - astPtr -= length; - TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; - System.arraycopy( - astStack, - astPtr + 1, - typeDecl.superInterfaces = new TypeReference[length], - 0, - length); - typeDecl.bodyStart = typeDecl.superInterfaces[length-1].sourceEnd + 1; - listLength = 0; // reset after having read super-interfaces - // recovery - if (currentElement != null) { - lastCheckPoint = typeDecl.bodyStart; - } -} -protected void consumeInterfaceHeaderName() { - // InterfaceHeaderName ::= Modifiersopt 'interface' 'Identifier' - TypeDeclaration typeDecl; - if (nestedMethod[nestedType] == 0) { - if (nestedType != 0) { - typeDecl = new MemberTypeDeclaration(this.compilationUnit.compilationResult); - } else { - typeDecl = new TypeDeclaration(this.compilationUnit.compilationResult); - } - } else { - // Record that the block has a declaration for local types - typeDecl = new LocalTypeDeclaration(this.compilationUnit.compilationResult); - markCurrentMethodWithLocalType(); - blockReal(); - } - - //highlight the name of the type - long pos = identifierPositionStack[identifierPtr]; - typeDecl.sourceEnd = (int) pos; - typeDecl.sourceStart = (int) (pos >>> 32); - typeDecl.name = identifierStack[identifierPtr--]; - identifierLengthPtr--; - - //compute the declaration source too - // 'class' and 'interface' push two int positions: the beginning of the class token and its end. - // we want to keep the beginning position but get rid of the end position - // it is only used for the ClassLiteralAccess positions. - typeDecl.declarationSourceStart = intStack[intPtr--]; - intPtr--; // remove the end position of the class token - typeDecl.modifiersSourceStart = intStack[intPtr--]; - typeDecl.modifiers = intStack[intPtr--]; - if (typeDecl.modifiersSourceStart >= 0) { - typeDecl.declarationSourceStart = typeDecl.modifiersSourceStart; - } - typeDecl.bodyStart = typeDecl.sourceEnd + 1; - pushOnAstStack(typeDecl); - listLength = 0; // will be updated when reading super-interfaces - // recovery - if (currentElement != null){ // is recovering - lastCheckPoint = typeDecl.bodyStart; - currentElement = currentElement.add(typeDecl, 0); - lastIgnoredToken = -1; - } -} -protected void consumeInterfaceMemberDeclarations() { - // InterfaceMemberDeclarations ::= InterfaceMemberDeclarations InterfaceMemberDeclaration - concatNodeLists(); -} -protected void consumeInterfaceMemberDeclarationsopt() { - // InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations - nestedType--; -} -protected void consumeInterfaceType() { - // InterfaceType ::= ClassOrInterfaceType - pushOnAstStack(getTypeReference(0)); - /* if incomplete type header, listLength counter will not have been reset, - indicating that some interfaces are available on the stack */ - listLength++; -} -protected void consumeInterfaceTypeList() { - // InterfaceTypeList ::= InterfaceTypeList ',' InterfaceType - optimizedConcatNodeLists(); -} -protected void consumeLeftHandSide() { - // LeftHandSide ::= Name + case 133 : // System.out.println("MethodDeclaration ::= MethodHeader MethodBody"); + // set to true to consume a method with a body + consumeMethodDeclaration(true); + break; + + case 134 : // System.out.println("AbstractMethodDeclaration ::= MethodHeader SEMICOLON"); + // set to false to consume a method without body + consumeMethodDeclaration(false); + break; + + case 135 : // System.out.println("MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims"); + consumeMethodHeader(); + break; + + case 136 : // System.out.println("MethodPushModifiersHeader ::= MethodPushModifiersHeaderName MethodHeaderParameters"); + consumeMethodHeader(); + break; + + case 137 : // System.out.println("MethodPushModifiersHeaderName ::= Modifiers Type PushModifiers Identifier LPAREN"); + consumeMethodPushModifiersHeaderName(); + break; + + case 138 : // System.out.println("MethodPushModifiersHeaderName ::= Type PushModifiers Identifier LPAREN"); + consumeMethodPushModifiersHeaderName(); + break; + + case 139 : // System.out.println("MethodHeaderName ::= Modifiersopt Type Identifier LPAREN"); + consumeMethodHeaderName(); + break; + + case 140 : // System.out.println("MethodHeaderParameters ::= FormalParameterListopt RPAREN"); + consumeMethodHeaderParameters(); + break; + + case 141 : // System.out.println("MethodHeaderExtendedDims ::= Dimsopt"); + consumeMethodHeaderExtendedDims(); + break; + + case 142 : // System.out.println("MethodHeaderThrowsClause ::= throws ClassTypeList"); + consumeMethodHeaderThrowsClause(); + break; + + case 143 : // System.out.println("ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters..."); + consumeConstructorHeader(); + break; + + case 144 : // System.out.println("ConstructorHeaderName ::= Modifiersopt Identifier LPAREN"); + consumeConstructorHeaderName(); + break; + + case 146 : // System.out.println("FormalParameterList ::= FormalParameterList COMMA FormalParameter"); + consumeFormalParameterList(); + break; + + case 147 : // System.out.println("FormalParameter ::= Modifiersopt Type VariableDeclaratorId"); + // the boolean is used to know if the modifiers should be reset + consumeFormalParameter(); + break; - pushOnExpressionStack(getUnspecifiedReferenceOptimized()); -} -protected void consumeLeftParen() { - // PushLPAREN ::= '(' - pushOnIntStack(lParenPos); -} -protected void consumeLocalVariableDeclaration() { - // LocalVariableDeclaration ::= Modifiers Type VariableDeclarators ';' - - /* - astStack : - expressionStack: Expression Expression ...... Expression - identifierStack : type identifier identifier ...... identifier - intStack : typeDim dim dim dim - ==> - astStack : FieldDeclaration FieldDeclaration ...... FieldDeclaration - expressionStack : - identifierStack : - intStack : - - */ - int variableDeclaratorsCounter = astLengthStack[astLengthPtr]; - - // update the astStack, astPtr and astLengthStack - int startIndex = astPtr - variablesCounter[nestedType] + 1; - System.arraycopy( - astStack, - startIndex, - astStack, - startIndex - 1, - variableDeclaratorsCounter); - astPtr--; // remove the type reference - astLengthStack[--astLengthPtr] = variableDeclaratorsCounter; - variablesCounter[nestedType] = 0; -} -protected void consumeLocalVariableDeclarationStatement() { - // LocalVariableDeclarationStatement ::= LocalVariableDeclaration ';' - // see blockReal in case of change: duplicated code - // increment the amount of declared variables for this block - realBlockStack[realBlockPtr]++; -} -protected void consumeMethodBody() { - // MethodBody ::= NestedMethod '{' BlockStatementsopt '}' - nestedMethod[nestedType] --; -} -protected void consumeMethodDeclaration(boolean isNotAbstract) { - // MethodDeclaration ::= MethodHeader MethodBody - // AbstractMethodDeclaration ::= MethodHeader ';' - - /* - astStack : modifiers arguments throws statements - identifierStack : type name - intStack : dim dim dim - ==> - astStack : MethodDeclaration - identifierStack : - intStack : - */ - - int length; - if (isNotAbstract) { - // pop the position of the { (body of the method) pushed in block decl - intPtr--; - } - - int explicitDeclarations = 0; - Statement[] statements = null; - if (isNotAbstract) { - //statements - explicitDeclarations = realBlockStack[realBlockPtr--]; - if ((length = astLengthStack[astLengthPtr--]) != 0) - System.arraycopy( - astStack, - (astPtr -= length) + 1, - statements = new Statement[length], - 0, - length); - } - - // now we know that we have a method declaration at the top of the ast stack - MethodDeclaration md = (MethodDeclaration) astStack[astPtr]; - md.statements = statements; - md.explicitDeclarations = explicitDeclarations; - - // cannot be done in consumeMethodHeader because we have no idea whether or not there - // is a body when we reduce the method header - if (!isNotAbstract) { //remember the fact that the method has a semicolon body - md.modifiers |= AccSemicolonBody; - } - // store the endPosition (position just before the '}') in case there is - // a trailing comment behind the end of the method - md.bodyEnd = endPosition; - md.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); -} -protected void consumeMethodHeader() { - // MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims ThrowsClauseopt - // retrieve end position of method declarator - AbstractMethodDeclaration method = (AbstractMethodDeclaration)astStack[astPtr]; - - if (currentToken == TokenNameLBRACE){ - method.bodyStart = scanner.currentPosition; - } - // recovery - if (currentElement != null){ - if (currentToken == TokenNameSEMICOLON){ - method.modifiers |= AccSemicolonBody; - method.declarationSourceEnd = scanner.currentPosition-1; - method.bodyEnd = scanner.currentPosition-1; - if (currentElement.parent != null){ - currentElement = currentElement.parent; - } - } - restartRecovery = true; // used to avoid branching back into the regular automaton - } -} -protected void consumeMethodHeaderExtendedDims() { - // MethodHeaderExtendedDims ::= Dimsopt - // now we update the returnType of the method - MethodDeclaration md = (MethodDeclaration) astStack[astPtr]; - int extendedDims = intStack[intPtr--]; - if (extendedDims != 0) { - TypeReference returnType = md.returnType; - md.sourceEnd = endPosition; - int dims = returnType.dimensions() + extendedDims; - int baseType; - if ((baseType = identifierLengthStack[identifierLengthPtr + 1]) < 0) { - //it was a baseType - int sourceStart = returnType.sourceStart; - int sourceEnd = returnType.sourceEnd; - returnType = TypeReference.baseTypeReference(-baseType, dims); - returnType.sourceStart = sourceStart; - returnType.sourceEnd = sourceEnd; - md.returnType = returnType; - } else { - md.returnType = this.copyDims(md.returnType, dims); - } - if (currentToken == TokenNameLBRACE){ - md.bodyStart = endPosition + 1; - } - // recovery - if (currentElement != null){ - lastCheckPoint = md.bodyStart; - } - } -} -protected void consumeMethodHeaderName() { - // MethodHeaderName ::= Modifiersopt Type 'Identifier' '(' - MethodDeclaration md = new MethodDeclaration(this.compilationUnit.compilationResult); - - //name - md.selector = identifierStack[identifierPtr]; - long selectorSource = identifierPositionStack[identifierPtr--]; - identifierLengthPtr--; - //type - md.returnType = getTypeReference(intStack[intPtr--]); - //modifiers - md.declarationSourceStart = intStack[intPtr--]; - md.modifiers = intStack[intPtr--]; - - //highlight starts at selector start - md.sourceStart = (int) (selectorSource >>> 32); - pushOnAstStack(md); - md.sourceEnd = lParenPos; - md.bodyStart = lParenPos+1; - listLength = 0; // initialize listLength before reading parameters/throws - - // recovery - if (currentElement != null){ - if (currentElement instanceof RecoveredType - //|| md.modifiers != 0 - || (scanner.getLineNumber(md.returnType.sourceStart) - == scanner.getLineNumber(md.sourceStart))){ - lastCheckPoint = md.bodyStart; - currentElement = currentElement.add(md, 0); - lastIgnoredToken = -1; - } else { - lastCheckPoint = md.sourceStart; - restartRecovery = true; - } - } -} -protected void consumeMethodHeaderParameters() { - // MethodHeaderParameters ::= FormalParameterListopt ')' - int length = astLengthStack[astLengthPtr--]; - astPtr -= length; - AbstractMethodDeclaration md = (AbstractMethodDeclaration) astStack[astPtr]; - md.sourceEnd = rParenPos; - //arguments - if (length != 0) { - System.arraycopy( - astStack, - astPtr + 1, - md.arguments = new Argument[length], - 0, - length); - } - md.bodyStart = rParenPos+1; - listLength = 0; // reset listLength after having read all parameters - // recovery - if (currentElement != null){ - lastCheckPoint = md.bodyStart; - if (currentElement.parseTree() == md) return; - - // might not have been attached yet - in some constructor scenarii - if (md.isConstructor()){ - if ((length != 0) - || (currentToken == TokenNameLBRACE) - // || (currentToken == TokenNamethrows) - ){ - currentElement = currentElement.add(md, 0); - lastIgnoredToken = -1; - } - } - } -} -protected void consumeMethodHeaderThrowsClause() { - // MethodHeaderThrowsClause ::= 'throws' ClassTypeList - int length = astLengthStack[astLengthPtr--]; - astPtr -= length; - AbstractMethodDeclaration md = (AbstractMethodDeclaration) astStack[astPtr]; - System.arraycopy( - astStack, - astPtr + 1, - md.thrownExceptions = new TypeReference[length], - 0, - length); - md.sourceEnd = md.thrownExceptions[length-1].sourceEnd; - md.bodyStart = md.thrownExceptions[length-1].sourceEnd + 1; - listLength = 0; // reset listLength after having read all thrown exceptions - // recovery - if (currentElement != null){ - lastCheckPoint = md.bodyStart; - } -} -protected void consumeMethodInvocationName() { - // MethodInvocation ::= Name '(' ArgumentListopt ')' - - // when the name is only an identifier...we have a message send to "this" (implicit) - - MessageSend m = newMessageSend(); - m.sourceEnd = rParenPos; - m.sourceStart = - (int) ((m.nameSourcePosition = identifierPositionStack[identifierPtr]) >>> 32); - m.selector = identifierStack[identifierPtr--]; - if (identifierLengthStack[identifierLengthPtr] == 1) { - m.receiver = ThisReference.ThisImplicit; - identifierLengthPtr--; - } else { - identifierLengthStack[identifierLengthPtr]--; - m.receiver = getUnspecifiedReference(); - m.sourceStart = m.receiver.sourceStart; - } - pushOnExpressionStack(m); -} -protected void consumeMethodInvocationPrimary() { - //optimize the push/pop - //MethodInvocation ::= Primary '.' 'Identifier' '(' ArgumentListopt ')' - - MessageSend m = newMessageSend(); - m.sourceStart = - (int) ((m.nameSourcePosition = identifierPositionStack[identifierPtr]) >>> 32); - m.selector = identifierStack[identifierPtr--]; - identifierLengthPtr--; - m.receiver = expressionStack[expressionPtr]; - m.sourceStart = m.receiver.sourceStart; - m.sourceEnd = rParenPos; - expressionStack[expressionPtr] = m; -} -protected void consumeMethodInvocationSuper() { - // MethodInvocation ::= 'super' '.' 'Identifier' '(' ArgumentListopt ')' - - MessageSend m = newMessageSend(); - m.sourceStart = intStack[intPtr--]; - m.sourceEnd = rParenPos; - m.nameSourcePosition = identifierPositionStack[identifierPtr]; - m.selector = identifierStack[identifierPtr--]; - identifierLengthPtr--; - m.receiver = new SuperReference(m.sourceStart, endPosition); - pushOnExpressionStack(m); -} -protected void consumeMethodPushModifiersHeaderName() { - // MethodPushModifiersHeaderName ::= Modifiers Type PushModifiers 'Identifier' '(' - // MethodPushModifiersHeaderName ::= Type PushModifiers 'Identifier' '(' - MethodDeclaration md = new MethodDeclaration(this.compilationUnit.compilationResult); - - //name - md.selector = identifierStack[identifierPtr]; - long selectorSource = identifierPositionStack[identifierPtr--]; - identifierLengthPtr--; - - //modifiers - md.declarationSourceStart = intStack[intPtr--]; - md.modifiers = intStack[intPtr--]; - - //type - md.returnType = getTypeReference(intStack[intPtr--]); - - //highlight starts at selector start - md.sourceStart = (int) (selectorSource >>> 32); - pushOnAstStack(md); - md.sourceEnd = lParenPos; - md.bodyStart = lParenPos + 1; - listLength = 0; // initialize listLength before reading parameters/throws - - // recovery - if (currentElement != null) { - lastCheckPoint = md.bodyStart; - currentElement = currentElement.add(md, 0); - lastIgnoredToken = -1; - } -} -protected void consumeModifiers() { - int savedModifiersSourceStart = modifiersSourceStart; - checkAnnotation(); // might update modifiers with AccDeprecated - pushOnIntStack(modifiers); // modifiers - if (modifiersSourceStart >= savedModifiersSourceStart) { - modifiersSourceStart = savedModifiersSourceStart; - } - pushOnIntStack(modifiersSourceStart); - resetModifiers(); -} -protected void consumeNestedMethod() { - // NestedMethod ::= $empty - jumpOverMethodBody(); - nestedMethod[nestedType] ++; - consumeOpenBlock(); -} -protected void consumeNestedType() { - // NestedType ::= $empty - nestedType++; - try { - nestedMethod[nestedType] = 0; - } catch (IndexOutOfBoundsException e) { - //except in test's cases, it should never raise - int oldL = nestedMethod.length; - System.arraycopy(nestedMethod , 0, (nestedMethod = new int[oldL + 30]), 0, oldL); - nestedMethod[nestedType] = 0; - // increase the size of the fieldsCounter as well. It has to be consistent with the size of the nestedMethod collection - System.arraycopy(variablesCounter, 0, (variablesCounter = new int[oldL + 30]), 0, oldL); - } - variablesCounter[nestedType] = 0; -} -protected void consumeOneDimLoop() { - // OneDimLoop ::= '[' ']' - dimensions++; -} -protected void consumeOnlySynchronized() { - // OnlySynchronized ::= 'synchronized' - pushOnIntStack(this.synchronizedBlockSourceStart); - resetModifiers(); -} -protected void consumeOpenBlock() { - // OpenBlock ::= $empty - - pushOnIntStack(scanner.startPosition); - try { - realBlockStack[++realBlockPtr] = 0; - } catch (IndexOutOfBoundsException e) { - //realBlockPtr is correct - int oldStackLength = realBlockStack.length; - int oldStack[] = realBlockStack; - realBlockStack = new int[oldStackLength + StackIncrement]; - System.arraycopy(oldStack, 0, realBlockStack, 0, oldStackLength); - realBlockStack[realBlockPtr] = 0; - } -} -protected void consumePackageDeclaration() { - // PackageDeclaration ::= 'package' Name ';' - /* build an ImportRef build from the last name - stored in the identifier stack. */ - - ImportReference impt = compilationUnit.currentPackage; - // flush annotations defined prior to import statements - impt.declarationEnd = endStatementPosition; - impt.declarationSourceEnd = this.flushAnnotationsDefinedPriorTo(impt.declarationSourceEnd); -} -protected void consumePackageDeclarationName() { - // PackageDeclarationName ::= 'package' Name - /* build an ImportRef build from the last name - stored in the identifier stack. */ - - ImportReference impt; - int length; - char[][] tokens = - new char[length = identifierLengthStack[identifierLengthPtr--]][]; - identifierPtr -= length; - long[] positions = new long[length]; - System.arraycopy(identifierStack, ++identifierPtr, tokens, 0, length); - System.arraycopy( - identifierPositionStack, - identifierPtr--, - positions, - 0, - length); - compilationUnit.currentPackage = - impt = new ImportReference(tokens, positions, true); - - if (currentToken == TokenNameSEMICOLON){ - impt.declarationSourceEnd = scanner.currentPosition - 1; - } else { - impt.declarationSourceEnd = impt.sourceEnd; - } - impt.declarationEnd = impt.declarationSourceEnd; - //endPosition is just before the ; - impt.declarationSourceStart = intStack[intPtr--]; - - // recovery - if (currentElement != null){ - lastCheckPoint = impt.declarationSourceEnd+1; - restartRecovery = true; // used to avoid branching back into the regular automaton - } -} -protected void consumePostfixExpression() { - // PostfixExpression ::= Name - pushOnExpressionStack(getUnspecifiedReferenceOptimized()); -} -protected void consumePrimaryNoNewArray() { - // PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN - updateSourcePosition(expressionStack[expressionPtr]); -} -protected void consumePrimaryNoNewArrayArrayType() { - // PrimaryNoNewArray ::= ArrayType '.' 'class' - intPtr--; - pushOnExpressionStack( - new ClassLiteralAccess(intStack[intPtr--], - getTypeReference(intStack[intPtr--]))); -} -protected void consumePrimaryNoNewArrayName() { - // PrimaryNoNewArray ::= Name '.' 'class' - intPtr--; - pushOnExpressionStack( - new ClassLiteralAccess(intStack[intPtr--], - getTypeReference(0))); -} -protected void consumePrimaryNoNewArrayNameSuper() { - // PrimaryNoNewArray ::= Name '.' 'super' - pushOnExpressionStack( - new QualifiedSuperReference( - getTypeReference(0), - intStack[intPtr--], - endPosition)); -} -protected void consumePrimaryNoNewArrayNameThis() { - // PrimaryNoNewArray ::= Name '.' 'this' - pushOnExpressionStack( - new QualifiedThisReference( - getTypeReference(0), - intStack[intPtr--], - endPosition)); -} -protected void consumePrimaryNoNewArrayPrimitiveType() { - // PrimaryNoNewArray ::= PrimitiveType '.' 'class' - intPtr--; - pushOnExpressionStack( - new ClassLiteralAccess(intStack[intPtr--], - getTypeReference(0))); -} -protected void consumePrimaryNoNewArrayThis() { - // PrimaryNoNewArray ::= 'this' - pushOnExpressionStack(new ThisReference(intStack[intPtr--], endPosition)); -} -protected void consumePrimitiveType() { - // Type ::= PrimitiveType - pushOnIntStack(0); -} -protected void consumePushModifiers() { - if ((modifiers & AccSynchronized) != 0) { - /* remove the starting position of the synchronized keyword - * we don't need it when synchronized is part of the modifiers - */ - intPtr--; - } - pushOnIntStack(modifiers); // modifiers - pushOnIntStack(modifiersSourceStart); - resetModifiers(); -} -protected void consumePushPosition() { - // for source managment purpose - // PushPosition ::= $empty - pushOnIntStack(endPosition); -} -protected void consumeQualifiedName() { - // QualifiedName ::= Name '.' SimpleName - /*back from the recursive loop of QualifiedName. - Updates identifier length into the length stack*/ + case 149 : // System.out.println("ClassTypeList ::= ClassTypeList COMMA ClassTypeElt"); + consumeClassTypeList(); + break; - identifierLengthStack[--identifierLengthPtr]++; -} -protected void consumeReferenceType() { - // ReferenceType ::= ClassOrInterfaceType - pushOnIntStack(0); -} -protected void consumeRestoreDiet() { - // RestoreDiet ::= $empty - dietInt--; -} -protected void consumeRightParen() { - // PushRPAREN ::= ')' - pushOnIntStack(rParenPos); -} - // This method is part of an automatic generation : do NOT edit-modify - // This method is part of an automatic generation : do NOT edit-modify - protected void consumeRule(int act) { - switch ( act ) { - case 29 : // System.out.println("Type ::= PrimitiveType"); - consumePrimitiveType(); - break ; - - case 43 : // System.out.println("ReferenceType ::= ClassOrInterfaceType"); - consumeReferenceType(); - break ; - - case 52 : // System.out.println("QualifiedName ::= Name DOT SimpleName"); - consumeQualifiedName(); - break ; - - case 53 : // System.out.println("CompilationUnit ::= EnterCompilationUnit PackageDeclarationopt ImportDeclarationsopt"); - consumeCompilationUnit(); - break ; - - case 54 : // System.out.println("EnterCompilationUnit ::="); - consumeEnterCompilationUnit(); - break ; - - case 66 : // System.out.println("CatchHeader ::= catch LPAREN FormalParameter RPAREN LBRACE"); - consumeCatchHeader(); - break ; - - case 68 : // System.out.println("ImportDeclarations ::= ImportDeclarations ImportDeclaration"); - consumeImportDeclarations(); - break ; - - case 70 : // System.out.println("TypeDeclarations ::= TypeDeclarations TypeDeclaration"); - consumeTypeDeclarations(); - break ; - - case 71 : // System.out.println("PackageDeclaration ::= PackageDeclarationName SEMICOLON"); - consumePackageDeclaration(); - break ; - - case 72 : // System.out.println("PackageDeclarationName ::= package Name"); - consumePackageDeclarationName(); - break ; - - case 75 : // System.out.println("SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName SEMICOLON"); - consumeSingleTypeImportDeclaration(); - break ; - - case 76 : // System.out.println("SingleTypeImportDeclarationName ::= import Name"); - consumeSingleTypeImportDeclarationName(); - break ; - - case 77 : // System.out.println("TypeImportOnDemandDeclaration ::= TypeImportOnDemandDeclarationName SEMICOLON"); - consumeTypeImportOnDemandDeclaration(); - break ; - - case 78 : // System.out.println("TypeImportOnDemandDeclarationName ::= import Name DOT MULTIPLY"); - consumeTypeImportOnDemandDeclarationName(); - break ; - - case 81 : // System.out.println("TypeDeclaration ::= SEMICOLON"); - consumeEmptyTypeDeclaration(); - break ; - - case 95 : // System.out.println("ClassDeclaration ::= ClassHeader ClassBody"); - consumeClassDeclaration(); - break ; - - case 96 : // System.out.println("ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt"); - consumeClassHeader(); - break ; - - case 97 : // System.out.println("ClassHeaderName ::= Modifiersopt class Identifier"); - consumeClassHeaderName(); - break ; - - case 98 : // System.out.println("ClassHeaderExtends ::= extends ClassType"); - consumeClassHeaderExtends(); - break ; - - case 99 : // System.out.println("ClassHeaderImplements ::= implements InterfaceTypeList"); - consumeClassHeaderImplements(); - break ; - - case 101 : // System.out.println("InterfaceTypeList ::= InterfaceTypeList COMMA InterfaceType"); - consumeInterfaceTypeList(); - break ; - - case 102 : // System.out.println("InterfaceType ::= ClassOrInterfaceType"); - consumeInterfaceType(); - break ; - - case 105 : // System.out.println("ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration"); - consumeClassBodyDeclarations(); - break ; - - case 109 : // System.out.println("ClassBodyDeclaration ::= Diet NestedMethod Block"); - consumeClassBodyDeclaration(); - break ; - - case 110 : // System.out.println("Diet ::="); - consumeDiet(); - break ; - - case 111 : // System.out.println("Initializer ::= Diet NestedMethod Block"); - consumeClassBodyDeclaration(); - break ; - - case 118 : // System.out.println("ClassMemberDeclaration ::= SEMICOLON"); - consumeEmptyClassMemberDeclaration(); - break ; - - case 119 : // System.out.println("FieldDeclaration ::= Modifiersopt Type VariableDeclarators SEMICOLON"); - consumeFieldDeclaration(); - break ; - - case 121 : // System.out.println("VariableDeclarators ::= VariableDeclarators COMMA VariableDeclarator"); - consumeVariableDeclarators(); - break ; - - case 124 : // System.out.println("EnterVariable ::="); - consumeEnterVariable(); - break ; - - case 125 : // System.out.println("ExitVariableWithInitialization ::="); - consumeExitVariableWithInitialization(); - break ; - - case 126 : // System.out.println("ExitVariableWithoutInitialization ::="); - consumeExitVariableWithoutInitialization(); - break ; - - case 127 : // System.out.println("ForceNoDiet ::="); - consumeForceNoDiet(); - break ; - - case 128 : // System.out.println("RestoreDiet ::="); - consumeRestoreDiet(); - break ; - - case 133 : // System.out.println("MethodDeclaration ::= MethodHeader MethodBody"); - // set to true to consume a method with a body - consumeMethodDeclaration(true); - break ; - - case 134 : // System.out.println("AbstractMethodDeclaration ::= MethodHeader SEMICOLON"); - // set to false to consume a method without body - consumeMethodDeclaration(false); - break ; - - case 135 : // System.out.println("MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims"); - consumeMethodHeader(); - break ; - - case 136 : // System.out.println("MethodPushModifiersHeader ::= MethodPushModifiersHeaderName MethodHeaderParameters"); - consumeMethodHeader(); - break ; - - case 137 : // System.out.println("MethodPushModifiersHeaderName ::= Modifiers Type PushModifiers Identifier LPAREN"); - consumeMethodPushModifiersHeaderName(); - break ; - - case 138 : // System.out.println("MethodPushModifiersHeaderName ::= Type PushModifiers Identifier LPAREN"); - consumeMethodPushModifiersHeaderName(); - break ; - - case 139 : // System.out.println("MethodHeaderName ::= Modifiersopt Type Identifier LPAREN"); - consumeMethodHeaderName(); - break ; - - case 140 : // System.out.println("MethodHeaderParameters ::= FormalParameterListopt RPAREN"); - consumeMethodHeaderParameters(); - break ; - - case 141 : // System.out.println("MethodHeaderExtendedDims ::= Dimsopt"); - consumeMethodHeaderExtendedDims(); - break ; - - case 142 : // System.out.println("MethodHeaderThrowsClause ::= throws ClassTypeList"); - consumeMethodHeaderThrowsClause(); - break ; - - case 143 : // System.out.println("ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters..."); - consumeConstructorHeader(); - break ; - - case 144 : // System.out.println("ConstructorHeaderName ::= Modifiersopt Identifier LPAREN"); - consumeConstructorHeaderName(); - break ; - - case 146 : // System.out.println("FormalParameterList ::= FormalParameterList COMMA FormalParameter"); - consumeFormalParameterList(); - break ; - - case 147 : // System.out.println("FormalParameter ::= Modifiersopt Type VariableDeclaratorId"); - // the boolean is used to know if the modifiers should be reset - consumeFormalParameter(); - break ; - - case 149 : // System.out.println("ClassTypeList ::= ClassTypeList COMMA ClassTypeElt"); - consumeClassTypeList(); - break ; - - case 150 : // System.out.println("ClassTypeElt ::= ClassType"); - consumeClassTypeElt(); - break ; - - case 151 : // System.out.println("MethodBody ::= NestedMethod LBRACE BlockStatementsopt RBRACE"); - consumeMethodBody(); - break ; - - case 152 : // System.out.println("NestedMethod ::="); - consumeNestedMethod(); - break ; - - case 153 : // System.out.println("StaticInitializer ::= StaticOnly Block"); - consumeStaticInitializer(); - break ; - - case 154 : // System.out.println("StaticOnly ::= static"); - consumeStaticOnly(); - break ; - - case 155 : // System.out.println("ConstructorDeclaration ::= ConstructorHeader ConstructorBody"); - consumeConstructorDeclaration() ; - break ; - - case 156 : // System.out.println("ConstructorDeclaration ::= ConstructorHeader SEMICOLON"); - consumeInvalidConstructorDeclaration() ; - break ; - - case 157 : // System.out.println("ConstructorBody ::= NestedMethod LBRACE ConstructorBlockStatementsopt RBRACE"); - consumeConstructorBody(); - break ; - - case 160 : // System.out.println("ConstructorBlockStatementsopt ::= ExplicitConstructorInvocation BlockStatements"); - consumeConstructorBlockStatements(); - break ; - - case 161 : // System.out.println("ExplicitConstructorInvocation ::= this LPAREN ArgumentListopt RPAREN SEMICOLON"); - consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.This); - break ; - - case 162 : // System.out.println("ExplicitConstructorInvocation ::= super LPAREN ArgumentListopt RPAREN SEMICOLON"); - consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.Super); - break ; - - case 163 : // System.out.println("ExplicitConstructorInvocation ::= Primary DOT super LPAREN ArgumentListopt RPAREN"); - consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.Super); - break ; - - case 164 : // System.out.println("ExplicitConstructorInvocation ::= Name DOT super LPAREN ArgumentListopt RPAREN..."); - consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.Super); - break ; - - case 165 : // System.out.println("ExplicitConstructorInvocation ::= Primary DOT this LPAREN ArgumentListopt RPAREN..."); - consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.This); - break ; - - case 166 : // System.out.println("ExplicitConstructorInvocation ::= Name DOT this LPAREN ArgumentListopt RPAREN..."); - consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.This); - break ; - - case 167 : // System.out.println("InterfaceDeclaration ::= InterfaceHeader InterfaceBody"); - consumeInterfaceDeclaration(); - break ; - - case 168 : // System.out.println("InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt"); - consumeInterfaceHeader(); - break ; - - case 169 : // System.out.println("InterfaceHeaderName ::= Modifiersopt interface Identifier"); - consumeInterfaceHeaderName(); - break ; - - case 171 : // System.out.println("InterfaceHeaderExtends ::= extends InterfaceTypeList"); - consumeInterfaceHeaderExtends(); - break ; - - case 174 : // System.out.println("InterfaceMemberDeclarations ::= InterfaceMemberDeclarations..."); - consumeInterfaceMemberDeclarations(); - break ; - - case 175 : // System.out.println("InterfaceMemberDeclaration ::= SEMICOLON"); - consumeEmptyInterfaceMemberDeclaration(); - break ; - - case 178 : // System.out.println("InterfaceMemberDeclaration ::= InvalidMethodDeclaration"); - ignoreMethodBody(); - break ; - - case 179 : // System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody"); - ignoreInvalidConstructorDeclaration(true); - break ; - - case 180 : // System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader SEMICOLON"); - ignoreInvalidConstructorDeclaration(false); - break ; - - case 186 : // System.out.println("ArrayInitializer ::= LBRACE ,opt RBRACE"); - consumeEmptyArrayInitializer(); - break ; - - case 187 : // System.out.println("ArrayInitializer ::= LBRACE VariableInitializers RBRACE"); - consumeArrayInitializer(); - break ; - - case 188 : // System.out.println("ArrayInitializer ::= LBRACE VariableInitializers COMMA RBRACE"); - consumeArrayInitializer(); - break ; - - case 190 : // System.out.println("VariableInitializers ::= VariableInitializers COMMA VariableInitializer"); - consumeVariableInitializers(); - break ; - - case 191 : // System.out.println("Block ::= OpenBlock LBRACE BlockStatementsopt RBRACE"); - consumeBlock(); - break ; - - case 192 : // System.out.println("OpenBlock ::="); - consumeOpenBlock() ; - break ; - - case 194 : // System.out.println("BlockStatements ::= BlockStatements BlockStatement"); - consumeBlockStatements() ; - break ; - - case 198 : // System.out.println("BlockStatement ::= InvalidInterfaceDeclaration"); - ignoreInterfaceDeclaration(); - break ; - - case 199 : // System.out.println("LocalVariableDeclarationStatement ::= LocalVariableDeclaration SEMICOLON"); - consumeLocalVariableDeclarationStatement(); - break ; - - case 200 : // System.out.println("LocalVariableDeclaration ::= Type PushModifiers VariableDeclarators"); - consumeLocalVariableDeclaration(); - break ; - - case 201 : // System.out.println("LocalVariableDeclaration ::= Modifiers Type PushModifiers VariableDeclarators"); - consumeLocalVariableDeclaration(); - break ; - - case 202 : // System.out.println("PushModifiers ::="); - consumePushModifiers(); - break ; - - case 226 : // System.out.println("EmptyStatement ::= SEMICOLON"); - consumeEmptyStatement(); - break ; - - case 227 : // System.out.println("LabeledStatement ::= Identifier COLON Statement"); - consumeStatementLabel() ; - break ; - - case 228 : // System.out.println("LabeledStatementNoShortIf ::= Identifier COLON StatementNoShortIf"); - consumeStatementLabel() ; - break ; - - case 229 : // System.out.println("ExpressionStatement ::= StatementExpression SEMICOLON"); - consumeExpressionStatement(); - break ; - - case 237 : // System.out.println("IfThenStatement ::= if LPAREN Expression RPAREN Statement"); - consumeStatementIfNoElse(); - break ; - - case 238 : // System.out.println("IfThenElseStatement ::= if LPAREN Expression RPAREN StatementNoShortIf else..."); - consumeStatementIfWithElse(); - break ; - - case 239 : // System.out.println("IfThenElseStatementNoShortIf ::= if LPAREN Expression RPAREN StatementNoShortIf..."); - consumeStatementIfWithElse(); - break ; - - case 240 : // System.out.println("SwitchStatement ::= switch OpenBlock LPAREN Expression RPAREN SwitchBlock"); - consumeStatementSwitch() ; - break ; - - case 241 : // System.out.println("SwitchBlock ::= LBRACE RBRACE"); - consumeEmptySwitchBlock() ; - break ; - - case 244 : // System.out.println("SwitchBlock ::= LBRACE SwitchBlockStatements SwitchLabels RBRACE"); - consumeSwitchBlock() ; - break ; - - case 246 : // System.out.println("SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement"); - consumeSwitchBlockStatements() ; - break ; - - case 247 : // System.out.println("SwitchBlockStatement ::= SwitchLabels BlockStatements"); - consumeSwitchBlockStatement() ; - break ; - - case 249 : // System.out.println("SwitchLabels ::= SwitchLabels SwitchLabel"); - consumeSwitchLabels() ; - break ; - - case 250 : // System.out.println("SwitchLabel ::= case ConstantExpression COLON"); - consumeCaseLabel(); - break ; - - case 251 : // System.out.println("SwitchLabel ::= default COLON"); - consumeDefaultLabel(); - break ; - - case 252 : // System.out.println("WhileStatement ::= while LPAREN Expression RPAREN Statement"); - consumeStatementWhile() ; - break ; - - case 253 : // System.out.println("WhileStatementNoShortIf ::= while LPAREN Expression RPAREN StatementNoShortIf"); - consumeStatementWhile() ; - break ; - - case 254 : // System.out.println("DoStatement ::= do Statement while LPAREN Expression RPAREN SEMICOLON"); - consumeStatementDo() ; - break ; - - case 255 : // System.out.println("ForStatement ::= for LPAREN ForInitopt SEMICOLON Expressionopt SEMICOLON..."); - consumeStatementFor() ; - break ; - - case 256 : // System.out.println("ForStatementNoShortIf ::= for LPAREN ForInitopt SEMICOLON Expressionopt SEMICOLON"); - consumeStatementFor() ; - break ; - - case 257 : // System.out.println("ForInit ::= StatementExpressionList"); - consumeForInit() ; - break ; - - case 261 : // System.out.println("StatementExpressionList ::= StatementExpressionList COMMA StatementExpression"); - consumeStatementExpressionList() ; - break ; - - case 262 : // System.out.println("AssertStatement ::= assert Expression SEMICOLON"); - consumeSimpleAssertStatement() ; - break ; - - case 263 : // System.out.println("AssertStatement ::= assert Expression COLON Expression SEMICOLON"); - consumeAssertStatement() ; - break ; - - case 264 : // System.out.println("BreakStatement ::= break SEMICOLON"); - consumeStatementBreak() ; - break ; - - case 265 : // System.out.println("BreakStatement ::= break Identifier SEMICOLON"); - consumeStatementBreakWithLabel() ; - break ; - - case 266 : // System.out.println("ContinueStatement ::= continue SEMICOLON"); - consumeStatementContinue() ; - break ; - - case 267 : // System.out.println("ContinueStatement ::= continue Identifier SEMICOLON"); - consumeStatementContinueWithLabel() ; - break ; - - case 268 : // System.out.println("ReturnStatement ::= return Expressionopt SEMICOLON"); - consumeStatementReturn() ; - break ; - - case 269 : // System.out.println("ThrowStatement ::= throw Expression SEMICOLON"); - consumeStatementThrow(); - - break ; - - case 270 : // System.out.println("SynchronizedStatement ::= OnlySynchronized LPAREN Expression RPAREN Block"); - consumeStatementSynchronized(); - break ; - - case 271 : // System.out.println("OnlySynchronized ::= synchronized"); - consumeOnlySynchronized(); - break ; - - case 272 : // System.out.println("TryStatement ::= try Block Catches"); - consumeStatementTry(false); - break ; - - case 273 : // System.out.println("TryStatement ::= try Block Catchesopt Finally"); - consumeStatementTry(true); - break ; - - case 275 : // System.out.println("Catches ::= Catches CatchClause"); - consumeCatches(); - break ; - - case 276 : // System.out.println("CatchClause ::= catch LPAREN FormalParameter RPAREN Block"); - consumeStatementCatch() ; - break ; - - case 278 : // System.out.println("PushLPAREN ::= LPAREN"); - consumeLeftParen(); - break ; - - case 279 : // System.out.println("PushRPAREN ::= RPAREN"); - consumeRightParen(); - break ; - - case 283 : // System.out.println("PrimaryNoNewArray ::= this"); - consumePrimaryNoNewArrayThis(); - break ; - - case 284 : // System.out.println("PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN"); - consumePrimaryNoNewArray(); - break ; - - case 287 : // System.out.println("PrimaryNoNewArray ::= Name DOT this"); - consumePrimaryNoNewArrayNameThis(); - break ; - - case 288 : // System.out.println("PrimaryNoNewArray ::= Name DOT super"); - consumePrimaryNoNewArrayNameSuper(); - break ; - - case 289 : // System.out.println("PrimaryNoNewArray ::= Name DOT class"); - consumePrimaryNoNewArrayName(); - break ; - - case 290 : // System.out.println("PrimaryNoNewArray ::= ArrayType DOT class"); - consumePrimaryNoNewArrayArrayType(); - break ; - - case 291 : // System.out.println("PrimaryNoNewArray ::= PrimitiveType DOT class"); - consumePrimaryNoNewArrayPrimitiveType(); - break ; - - case 294 : // System.out.println("AllocationHeader ::= new ClassType LPAREN ArgumentListopt RPAREN"); - consumeAllocationHeader(); - break ; - - case 295 : // System.out.println("ClassInstanceCreationExpression ::= new ClassType LPAREN ArgumentListopt RPAREN..."); - consumeClassInstanceCreationExpression(); - break ; - - case 296 : // System.out.println("ClassInstanceCreationExpression ::= Primary DOT new SimpleName LPAREN..."); - consumeClassInstanceCreationExpressionQualified() ; - break ; - - case 297 : // System.out.println("ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName new..."); - consumeClassInstanceCreationExpressionQualified() ; - break ; - - case 298 : // System.out.println("ClassInstanceCreationExpressionName ::= Name DOT"); - consumeClassInstanceCreationExpressionName() ; - break ; - - case 299 : // System.out.println("ClassBodyopt ::="); - consumeClassBodyopt(); - break ; - - case 301 : // System.out.println("EnterAnonymousClassBody ::="); - consumeEnterAnonymousClassBody(); - break ; - - case 303 : // System.out.println("ArgumentList ::= ArgumentList COMMA Expression"); - consumeArgumentList(); - break ; - - case 304 : // System.out.println("ArrayCreationExpression ::= new PrimitiveType DimWithOrWithOutExprs..."); - consumeArrayCreationExpression(); - break ; - - case 305 : // System.out.println("ArrayCreationExpression ::= new ClassOrInterfaceType DimWithOrWithOutExprs..."); - consumeArrayCreationExpression(); - break ; - - case 307 : // System.out.println("DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr"); - consumeDimWithOrWithOutExprs(); - break ; - - case 309 : // System.out.println("DimWithOrWithOutExpr ::= LBRACKET RBRACKET"); - consumeDimWithOrWithOutExpr(); - break ; - - case 310 : // System.out.println("Dims ::= DimsLoop"); - consumeDims(); - break ; - - case 313 : // System.out.println("OneDimLoop ::= LBRACKET RBRACKET"); - consumeOneDimLoop(); - break ; - - case 314 : // System.out.println("FieldAccess ::= Primary DOT Identifier"); - consumeFieldAccess(false); - break ; - - case 315 : // System.out.println("FieldAccess ::= super DOT Identifier"); - consumeFieldAccess(true); - break ; - - case 316 : // System.out.println("MethodInvocation ::= Name LPAREN ArgumentListopt RPAREN"); - consumeMethodInvocationName(); - break ; - - case 317 : // System.out.println("MethodInvocation ::= Primary DOT Identifier LPAREN ArgumentListopt RPAREN"); - consumeMethodInvocationPrimary(); - break ; - - case 318 : // System.out.println("MethodInvocation ::= super DOT Identifier LPAREN ArgumentListopt RPAREN"); - consumeMethodInvocationSuper(); - break ; - - case 319 : // System.out.println("ArrayAccess ::= Name LBRACKET Expression RBRACKET"); - consumeArrayAccess(true); - break ; - - case 320 : // System.out.println("ArrayAccess ::= PrimaryNoNewArray LBRACKET Expression RBRACKET"); - consumeArrayAccess(false); - break ; - - case 322 : // System.out.println("PostfixExpression ::= Name"); - consumePostfixExpression(); - break ; - - case 325 : // System.out.println("PostIncrementExpression ::= PostfixExpression PLUS_PLUS"); - consumeUnaryExpression(OperatorExpression.PLUS,true); - break ; - - case 326 : // System.out.println("PostDecrementExpression ::= PostfixExpression MINUS_MINUS"); - consumeUnaryExpression(OperatorExpression.MINUS,true); - break ; - - case 327 : // System.out.println("PushPosition ::="); - consumePushPosition(); - break ; - - case 330 : // System.out.println("UnaryExpression ::= PLUS PushPosition UnaryExpression"); - consumeUnaryExpression(OperatorExpression.PLUS); - break ; - - case 331 : // System.out.println("UnaryExpression ::= MINUS PushPosition UnaryExpression"); - consumeUnaryExpression(OperatorExpression.MINUS); - break ; - - case 333 : // System.out.println("PreIncrementExpression ::= PLUS_PLUS PushPosition UnaryExpression"); - consumeUnaryExpression(OperatorExpression.PLUS,false); - break ; - - case 334 : // System.out.println("PreDecrementExpression ::= MINUS_MINUS PushPosition UnaryExpression"); - consumeUnaryExpression(OperatorExpression.MINUS,false); - break ; - - case 336 : // System.out.println("UnaryExpressionNotPlusMinus ::= TWIDDLE PushPosition UnaryExpression"); - consumeUnaryExpression(OperatorExpression.TWIDDLE); - break ; - - case 337 : // System.out.println("UnaryExpressionNotPlusMinus ::= NOT PushPosition UnaryExpression"); - consumeUnaryExpression(OperatorExpression.NOT); - break ; - - case 339 : // System.out.println("CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN UnaryExpression"); - consumeCastExpression(); - break ; - - case 340 : // System.out.println("CastExpression ::= PushLPAREN Name Dims PushRPAREN UnaryExpressionNotPlusMinus"); - consumeCastExpression(); - break ; - - case 341 : // System.out.println("CastExpression ::= PushLPAREN Expression PushRPAREN UnaryExpressionNotPlusMinus"); - consumeCastExpressionLL1(); - break ; - - case 343 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression MULTIPLY UnaryExpression"); - consumeBinaryExpression(OperatorExpression.MULTIPLY); - break ; - - case 344 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression DIVIDE UnaryExpression"); - consumeBinaryExpression(OperatorExpression.DIVIDE); - break ; - - case 345 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression REMAINDER UnaryExpression"); - consumeBinaryExpression(OperatorExpression.REMAINDER); - break ; - - case 347 : // System.out.println("AdditiveExpression ::= AdditiveExpression PLUS MultiplicativeExpression"); - consumeBinaryExpression(OperatorExpression.PLUS); - break ; - - case 348 : // System.out.println("AdditiveExpression ::= AdditiveExpression MINUS MultiplicativeExpression"); - consumeBinaryExpression(OperatorExpression.MINUS); - break ; - - case 350 : // System.out.println("ShiftExpression ::= ShiftExpression LEFT_SHIFT AdditiveExpression"); - consumeBinaryExpression(OperatorExpression.LEFT_SHIFT); - break ; - - case 351 : // System.out.println("ShiftExpression ::= ShiftExpression RIGHT_SHIFT AdditiveExpression"); - consumeBinaryExpression(OperatorExpression.RIGHT_SHIFT); - break ; - - case 352 : // System.out.println("ShiftExpression ::= ShiftExpression UNSIGNED_RIGHT_SHIFT AdditiveExpression"); - consumeBinaryExpression(OperatorExpression.UNSIGNED_RIGHT_SHIFT); - break ; - - case 354 : // System.out.println("RelationalExpression ::= RelationalExpression LESS ShiftExpression"); - consumeBinaryExpression(OperatorExpression.LESS); - break ; - - case 355 : // System.out.println("RelationalExpression ::= RelationalExpression GREATER ShiftExpression"); - consumeBinaryExpression(OperatorExpression.GREATER); - break ; - - case 356 : // System.out.println("RelationalExpression ::= RelationalExpression LESS_EQUAL ShiftExpression"); - consumeBinaryExpression(OperatorExpression.LESS_EQUAL); - break ; - - case 357 : // System.out.println("RelationalExpression ::= RelationalExpression GREATER_EQUAL ShiftExpression"); - consumeBinaryExpression(OperatorExpression.GREATER_EQUAL); - break ; - - case 358 : // System.out.println("RelationalExpression ::= RelationalExpression instanceof ReferenceType"); - consumeInstanceOfExpression(OperatorExpression.INSTANCEOF); - break ; - - case 360 : // System.out.println("EqualityExpression ::= EqualityExpression EQUAL_EQUAL RelationalExpression"); - consumeEqualityExpression(OperatorExpression.EQUAL_EQUAL); - break ; - - case 361 : // System.out.println("EqualityExpression ::= EqualityExpression NOT_EQUAL RelationalExpression"); - consumeEqualityExpression(OperatorExpression.NOT_EQUAL); - break ; - - case 363 : // System.out.println("AndExpression ::= AndExpression AND EqualityExpression"); - consumeBinaryExpression(OperatorExpression.AND); - break ; - - case 365 : // System.out.println("ExclusiveOrExpression ::= ExclusiveOrExpression XOR AndExpression"); - consumeBinaryExpression(OperatorExpression.XOR); - break ; - - case 367 : // System.out.println("InclusiveOrExpression ::= InclusiveOrExpression OR ExclusiveOrExpression"); - consumeBinaryExpression(OperatorExpression.OR); - break ; - - case 369 : // System.out.println("ConditionalAndExpression ::= ConditionalAndExpression AND_AND InclusiveOrExpression"); - consumeBinaryExpression(OperatorExpression.AND_AND); - break ; - - case 371 : // System.out.println("ConditionalOrExpression ::= ConditionalOrExpression OR_OR ConditionalAndExpression"); - consumeBinaryExpression(OperatorExpression.OR_OR); - break ; - - case 373 : // System.out.println("ConditionalExpression ::= ConditionalOrExpression QUESTION Expression COLON..."); - consumeConditionalExpression(OperatorExpression.QUESTIONCOLON) ; - break ; - - case 376 : // System.out.println("Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression"); - consumeAssignment(); - break ; - - case 378 : // System.out.println("Assignment ::= InvalidArrayInitializerAssignement"); - ignoreExpressionAssignment(); - break ; - - case 379 : // System.out.println("LeftHandSide ::= Name"); - consumeLeftHandSide(); - break ; - - case 382 : // System.out.println("AssignmentOperator ::= EQUAL"); - consumeAssignmentOperator(EQUAL); - break ; - - case 383 : // System.out.println("AssignmentOperator ::= MULTIPLY_EQUAL"); - consumeAssignmentOperator(MULTIPLY); - break ; - - case 384 : // System.out.println("AssignmentOperator ::= DIVIDE_EQUAL"); - consumeAssignmentOperator(DIVIDE); - break ; - - case 385 : // System.out.println("AssignmentOperator ::= REMAINDER_EQUAL"); - consumeAssignmentOperator(REMAINDER); - break ; - - case 386 : // System.out.println("AssignmentOperator ::= PLUS_EQUAL"); - consumeAssignmentOperator(PLUS); - break ; - - case 387 : // System.out.println("AssignmentOperator ::= MINUS_EQUAL"); - consumeAssignmentOperator(MINUS); - break ; - - case 388 : // System.out.println("AssignmentOperator ::= LEFT_SHIFT_EQUAL"); - consumeAssignmentOperator(LEFT_SHIFT); - break ; - - case 389 : // System.out.println("AssignmentOperator ::= RIGHT_SHIFT_EQUAL"); - consumeAssignmentOperator(RIGHT_SHIFT); - break ; - - case 390 : // System.out.println("AssignmentOperator ::= UNSIGNED_RIGHT_SHIFT_EQUAL"); - consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT); - break ; - - case 391 : // System.out.println("AssignmentOperator ::= AND_EQUAL"); - consumeAssignmentOperator(AND); - break ; - - case 392 : // System.out.println("AssignmentOperator ::= XOR_EQUAL"); - consumeAssignmentOperator(XOR); - break ; - - case 393 : // System.out.println("AssignmentOperator ::= OR_EQUAL"); - consumeAssignmentOperator(OR); - break ; - - case 400 : // System.out.println("Expressionopt ::="); - consumeEmptyExpression(); - break ; - - case 404 : // System.out.println("ImportDeclarationsopt ::="); - consumeEmptyImportDeclarationsopt(); - break ; - - case 405 : // System.out.println("ImportDeclarationsopt ::= ImportDeclarations"); - consumeImportDeclarationsopt(); - break ; - - case 406 : // System.out.println("TypeDeclarationsopt ::="); - consumeEmptyTypeDeclarationsopt(); - break ; - - case 407 : // System.out.println("TypeDeclarationsopt ::= TypeDeclarations"); - consumeTypeDeclarationsopt(); - break ; - - case 408 : // System.out.println("ClassBodyDeclarationsopt ::="); - consumeEmptyClassBodyDeclarationsopt(); - break ; - - case 409 : // System.out.println("ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations"); - consumeClassBodyDeclarationsopt(); - break ; - - case 410 : // System.out.println("Modifiersopt ::="); - consumeDefaultModifiers(); - break ; - - case 411 : // System.out.println("Modifiersopt ::= Modifiers"); - consumeModifiers(); - break ; - - case 412 : // System.out.println("BlockStatementsopt ::="); - consumeEmptyBlockStatementsopt(); - break ; - - case 414 : // System.out.println("Dimsopt ::="); - consumeEmptyDimsopt(); - break ; - - case 416 : // System.out.println("ArgumentListopt ::="); - consumeEmptyArgumentListopt(); - break ; - - case 420 : // System.out.println("FormalParameterListopt ::="); - consumeFormalParameterListopt(); - break ; - - case 424 : // System.out.println("InterfaceMemberDeclarationsopt ::="); - consumeEmptyInterfaceMemberDeclarationsopt(); - break ; - - case 425 : // System.out.println("InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations"); - consumeInterfaceMemberDeclarationsopt(); - break ; - - case 426 : // System.out.println("NestedType ::="); - consumeNestedType(); - break ; - - case 427 : // System.out.println("ForInitopt ::="); - consumeEmptyForInitopt(); - break ; - - case 429 : // System.out.println("ForUpdateopt ::="); - consumeEmptyForUpdateopt(); - break ; - - case 433 : // System.out.println("Catchesopt ::="); - consumeEmptyCatchesopt(); - break ; - - case 435 : // System.out.println("ArrayInitializeropt ::="); - consumeEmptyArrayInitializeropt(); - break ; - - } - } - - -protected void consumeSimpleAssertStatement() { - // AssertStatement ::= 'assert' Expression ';' - expressionLengthPtr--; - pushOnAstStack(new AssertStatement(expressionStack[expressionPtr--], intStack[intPtr--])); -} - -protected void consumeSingleTypeImportDeclaration() { - // SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';' - - ImportReference impt = (ImportReference) astStack[astPtr]; - // flush annotations defined prior to import statements - impt.declarationEnd = endStatementPosition; - impt.declarationSourceEnd = - this.flushAnnotationsDefinedPriorTo(impt.declarationSourceEnd); - - // recovery - if (currentElement != null) { - lastCheckPoint = impt.declarationSourceEnd + 1; - currentElement = currentElement.add(impt, 0); - lastIgnoredToken = -1; - restartRecovery = true; - // used to avoid branching back into the regular automaton - } -} -protected void consumeSingleTypeImportDeclarationName() { - // SingleTypeImportDeclarationName ::= 'import' Name - /* push an ImportRef build from the last name - stored in the identifier stack. */ - - ImportReference impt; - int length; - char[][] tokens = new char[length = identifierLengthStack[identifierLengthPtr--]][]; - identifierPtr -= length; - long[] positions = new long[length]; - System.arraycopy(identifierStack, identifierPtr + 1, tokens, 0, length); - System.arraycopy(identifierPositionStack, identifierPtr + 1, positions, 0, length); - pushOnAstStack(impt = new ImportReference(tokens, positions, false)); - - if (currentToken == TokenNameSEMICOLON){ - impt.declarationSourceEnd = scanner.currentPosition - 1; - } else { - impt.declarationSourceEnd = impt.sourceEnd; - } - impt.declarationEnd = impt.declarationSourceEnd; - //endPosition is just before the ; - impt.declarationSourceStart = intStack[intPtr--]; - - // recovery - if (currentElement != null){ - lastCheckPoint = impt.declarationSourceEnd+1; - currentElement = currentElement.add(impt, 0); - lastIgnoredToken = -1; - restartRecovery = true; // used to avoid branching back into the regular automaton - } -} -protected void consumeStatementBreak() { - // BreakStatement ::= 'break' ';' - // break pushs a position on intStack in case there is no label + case 150 : // System.out.println("ClassTypeElt ::= ClassType"); + consumeClassTypeElt(); + break; - pushOnAstStack(new Break(null, intStack[intPtr--], endPosition)); -} -protected void consumeStatementBreakWithLabel() { - // BreakStatement ::= 'break' Identifier ';' - // break pushs a position on intStack in case there is no label - - pushOnAstStack( - new Break( - identifierStack[identifierPtr--], - intStack[intPtr--], - endPosition)); - identifierLengthPtr--; -} -protected void consumeStatementCatch() { - // CatchClause ::= 'catch' '(' FormalParameter ')' Block + case 151 : // System.out.println("MethodBody ::= NestedMethod LBRACE BlockStatementsopt RBRACE"); + consumeMethodBody(); + break; - //catch are stored directly into the Try - //has they always comes two by two.... - //we remove one entry from the astlengthPtr. - //The construction of the try statement must - //then fetch the catches using 2*i and 2*i + 1 + case 152 : // System.out.println("NestedMethod ::="); + consumeNestedMethod(); + break; - astLengthPtr--; - listLength = 0; // reset formalParameter counter (incremented for catch variable) -} -protected void consumeStatementContinue() { - // ContinueStatement ::= 'continue' ';' - // continue pushs a position on intStack in case there is no label - - pushOnAstStack( - new Continue( - null, - intStack[intPtr--], - endPosition)); -} -protected void consumeStatementContinueWithLabel() { - // ContinueStatement ::= 'continue' Identifier ';' - // continue pushs a position on intStack in case there is no label - - pushOnAstStack( - new Continue( - identifierStack[identifierPtr--], - intStack[intPtr--], - endPosition)); - identifierLengthPtr--; -} -protected void consumeStatementDo() { - // DoStatement ::= 'do' Statement 'while' '(' Expression ')' ';' - - //the 'while' pushes a value on intStack that we need to remove - intPtr--; - - //optimize the push/pop - Statement action = (Statement) astStack[astPtr]; - if (action instanceof EmptyStatement - && problemReporter.options.complianceLevel <= CompilerOptions.JDK1_3) { - expressionLengthPtr--; - astStack[astPtr] = - new DoStatement( - expressionStack[expressionPtr--], - null, - intStack[intPtr--], - endPosition); - } else { - expressionLengthPtr--; - astStack[astPtr] = - new DoStatement( - expressionStack[expressionPtr--], - action, - intStack[intPtr--], - endPosition); - } -} -protected void consumeStatementExpressionList() { - // StatementExpressionList ::= StatementExpressionList ',' StatementExpression - concatExpressionLists(); -} -protected void consumeStatementFor() { - // ForStatement ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' Statement - // ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' StatementNoShortIf - - int length; - Expression cond = null; - Statement[] inits, updates; - Statement action; - boolean scope = true; - - //statements - astLengthPtr--; // we need to consume it - action = (Statement) astStack[astPtr--]; - if (action instanceof EmptyStatement - && problemReporter.options.complianceLevel <= CompilerOptions.JDK1_3) { - action = null; - } - - //updates are on the expresion stack - if ((length = expressionLengthStack[expressionLengthPtr--]) == 0) { - updates = null; - } else { - expressionPtr -= length; - System.arraycopy( - expressionStack, - expressionPtr + 1, - updates = new Statement[length], - 0, - length); - } - - if (expressionLengthStack[expressionLengthPtr--] != 0) - cond = expressionStack[expressionPtr--]; - - //inits may be on two different stacks - if ((length = astLengthStack[astLengthPtr--]) == 0) { - inits = null; - scope = false; - } else { - if (length == -1) { //on expressionStack - scope = false; - length = expressionLengthStack[expressionLengthPtr--]; - expressionPtr -= length; - System.arraycopy( - expressionStack, - expressionPtr + 1, - inits = new Statement[length], - 0, - length); - } else { //on astStack - astPtr -= length; - System.arraycopy( - astStack, - astPtr + 1, - inits = new Statement[length], - 0, - length); - } - }; - if (action instanceof Block) { - pushOnAstStack( - new ForStatement( - inits, - cond, - updates, - action, - scope, - intStack[intPtr--], - endStatementPosition)); - } else { - pushOnAstStack( - new ForStatement( - inits, - cond, - updates, - action, - scope, - intStack[intPtr--], - endPosition)); - } -} -protected void consumeStatementIfNoElse() { - // IfThenStatement ::= 'if' '(' Expression ')' Statement - - //optimize the push/pop - expressionLengthPtr--; - Statement thenStatement = (Statement) astStack[astPtr]; - if (thenStatement instanceof Block) { - astStack[astPtr] = - new IfStatement( - expressionStack[expressionPtr--], - thenStatement, - intStack[intPtr--], - endStatementPosition); - } else if (thenStatement instanceof EmptyStatement) { - astStack[astPtr] = - new IfStatement( - expressionStack[expressionPtr--], - Block.None, - intStack[intPtr--], - endStatementPosition); - } else { - astStack[astPtr] = - new IfStatement( - expressionStack[expressionPtr--], - thenStatement, - intStack[intPtr--], - endStatementPosition); - } -} -protected void consumeStatementIfWithElse() { - // IfThenElseStatement ::= 'if' '(' Expression ')' StatementNoShortIf 'else' Statement - // IfThenElseStatementNoShortIf ::= 'if' '(' Expression ')' StatementNoShortIf 'else' StatementNoShortIf - - astLengthPtr--; // optimized {..., Then, Else } ==> {..., If } - expressionLengthPtr--; - //optimize the push/pop - Statement elseStatement = (Statement) astStack[astPtr--]; - Statement thenStatement = (Statement) astStack[astPtr]; - if (elseStatement instanceof EmptyStatement) { - elseStatement = Block.None; - } - if (thenStatement instanceof EmptyStatement) { - thenStatement = Block.None; - } - if (elseStatement instanceof Block) { - astStack[astPtr] = - new IfStatement( - expressionStack[expressionPtr--], - thenStatement, - elseStatement, - intStack[intPtr--], - endStatementPosition); - } else { - astStack[astPtr] = - new IfStatement( - expressionStack[expressionPtr--], - thenStatement, - elseStatement, - intStack[intPtr--], - endStatementPosition); - } -} -protected void consumeStatementLabel() { - // LabeledStatement ::= 'Identifier' ':' Statement - // LabeledStatementNoShortIf ::= 'Identifier' ':' StatementNoShortIf - - //optimize push/pop - - Statement stmt = (Statement) astStack[astPtr]; - if (stmt instanceof EmptyStatement) { - astStack[astPtr] = - new LabeledStatement( - identifierStack[identifierPtr], - Block.None, - (int) (identifierPositionStack[identifierPtr--] >>> 32), - endStatementPosition); - } else { - astStack[astPtr] = - new LabeledStatement( - identifierStack[identifierPtr], - stmt, - (int) (identifierPositionStack[identifierPtr--] >>> 32), - endStatementPosition); - } - identifierLengthPtr--; -} -protected void consumeStatementReturn() { - // ReturnStatement ::= 'return' Expressionopt ';' - // return pushs a position on intStack in case there is no expression - - if (expressionLengthStack[expressionLengthPtr--] != 0) { - pushOnAstStack( - new ReturnStatement( - expressionStack[expressionPtr--], - intStack[intPtr--], - endPosition) - ); - } else { - pushOnAstStack(new ReturnStatement(null, intStack[intPtr--], endPosition)); - } -} -protected void consumeStatementSwitch() { - // SwitchStatement ::= 'switch' OpenBlock '(' Expression ')' SwitchBlock - - //OpenBlock just makes the semantic action blockStart() - //the block is inlined but a scope need to be created - //if some declaration occurs. - - int length; - SwitchStatement s = new SwitchStatement(); - expressionLengthPtr--; - s.testExpression = expressionStack[expressionPtr--]; - if ((length = astLengthStack[astLengthPtr--]) != 0) { - astPtr -= length; - System.arraycopy( - astStack, - astPtr + 1, - s.statements = new Statement[length], - 0, - length); - } - s.explicitDeclarations = realBlockStack[realBlockPtr--]; - pushOnAstStack(s); - intPtr--; // because of OpenBlock - s.sourceStart = intStack[intPtr--]; - s.sourceEnd = endStatementPosition; -} -protected void consumeStatementSynchronized() { - // SynchronizedStatement ::= OnlySynchronized '(' Expression ')' Block - //optimize the push/pop - - if (astLengthStack[astLengthPtr] == 0) { - astLengthStack[astLengthPtr] = 1; - expressionLengthPtr--; - astStack[++astPtr] = - new SynchronizedStatement( - expressionStack[expressionPtr--], - Block.None, - intStack[intPtr--], - endStatementPosition); - } else { - expressionLengthPtr--; - astStack[astPtr] = - new SynchronizedStatement( - expressionStack[expressionPtr--], - (Block) astStack[astPtr], - intStack[intPtr--], - endStatementPosition); - } - resetModifiers(); -} -protected void consumeStatementThrow() { - // ThrowStatement ::= 'throw' Expression ';' - expressionLengthPtr--; - pushOnAstStack(new ThrowStatement(expressionStack[expressionPtr--], intStack[intPtr--])); -} -protected void consumeStatementTry(boolean withFinally) { - //TryStatement ::= 'try' Block Catches - //TryStatement ::= 'try' Block Catchesopt Finally - - int length; - TryStatement tryStmt = new TryStatement(); - //finally - if (withFinally) { - astLengthPtr--; - tryStmt.finallyBlock = (Block) astStack[astPtr--]; - } - //catches are handle by two [see statementCatch] - if ((length = astLengthStack[astLengthPtr--]) != 0) { - if (length == 1) { - tryStmt.catchBlocks = new Block[] {(Block) astStack[astPtr--]}; - tryStmt.catchArguments = new Argument[] {(Argument) astStack[astPtr--]}; - } else { - Block[] bks = (tryStmt.catchBlocks = new Block[length]); - Argument[] args = (tryStmt.catchArguments = new Argument[length]); - while (length-- > 0) { - bks[length] = (Block) astStack[astPtr--]; - args[length] = (Argument) astStack[astPtr--]; - } - } - } - //try - astLengthPtr--; - tryStmt.tryBlock = (Block) astStack[astPtr--]; - - //positions - tryStmt.sourceEnd = endStatementPosition; - tryStmt.sourceStart = intStack[intPtr--]; - pushOnAstStack(tryStmt); -} -protected void consumeStatementWhile() { - // WhileStatement ::= 'while' '(' Expression ')' Statement - // WhileStatementNoShortIf ::= 'while' '(' Expression ')' StatementNoShortIf - - Statement action = (Statement) astStack[astPtr]; - expressionLengthPtr--; - if (action instanceof Block) { - astStack[astPtr] = - new WhileStatement( - expressionStack[expressionPtr--], - action, - intStack[intPtr--], - endStatementPosition); - } else { - if (action instanceof EmptyStatement - && problemReporter.options.complianceLevel <= CompilerOptions.JDK1_3) { - astStack[astPtr] = - new WhileStatement( - expressionStack[expressionPtr--], - null, - intStack[intPtr--], - endPosition); - } else { - astStack[astPtr] = - new WhileStatement( - expressionStack[expressionPtr--], - action, - intStack[intPtr--], - endPosition); - } - } -} -protected void consumeStaticInitializer() { - // StaticInitializer ::= StaticOnly Block - //push an Initializer - //optimize the push/pop - Initializer initializer = new Initializer((Block) astStack[astPtr], AccStatic); - astStack[astPtr] = initializer; - initializer.sourceEnd = endStatementPosition; - initializer.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); - nestedMethod[nestedType] --; - initializer.declarationSourceStart = intStack[intPtr--]; - - // recovery - if (currentElement != null){ - lastCheckPoint = initializer.declarationSourceEnd; - currentElement = currentElement.add(initializer, 0); - lastIgnoredToken = -1; - } -} -protected void consumeStaticOnly() { - // StaticOnly ::= 'static' - int savedModifiersSourceStart = modifiersSourceStart; - checkAnnotation(); // might update declaration source start - if (modifiersSourceStart >= savedModifiersSourceStart) { - modifiersSourceStart = savedModifiersSourceStart; - } - pushOnIntStack( - modifiersSourceStart >= 0 ? modifiersSourceStart : scanner.startPosition); - jumpOverMethodBody(); - nestedMethod[nestedType]++; - resetModifiers(); - - // recovery - if (currentElement != null){ - recoveredStaticInitializerStart = intStack[intPtr]; // remember start position only for static initializers - } -} -protected void consumeSwitchBlock() { - // SwitchBlock ::= '{' SwitchBlockStatements SwitchLabels '}' - concatNodeLists(); -} -protected void consumeSwitchBlockStatement() { - // SwitchBlockStatement ::= SwitchLabels BlockStatements - concatNodeLists(); -} -protected void consumeSwitchBlockStatements() { - // SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement - concatNodeLists(); -} -protected void consumeSwitchLabels() { - // SwitchLabels ::= SwitchLabels SwitchLabel - optimizedConcatNodeLists(); -} -protected void consumeToken(int type) { - /* remember the last consumed value */ - /* try to minimize the number of build values */ - if (scanner.wasNonExternalizedStringLiteral) { - StringLiteral[] literals = this.scanner.nonNLSStrings; - // could not reproduce, but this is the only NPE - // added preventive null check see PR 9035 - if (literals != null) { - for (int i = 0, max = literals.length; i < max; i++) { - problemReporter().nonExternalizedStringLiteral(literals[i]); - } - } - scanner.currentLine = null; - scanner.wasNonExternalizedStringLiteral = false; - } - // clear the commentPtr of the scanner in case we read something different from a modifier - switch(type) { -// case TokenNameabstract : -// case TokenNamestrictfp : -// case TokenNamefinal : -// case TokenNamenative : -// case TokenNameprivate : -// case TokenNameprotected : -// case TokenNamepublic : -// case TokenNametransient : -// case TokenNamevolatile : - case TokenNamestatic : -// case TokenNamesynchronized : - break; - default: - scanner.commentPtr = -1; - } - //System.out.println(scanner.toStringAction(type)); - switch (type) { - case TokenNameIdentifier : - pushIdentifier(); - if (scanner.useAssertAsAnIndentifier) { - long positions = identifierPositionStack[identifierPtr]; - problemReporter().useAssertAsAnIdentifier((int) (positions >>> 32), (int) positions); - } - scanner.commentPtr = -1; - break; -// case TokenNameinterface : -// adjustInterfaceModifiers(); -// //'class' is pushing two int (positions) on the stack ==> 'interface' needs to do it too.... -// pushOnIntStack(scanner.startPosition); -// pushOnIntStack(scanner.currentPosition - 1); -// scanner.commentPtr = -1; -// break; -// case TokenNameabstract : -// checkAndSetModifiers(AccAbstract); -// break; -// case TokenNamestrictfp : -// checkAndSetModifiers(AccStrictfp); -// break; -// case TokenNamefinal : -// checkAndSetModifiers(AccFinal); -// break; -// case TokenNamenative : -// checkAndSetModifiers(AccNative); -// break; -// case TokenNameprivate : -// checkAndSetModifiers(AccPrivate); -// break; -// case TokenNameprotected : -// checkAndSetModifiers(AccProtected); -// break; -// case TokenNamepublic : -// checkAndSetModifiers(AccPublic); -// break; -// case TokenNametransient : -// checkAndSetModifiers(AccTransient); -// break; -// case TokenNamevolatile : -// checkAndSetModifiers(AccVolatile); -// break; - case TokenNamestatic : - checkAndSetModifiers(AccStatic); - break; -// case TokenNamesynchronized : -// this.synchronizedBlockSourceStart = scanner.startPosition; -// checkAndSetModifiers(AccSynchronized); -// break; -// //============================== -// case TokenNamevoid : -// pushIdentifier(-T_void); -// pushOnIntStack(scanner.currentPosition - 1); -// pushOnIntStack(scanner.startPosition); -// scanner.commentPtr = -1; -// break; -// //push a default dimension while void is not part of the primitive -// //declaration baseType and so takes the place of a type without getting into -// //regular type parsing that generates a dimension on intStack -// case TokenNameboolean : -// pushIdentifier(-T_boolean); -// pushOnIntStack(scanner.currentPosition - 1); -// pushOnIntStack(scanner.startPosition); -// scanner.commentPtr = -1; -// break; -// case TokenNamebyte : -// pushIdentifier(-T_byte); -// pushOnIntStack(scanner.currentPosition - 1); -// pushOnIntStack(scanner.startPosition); -// scanner.commentPtr = -1; -// break; -// case TokenNamechar : -// pushIdentifier(-T_char); -// pushOnIntStack(scanner.currentPosition - 1); -// pushOnIntStack(scanner.startPosition); -// scanner.commentPtr = -1; -// break; -// case TokenNamedouble : -// pushIdentifier(-T_double); -// pushOnIntStack(scanner.currentPosition - 1); -// pushOnIntStack(scanner.startPosition); -// scanner.commentPtr = -1; -// break; -// case TokenNamefloat : -// pushIdentifier(-T_float); -// pushOnIntStack(scanner.currentPosition - 1); -// pushOnIntStack(scanner.startPosition); -// scanner.commentPtr = -1; -// break; -// case TokenNameint : -// pushIdentifier(-T_int); -// pushOnIntStack(scanner.currentPosition - 1); -// pushOnIntStack(scanner.startPosition); -// scanner.commentPtr = -1; -// break; -// case TokenNamelong : -// pushIdentifier(-T_long); -// pushOnIntStack(scanner.currentPosition - 1); -// pushOnIntStack(scanner.startPosition); -// scanner.commentPtr = -1; -// break; -// case TokenNameshort : -// pushIdentifier(-T_short); -// pushOnIntStack(scanner.currentPosition - 1); -// pushOnIntStack(scanner.startPosition); -// scanner.commentPtr = -1; -// break; - //============================== - case TokenNameIntegerLiteral : - pushOnExpressionStack( - new IntLiteral( - scanner.getCurrentTokenSource(), - scanner.startPosition, - scanner.currentPosition - 1)); - scanner.commentPtr = -1; - break; - case TokenNameLongLiteral : - pushOnExpressionStack( - new LongLiteral( - scanner.getCurrentTokenSource(), - scanner.startPosition, - scanner.currentPosition - 1)); - scanner.commentPtr = -1; - break; - case TokenNameFloatingPointLiteral : - pushOnExpressionStack( - new FloatLiteral( - scanner.getCurrentTokenSource(), - scanner.startPosition, - scanner.currentPosition - 1)); - scanner.commentPtr = -1; - break; - case TokenNameDoubleLiteral : - pushOnExpressionStack( - new DoubleLiteral( - scanner.getCurrentTokenSource(), - scanner.startPosition, - scanner.currentPosition - 1)); - scanner.commentPtr = -1; - break; - case TokenNameCharacterLiteral : - pushOnExpressionStack( - new CharLiteral( - scanner.getCurrentTokenSource(), - scanner.startPosition, - scanner.currentPosition - 1)); - scanner.commentPtr = -1; - break; - case TokenNameStringLiteral : - StringLiteral stringLiteral = new StringLiteral( - scanner.getCurrentTokenSourceString(), - scanner.startPosition, - scanner.currentPosition - 1); - pushOnExpressionStack(stringLiteral); - scanner.commentPtr = -1; - break; - case TokenNamefalse : - pushOnExpressionStack( - new FalseLiteral(scanner.startPosition, scanner.currentPosition - 1)); - scanner.commentPtr = -1; - break; - case TokenNametrue : - pushOnExpressionStack( - new TrueLiteral(scanner.startPosition, scanner.currentPosition - 1)); - break; - case TokenNamenull : - pushOnExpressionStack( - new NullLiteral(scanner.startPosition, scanner.currentPosition - 1)); - break; - //============================ -// case TokenNamesuper : -// case TokenNamethis : -// endPosition = scanner.currentPosition - 1; -// pushOnIntStack(scanner.startPosition); -// break; -// case TokenNameassert : -// case TokenNameimport : -// case TokenNamepackage : -// case TokenNamethrow : - case TokenNamenew : - case TokenNamedo : - case TokenNameif : - case TokenNamefor : - case TokenNameswitch : -// case TokenNametry : - case TokenNamewhile : - case TokenNamebreak : - case TokenNamecontinue : - case TokenNamereturn : - case TokenNamecase : - pushOnIntStack(scanner.startPosition); - break; - case TokenNameclass : - pushOnIntStack(scanner.currentPosition - 1); - pushOnIntStack(scanner.startPosition); - break; - case TokenNamedefault : - pushOnIntStack(scanner.startPosition); - pushOnIntStack(scanner.currentPosition - 1); - break; - //let extra semantic action decide when to push - case TokenNameRBRACKET : - case TokenNamePLUS : - case TokenNameMINUS : - case TokenNameNOT : - case TokenNameTWIDDLE : - endPosition = scanner.startPosition; - break; - case TokenNamePLUS_PLUS : - case TokenNameMINUS_MINUS : - endPosition = scanner.startPosition; - endStatementPosition = scanner.currentPosition - 1; - break; - case TokenNameRBRACE: - case TokenNameSEMICOLON : - endStatementPosition = scanner.currentPosition - 1; - endPosition = scanner.startPosition - 1; - //the item is not part of the potential futur expression/statement - break; - // in order to handle ( expression) ////// (cast)expression///// foo(x) - case TokenNameRPAREN : - rParenPos = scanner.currentPosition - 1; // position of the end of right parenthesis (in case of unicode \u0029) lex00101 - break; - case TokenNameLPAREN : - lParenPos = scanner.startPosition; - break; - // case TokenNameQUESTION : - // case TokenNameCOMMA : - // case TokenNameCOLON : - // case TokenNameEQUAL : - // case TokenNameLBRACKET : - // case TokenNameDOT : - // case TokenNameERROR : - // case TokenNameEOF : - // case TokenNamecase : - // case TokenNamecatch : - // case TokenNameelse : - // case TokenNameextends : - // case TokenNamefinally : - // case TokenNameimplements : - // case TokenNamethrows : - // case TokenNameinstanceof : - // case TokenNameEQUAL_EQUAL : - // case TokenNameLESS_EQUAL : - // case TokenNameGREATER_EQUAL : - // case TokenNameNOT_EQUAL : - // case TokenNameLEFT_SHIFT : - // case TokenNameRIGHT_SHIFT : - // case TokenNameUNSIGNED_RIGHT_SHIFT : - // case TokenNamePLUS_EQUAL : - // case TokenNameMINUS_EQUAL : - // case TokenNameMULTIPLY_EQUAL : - // case TokenNameDIVIDE_EQUAL : - // case TokenNameAND_EQUAL : - // case TokenNameOR_EQUAL : - // case TokenNameXOR_EQUAL : - // case TokenNameREMAINDER_EQUAL : - // case TokenNameLEFT_SHIFT_EQUAL : - // case TokenNameRIGHT_SHIFT_EQUAL : - // case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL : - // case TokenNameOR_OR : - // case TokenNameAND_AND : - // case TokenNameREMAINDER : - // case TokenNameXOR : - // case TokenNameAND : - // case TokenNameMULTIPLY : - // case TokenNameOR : - // case TokenNameDIVIDE : - // case TokenNameGREATER : - // case TokenNameLESS : - } -} -protected void consumeTypeDeclarations() { - // TypeDeclarations ::= TypeDeclarations TypeDeclaration - concatNodeLists(); -} -protected void consumeTypeDeclarationsopt() { - // TypeDeclarationsopt ::= TypeDeclarations - int length; - if ((length = astLengthStack[astLengthPtr--]) != 0) { - astPtr -= length; - System.arraycopy(astStack, astPtr + 1, compilationUnit.types = new TypeDeclaration[length], 0, length); - } -} -protected void consumeTypeImportOnDemandDeclaration() { - // TypeImportOnDemandDeclaration ::= TypeImportOnDemandDeclarationName ';' - - ImportReference impt = (ImportReference) astStack[astPtr]; - // flush annotations defined prior to import statements - impt.declarationEnd = endStatementPosition; - impt.declarationSourceEnd = - this.flushAnnotationsDefinedPriorTo(impt.declarationSourceEnd); - - // recovery - if (currentElement != null) { - lastCheckPoint = impt.declarationSourceEnd + 1; - currentElement = currentElement.add(impt, 0); - restartRecovery = true; - lastIgnoredToken = -1; - // used to avoid branching back into the regular automaton - } -} -protected void consumeTypeImportOnDemandDeclarationName() { - // TypeImportOnDemandDeclarationName ::= 'import' Name '.' '*' - /* push an ImportRef build from the last name - stored in the identifier stack. */ - - ImportReference impt; - int length; - char[][] tokens = new char[length = identifierLengthStack[identifierLengthPtr--]][]; - identifierPtr -= length; - long[] positions = new long[length]; - System.arraycopy(identifierStack, identifierPtr + 1, tokens, 0, length); - System.arraycopy(identifierPositionStack, identifierPtr + 1, positions, 0, length); - pushOnAstStack(impt = new ImportReference(tokens, positions, true)); - - if (currentToken == TokenNameSEMICOLON){ - impt.declarationSourceEnd = scanner.currentPosition - 1; - } else { - impt.declarationSourceEnd = impt.sourceEnd; - } - impt.declarationEnd = impt.declarationSourceEnd; - //endPosition is just before the ; - impt.declarationSourceStart = intStack[intPtr--]; - - // recovery - if (currentElement != null){ - lastCheckPoint = impt.declarationSourceEnd+1; - currentElement = currentElement.add(impt, 0); - lastIgnoredToken = -1; - restartRecovery = true; // used to avoid branching back into the regular automaton - } -} -protected void consumeUnaryExpression(int op) { - // UnaryExpression ::= '+' PushPosition UnaryExpression - // UnaryExpression ::= '-' PushPosition UnaryExpression - // UnaryExpressionNotPlusMinus ::= '~' PushPosition UnaryExpression - // UnaryExpressionNotPlusMinus ::= '!' PushPosition UnaryExpression - - //optimize the push/pop - - //handle manually the -2147483648 while it is not a real - //computation of an - and 2147483648 (notice that 2147483648 - //is Integer.MAX_VALUE+1.....) - //Same for -9223372036854775808L ............ - - //intStack have the position of the operator - - Expression r, exp = expressionStack[expressionPtr]; - if (op == MINUS) { - if ((exp instanceof IntLiteral) && (((IntLiteral) exp).mayRepresentMIN_VALUE())) { - r = expressionStack[expressionPtr] = new IntLiteralMinValue(); - } else { - if ((exp instanceof LongLiteral) && (((LongLiteral) exp).mayRepresentMIN_VALUE())) { - r = expressionStack[expressionPtr] = new LongLiteralMinValue(); - } else { - r = expressionStack[expressionPtr] = new UnaryExpression(exp, op); - } - } - } else { - r = expressionStack[expressionPtr] = new UnaryExpression(exp, op); - } - r.sourceStart = intStack[intPtr--]; - r.sourceEnd = exp.sourceEnd; -} -protected void consumeUnaryExpression(int op, boolean post) { - // PreIncrementExpression ::= '++' PushPosition UnaryExpression - // PreDecrementExpression ::= '--' PushPosition UnaryExpression - - // ++ and -- operators - //optimize the push/pop - - //intStack has the position of the operator when prefix - - Expression leftHandSide = expressionStack[expressionPtr]; - if (leftHandSide instanceof Reference) { - // ++foo()++ is unvalid - if (post) { - expressionStack[expressionPtr] = - new PostfixExpression( - leftHandSide, - IntLiteral.One, - op, - endStatementPosition); - } else { - expressionStack[expressionPtr] = - new PrefixExpression( - leftHandSide, - IntLiteral.One, - op, - intStack[intPtr--]); - } - } else { - //the ++ or the -- is NOT taken into account if code gen proceeds - if (!post) { - intPtr--; - } - problemReporter().invalidUnaryExpression(leftHandSide); - } -} -protected void consumeVariableDeclarators() { - // VariableDeclarators ::= VariableDeclarators ',' VariableDeclarator - optimizedConcatNodeLists(); -} -protected void consumeVariableInitializers() { - // VariableInitializers ::= VariableInitializers ',' VariableInitializer - concatExpressionLists(); -} -protected TypeReference copyDims(TypeReference typeRef, int dim) { - return typeRef.copyDims(dim); -} -protected FieldDeclaration createFieldDeclaration(Expression initialization, char[] name, int sourceStart, int sourceEnd) { - return new FieldDeclaration(null, name, sourceStart, sourceEnd); -} + case 153 : // System.out.println("StaticInitializer ::= StaticOnly Block"); + consumeStaticInitializer(); + break; -protected LocalDeclaration createLocalDeclaration(Expression initialization, char[] name, int sourceStart, int sourceEnd) { - return new LocalDeclaration(null, name, sourceStart, sourceEnd); -} + case 154 : // System.out.println("StaticOnly ::= static"); + consumeStaticOnly(); + break; -public CompilationUnitDeclaration dietParse(ICompilationUnit sourceUnit, CompilationResult compilationResult) { - - CompilationUnitDeclaration parsedUnit; - boolean old = diet; - try { - diet = true; - parsedUnit = parse(sourceUnit, compilationResult); - } - finally { - diet = old; - } - return parsedUnit; -} -protected void dispatchDeclarationInto(int length) { - /* they are length on astStack that should go into - methods fields constructors lists of the typeDecl - - Return if there is a constructor declaration in the methods declaration */ - - - // Looks for the size of each array . - - if (length == 0) - return; - int[] flag = new int[length + 1]; //plus one -- see - int size1 = 0, size2 = 0, size3 = 0; - for (int i = length - 1; i >= 0; i--) { - AstNode astNode = astStack[astPtr--]; - if (astNode instanceof AbstractMethodDeclaration) { - //methods and constructors have been regrouped into one single list - flag[i] = 3; - size2++; - } else { - if (astNode instanceof TypeDeclaration) { - flag[i] = 4; - size3++; - } else { - //field - flag[i] = 1; - size1++; - } - } - } - - //arrays creation - TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; - if (size1 != 0) - typeDecl.fields = new FieldDeclaration[size1]; - if (size2 != 0) - typeDecl.methods = new AbstractMethodDeclaration[size2]; - if (size3 != 0) - typeDecl.memberTypes = new MemberTypeDeclaration[size3]; - - //arrays fill up - size1 = size2 = size3 = 0; - int flagI = flag[0], start = 0; - int length2; - for (int end = 0; end <= length; end++) // the plus one allows to - { - if (flagI != flag[end]) //treat the last element as a ended flag..... - { //array copy - switch (flagI) { - case 1 : - size1 += (length2 = end - start); - System.arraycopy( - astStack, - astPtr + start + 1, - typeDecl.fields, - size1 - length2, - length2); - break; - case 3 : - size2 += (length2 = end - start); - System.arraycopy( - astStack, - astPtr + start + 1, - typeDecl.methods, - size2 - length2, - length2); - break; - case 4 : - size3 += (length2 = end - start); - System.arraycopy( - astStack, - astPtr + start + 1, - typeDecl.memberTypes, - size3 - length2, - length2); - break; - }; - flagI = flag[start = end]; - } - } - - if (typeDecl.memberTypes != null) { - for (int i = typeDecl.memberTypes.length - 1; i >= 0; i--) { - typeDecl.memberTypes[i].enclosingType = typeDecl; - } - } -} -protected CompilationUnitDeclaration endParse(int act) { - - this.lastAct = act; - - if (currentElement != null){ - currentElement.topElement().updateParseTree(); - if (VERBOSE_RECOVERY){ - System.out.print(Util.bind("parser.syntaxRecovery")); //$NON-NLS-1$ - System.out.println("--------------------------"); //$NON-NLS-1$ - System.out.println(compilationUnit); - System.out.println("----------------------------------"); //$NON-NLS-1$ - } - } else { - if (diet & VERBOSE_RECOVERY){ - System.out.print(Util.bind("parser.regularParse")); //$NON-NLS-1$ - System.out.println("--------------------------"); //$NON-NLS-1$ - System.out.println(compilationUnit); - System.out.println("----------------------------------"); //$NON-NLS-1$ - } - } - if (scanner.recordLineSeparator) { - compilationUnit.compilationResult.lineSeparatorPositions = scanner.getLineEnds(); - } - return compilationUnit; -} -/* - * Flush annotations defined prior to a given positions. - * - * Note: annotations are stacked in syntactical order - * - * Either answer given , or the end position of a comment line - * immediately following the (same line) - * - * e.g. - * void foo(){ - * } // end of method foo - */ - -public int flushAnnotationsDefinedPriorTo(int position) { - - int lastAnnotationIndex = scanner.commentPtr; - if (lastAnnotationIndex < 0) return position; // no comment - - // compute the index of the first obsolete comment - int index = lastAnnotationIndex; - int validCount = 0; - while (index >= 0){ - int commentEnd = scanner.commentStops[index]; - if (commentEnd < 0) commentEnd = -commentEnd; // negative end position for non-javadoc comments - if (commentEnd <= position){ - break; - } - index--; - validCount++; - } - // if the source at is immediately followed by a line comment, then - // flush this comment and shift to the comment end. - if (validCount > 0){ - int immediateCommentEnd = -scanner.commentStops[index+1]; //non-javadoc comment end positions are negative - if (immediateCommentEnd > 0){ // only tolerating non-javadoc comments - // is there any line break until the end of the immediate comment ? (thus only tolerating line comment) - immediateCommentEnd--; // comment end in one char too far - if (scanner.getLineNumber(position) == scanner.getLineNumber(immediateCommentEnd)){ - position = immediateCommentEnd; - validCount--; // flush this comment - index++; - } - } - } - // position can be located in the middle of a line break - // this is a bug on Windows platform only. - // http://dev.eclipse.org/bugs/show_bug.cgi?id=10557 - char[] source = scanner.source; - - if ((position < source.length) - && (source[position] == '\r') - && ((position + 1) < source.length) - && (source[position + 1] == '\n')) { - position++; - } - if (index < 0) return position; // no obsolete comment - - if (validCount > 0){ // move valid comment infos, overriding obsolete comment infos - System.arraycopy(scanner.commentStarts, index + 1, scanner.commentStarts, 0, validCount); - System.arraycopy(scanner.commentStops, index + 1, scanner.commentStops, 0, validCount); - } - scanner.commentPtr = validCount - 1; - return position; -} -public final int getFirstToken() { - // the first token is a virtual token that - // allows the parser to parse several goals - // even if they aren't LALR(1).... - // Goal ::= '++' CompilationUnit - // Goal ::= '--' MethodBody - // Goal ::= '==' ConstructorBody - // -- Initializer - // Goal ::= '>>' StaticInitializer - // Goal ::= '>>' Block - // -- error recovery - // Goal ::= '>>>' Headers - // Goal ::= '*' BlockStatements - // Goal ::= '*' MethodPushModifiersHeader - // -- JDOM - // Goal ::= '&&' FieldDeclaration - // Goal ::= '||' ImportDeclaration - // Goal ::= '?' PackageDeclaration - // Goal ::= '+' TypeDeclaration - // Goal ::= '/' GenericMethodDeclaration - // Goal ::= '&' ClassBodyDeclaration - // -- code snippet - // Goal ::= '%' Expression - // -- completion parser - // Goal ::= '!' ConstructorBlockStatementsopt - // Goal ::= '~' BlockStatementsopt - - return firstToken; -} -/* - * Answer back an array of sourceStart/sourceEnd positions of the available JavaDoc comments. - * The array is a flattened structure: 2*n entries with consecutives start and end positions. - * - * If no JavaDoc is available, then null is answered instead of an empty array. - * - * e.g. { 10, 20, 25, 45 } --> javadoc1 from 10 to 20, javadoc2 from 25 to 45 - */ -public int[] getJavaDocPositions() { - - int javadocCount = 0; - for (int i = 0, max = scanner.commentPtr; i <= max; i++){ - // javadoc only (non javadoc comment have negative end positions.) - if (scanner.commentStops[i] > 0){ - javadocCount++; - } - } - if (javadocCount == 0) return null; - - int[] positions = new int[2*javadocCount]; - int index = 0; - for (int i = 0, max = scanner.commentPtr; i <= max; i++){ - // javadoc only (non javadoc comment have negative end positions.) - if (scanner.commentStops[i] > 0){ - positions[index++] = scanner.commentStarts[i]; - positions[index++] = scanner.commentStops[i]-1; //stop is one over - } - } - return positions; -} - protected void getMethodBodies(CompilationUnitDeclaration unit) { - //fill the methods bodies in order for the code to be generated - - if (unit == null) return; - - if (unit.ignoreMethodBodies) { - unit.ignoreFurtherInvestigation = true; - return; - // if initial diet parse did not work, no need to dig into method bodies. - } - - //real parse of the method.... - this.scanner.setSource( - unit.compilationResult.compilationUnit.getContents()); - if (unit.types != null) { - for (int i = unit.types.length; --i >= 0;) - unit.types[i].parseMethod(this, unit); - } - } -protected TypeReference getTypeReference(int dim) { /* build a Reference on a variable that may be qualified or not -This variable is a type reference and dim will be its dimensions*/ - - int length; - TypeReference ref; - if ((length = identifierLengthStack[identifierLengthPtr--]) == 1) { - // single variable reference - if (dim == 0) { - ref = - new SingleTypeReference( - identifierStack[identifierPtr], - identifierPositionStack[identifierPtr--]); - } else { - ref = - new ArrayTypeReference( - identifierStack[identifierPtr], - dim, - identifierPositionStack[identifierPtr--]); - ref.sourceEnd = endPosition; - } - } else { - if (length < 0) { //flag for precompiled type reference on base types - ref = TypeReference.baseTypeReference(-length, dim); - ref.sourceStart = intStack[intPtr--]; - if (dim == 0) { - ref.sourceEnd = intStack[intPtr--]; - } else { - intPtr--; - ref.sourceEnd = endPosition; - } - } else { //Qualified variable reference - char[][] tokens = new char[length][]; - identifierPtr -= length; - long[] positions = new long[length]; - System.arraycopy(identifierStack, identifierPtr + 1, tokens, 0, length); - System.arraycopy( - identifierPositionStack, - identifierPtr + 1, - positions, - 0, - length); - if (dim == 0) { - ref = new QualifiedTypeReference(tokens, positions); - } else { - ref = new ArrayQualifiedTypeReference(tokens, dim, positions); - ref.sourceEnd = endPosition; - } - } - }; - return ref; -} -protected Expression getTypeReference(Expression exp) { - - exp.bits &= ~AstNode.RestrictiveFlagMASK; - exp.bits |= TYPE; - return exp; -} -protected NameReference getUnspecifiedReference() { - /* build a (unspecified) NameReference which may be qualified*/ - - int length; - NameReference ref; - if ((length = identifierLengthStack[identifierLengthPtr--]) == 1) - // single variable reference - ref = - new SingleNameReference( - identifierStack[identifierPtr], - identifierPositionStack[identifierPtr--]); - else - //Qualified variable reference - { - char[][] tokens = new char[length][]; - identifierPtr -= length; - System.arraycopy(identifierStack, identifierPtr + 1, tokens, 0, length); - ref = - new QualifiedNameReference(tokens, - (int) (identifierPositionStack[identifierPtr + 1] >> 32), // sourceStart - (int) identifierPositionStack[identifierPtr + length]); // sourceEnd - }; - return ref; -} -protected NameReference getUnspecifiedReferenceOptimized() { - /* build a (unspecified) NameReference which may be qualified - The optimization occurs for qualified reference while we are - certain in this case the last item of the qualified name is - a field access. This optimization is IMPORTANT while it results - that when a NameReference is build, the type checker should always - look for that it is not a type reference */ - - int length; - NameReference ref; - if ((length = identifierLengthStack[identifierLengthPtr--]) == 1) { - // single variable reference - ref = - new SingleNameReference( - identifierStack[identifierPtr], - identifierPositionStack[identifierPtr--]); - ref.bits &= ~AstNode.RestrictiveFlagMASK; - ref.bits |= LOCAL | FIELD; - return ref; - } - - //Qualified-variable-reference - //In fact it is variable-reference DOT field-ref , but it would result in a type - //conflict tha can be only reduce by making a superclass (or inetrface ) between - //nameReference and FiledReference or putting FieldReference under NameReference - //or else..........This optimisation is not really relevant so just leave as it is - - char[][] tokens = new char[length][]; - identifierPtr -= length; - System.arraycopy(identifierStack, identifierPtr + 1, tokens, 0, length); - ref = new QualifiedNameReference( - tokens, - (int) (identifierPositionStack[identifierPtr + 1] >> 32), // sourceStart - (int) identifierPositionStack[identifierPtr + length]); // sourceEnd - ref.bits &= ~AstNode.RestrictiveFlagMASK; - ref.bits |= LOCAL | FIELD; - return ref; -} -public void goForBlockStatementsOrMethodHeaders() { - //tells the scanner to go for block statements or method headers parsing + case 155 : // System.out.println("ConstructorDeclaration ::= ConstructorHeader ConstructorBody"); + consumeConstructorDeclaration(); + break; - firstToken = TokenNameMULTIPLY; - scanner.recordLineSeparator = false; -} -public void goForClassBodyDeclarations() { - //tells the scanner to go for any body declarations parsing + case 156 : // System.out.println("ConstructorDeclaration ::= ConstructorHeader SEMICOLON"); + consumeInvalidConstructorDeclaration(); + break; - firstToken = TokenNameAND; - scanner.recordLineSeparator = true; -} -public void goForCompilationUnit(){ - //tells the scanner to go for compilation unit parsing - - firstToken = TokenNamePLUS_PLUS ; - scanner.linePtr = -1; - scanner.recordLineSeparator = true; - scanner.currentLine= null; - scanner.lines= new ArrayList(); -} -public void goForConstructorBody(){ - //tells the scanner to go for compilation unit parsing + case 157 : // System.out.println("ConstructorBody ::= NestedMethod LBRACE ConstructorBlockStatementsopt RBRACE"); + consumeConstructorBody(); + break; - firstToken = TokenNameEQUAL_EQUAL ; - scanner.recordLineSeparator = false; -} -public void goForExpression() { - //tells the scanner to go for an expression parsing + case 160 : // System.out.println("ConstructorBlockStatementsopt ::= ExplicitConstructorInvocation BlockStatements"); + consumeConstructorBlockStatements(); + break; - firstToken = TokenNameREMAINDER; - scanner.recordLineSeparator = false; -} -public void goForFieldDeclaration(){ - //tells the scanner to go for field declaration parsing + case 161 : // System.out.println("ExplicitConstructorInvocation ::= this LPAREN ArgumentListopt RPAREN SEMICOLON"); + consumeExplicitConstructorInvocation(0, ExplicitConstructorCall.This); + break; - firstToken = TokenNameAND_AND ; - scanner.recordLineSeparator = true; -} -public void goForGenericMethodDeclaration(){ - //tells the scanner to go for generic method declarations parsing + case 162 : // System.out.println("ExplicitConstructorInvocation ::= super LPAREN ArgumentListopt RPAREN SEMICOLON"); + consumeExplicitConstructorInvocation(0, ExplicitConstructorCall.Super); + break; - firstToken = TokenNameDIVIDE; - scanner.recordLineSeparator = true; -} -public void goForHeaders(){ - //tells the scanner to go for headers only parsing + case 163 : // System.out.println("ExplicitConstructorInvocation ::= Primary DOT super LPAREN ArgumentListopt RPAREN"); + consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.Super); + break; - firstToken = TokenNameUNSIGNED_RIGHT_SHIFT; - scanner.recordLineSeparator = true; -} -public void goForImportDeclaration(){ - //tells the scanner to go for import declaration parsing + case 164 : // System.out.println("ExplicitConstructorInvocation ::= Name DOT super LPAREN ArgumentListopt RPAREN..."); + consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.Super); + break; - firstToken = TokenNameOR_OR ; - scanner.recordLineSeparator = true; -} -public void goForInitializer(){ - //tells the scanner to go for initializer parsing + case 165 : // System.out.println("ExplicitConstructorInvocation ::= Primary DOT this LPAREN ArgumentListopt RPAREN..."); + consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.This); + break; - firstToken = TokenNameRIGHT_SHIFT ; - scanner.recordLineSeparator = false; -} -public void goForMethodBody(){ - //tells the scanner to go for method body parsing + case 166 : // System.out.println("ExplicitConstructorInvocation ::= Name DOT this LPAREN ArgumentListopt RPAREN..."); + consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.This); + break; - firstToken = TokenNameMINUS_MINUS ; - scanner.recordLineSeparator = false; -} -public void goForPackageDeclaration() { - //tells the scanner to go for package declaration parsing + case 167 : // System.out.println("InterfaceDeclaration ::= InterfaceHeader InterfaceBody"); + consumeInterfaceDeclaration(); + break; - firstToken = TokenNameQUESTION; - scanner.recordLineSeparator = true; -} -public void goForTypeDeclaration() { - //tells the scanner to go for type (interface or class) declaration parsing + case 168 : // System.out.println("InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt"); + consumeInterfaceHeader(); + break; - firstToken = TokenNamePLUS; - scanner.recordLineSeparator = true; -} -public final static void grammar(){ -/* ---main options -%options ACTION, AN=JavaAction.java, GP=java, -%options FILE-PREFIX=java, ESCAPE=$, PREFIX=TokenName, OUTPUT-SIZE=125 , -%options NOGOTO-DEFAULT, SINGLE-PRODUCTIONS, LALR=1 , TABLE=TIME , - ---error recovering options..... -%options ERROR_MAPS - ---grammar understanding options -%options first follow -%options TRACE=FULL , -%options VERBOSE - ---Usefull macros helping reading/writing semantic actions -$Define -$putCase -/. case $rule_number : // System.out.println("$rule_text"); - ./ - -$break -/. - break ; -./ - --- here it starts really ------------------------------------------ -$Terminals - - Identifier - - abstract assert boolean break byte case catch char class - continue default do double else extends false final finally float - for if implements import instanceof int - interface long native new null package private - protected public return short static strictfp super switch - synchronized this throw throws transient true try void - volatile while - - IntegerLiteral - LongLiteral - FloatingPointLiteral - DoubleLiteral - CharacterLiteral - StringLiteral - - PLUS_PLUS - MINUS_MINUS - EQUAL_EQUAL - LESS_EQUAL - GREATER_EQUAL - NOT_EQUAL - LEFT_SHIFT - RIGHT_SHIFT - UNSIGNED_RIGHT_SHIFT - PLUS_EQUAL - MINUS_EQUAL - MULTIPLY_EQUAL - DIVIDE_EQUAL - AND_EQUAL - OR_EQUAL - XOR_EQUAL - REMAINDER_EQUAL - LEFT_SHIFT_EQUAL - RIGHT_SHIFT_EQUAL - UNSIGNED_RIGHT_SHIFT_EQUAL - OR_OR - AND_AND - PLUS - MINUS - NOT - REMAINDER - XOR - AND - MULTIPLY - OR - TWIDDLE - DIVIDE - GREATER - LESS - LPAREN - RPAREN - LBRACE - RBRACE - LBRACKET - RBRACKET - SEMICOLON - QUESTION - COLON - COMMA - DOT - EQUAL - --- BodyMarker - -$Alias - - '++' ::= PLUS_PLUS - '--' ::= MINUS_MINUS - '==' ::= EQUAL_EQUAL - '<=' ::= LESS_EQUAL - '>=' ::= GREATER_EQUAL - '!=' ::= NOT_EQUAL - '<<' ::= LEFT_SHIFT - '>>' ::= RIGHT_SHIFT - '>>>' ::= UNSIGNED_RIGHT_SHIFT - '+=' ::= PLUS_EQUAL - '-=' ::= MINUS_EQUAL - '*=' ::= MULTIPLY_EQUAL - '/=' ::= DIVIDE_EQUAL - '&=' ::= AND_EQUAL - '|=' ::= OR_EQUAL - '^=' ::= XOR_EQUAL - '%=' ::= REMAINDER_EQUAL - '<<=' ::= LEFT_SHIFT_EQUAL - '>>=' ::= RIGHT_SHIFT_EQUAL - '>>>=' ::= UNSIGNED_RIGHT_SHIFT_EQUAL - '||' ::= OR_OR - '&&' ::= AND_AND - - '+' ::= PLUS - '-' ::= MINUS - '!' ::= NOT - '%' ::= REMAINDER - '^' ::= XOR - '&' ::= AND - '*' ::= MULTIPLY - '|' ::= OR - '~' ::= TWIDDLE - '/' ::= DIVIDE - '>' ::= GREATER - '<' ::= LESS - '(' ::= LPAREN - ')' ::= RPAREN - '{' ::= LBRACE - '}' ::= RBRACE - '[' ::= LBRACKET - ']' ::= RBRACKET - ';' ::= SEMICOLON - '?' ::= QUESTION - ':' ::= COLON - ',' ::= COMMA - '.' ::= DOT - '=' ::= EQUAL - -$Start - Goal - -$Rules - -/. // This method is part of an automatic generation : do NOT edit-modify -protected void consumeRule(int act) { - switch ( act ) { -./ - - - -Goal ::= '++' CompilationUnit -Goal ::= '--' MethodBody -Goal ::= '==' ConstructorBody --- Initializer -Goal ::= '>>' StaticInitializer -Goal ::= '>>' Initializer --- error recovery -Goal ::= '>>>' Headers -Goal ::= '*' BlockStatements -Goal ::= '*' MethodPushModifiersHeader -Goal ::= '*' CatchHeader --- JDOM -Goal ::= '&&' FieldDeclaration -Goal ::= '||' ImportDeclaration -Goal ::= '?' PackageDeclaration -Goal ::= '+' TypeDeclaration -Goal ::= '/' GenericMethodDeclaration -Goal ::= '&' ClassBodyDeclaration --- code snippet -Goal ::= '%' Expression --- completion parser -Goal ::= '!' ConstructorBlockStatementsopt -Goal ::= '~' BlockStatementsopt - -Literal -> IntegerLiteral -Literal -> LongLiteral -Literal -> FloatingPointLiteral -Literal -> DoubleLiteral -Literal -> CharacterLiteral -Literal -> StringLiteral -Literal -> null -Literal -> BooleanLiteral -BooleanLiteral -> true -BooleanLiteral -> false - -------------------------------------------------------------- -------------------------------------------------------------- ---a Type results in both a push of its dimension(s) and its name(s). - -Type ::= PrimitiveType - /.$putCase consumePrimitiveType(); $break ./ -Type -> ReferenceType - -PrimitiveType -> NumericType -NumericType -> IntegralType -NumericType -> FloatingPointType - -PrimitiveType -> 'boolean' -PrimitiveType -> 'void' -IntegralType -> 'byte' -IntegralType -> 'short' -IntegralType -> 'int' -IntegralType -> 'long' -IntegralType -> 'char' -FloatingPointType -> 'float' -FloatingPointType -> 'double' - -ReferenceType ::= ClassOrInterfaceType -/.$putCase consumeReferenceType(); $break ./ -ReferenceType -> ArrayType -- here a push of dimensions is done, that explains the two previous push 0 - -ClassOrInterfaceType -> Name - --- --- These rules have been rewritten to avoid some conflicts introduced --- by adding the 1.1 features --- --- ArrayType ::= PrimitiveType '[' ']' --- ArrayType ::= Name '[' ']' --- ArrayType ::= ArrayType '[' ']' --- - -ArrayType ::= PrimitiveType Dims -ArrayType ::= Name Dims - -ClassType -> ClassOrInterfaceType - - --------------------------------------------------------------- --------------------------------------------------------------- - -Name -> SimpleName -Name -> QualifiedName - -SimpleName -> 'Identifier' - -QualifiedName ::= Name '.' SimpleName -/.$putCase consumeQualifiedName(); $break ./ - -CompilationUnit ::= EnterCompilationUnit PackageDeclarationopt ImportDeclarationsopt TypeDeclarationsopt -/.$putCase consumeCompilationUnit(); $break ./ - -EnterCompilationUnit ::= $empty -/.$putCase consumeEnterCompilationUnit(); $break ./ - -Headers -> Header -Headers ::= Headers Header - -Header -> ImportDeclaration -Header -> PackageDeclaration -Header -> ClassHeader -Header -> InterfaceHeader -Header -> StaticInitializer -Header -> MethodHeader -Header -> ConstructorHeader -Header -> FieldDeclaration -Header -> AllocationHeader - -CatchHeader ::= 'catch' '(' FormalParameter ')' '{' -/.$putCase consumeCatchHeader(); $break ./ - -ImportDeclarations -> ImportDeclaration -ImportDeclarations ::= ImportDeclarations ImportDeclaration -/.$putCase consumeImportDeclarations(); $break ./ - -TypeDeclarations -> TypeDeclaration -TypeDeclarations ::= TypeDeclarations TypeDeclaration -/.$putCase consumeTypeDeclarations(); $break ./ - -PackageDeclaration ::= PackageDeclarationName ';' -/.$putCase consumePackageDeclaration(); $break ./ - -PackageDeclarationName ::= 'package' Name -/.$putCase consumePackageDeclarationName(); $break ./ - -ImportDeclaration -> SingleTypeImportDeclaration -ImportDeclaration -> TypeImportOnDemandDeclaration - -SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';' -/.$putCase consumeSingleTypeImportDeclaration(); $break ./ - -SingleTypeImportDeclarationName ::= 'import' Name -/.$putCase consumeSingleTypeImportDeclarationName(); $break ./ - -TypeImportOnDemandDeclaration ::= TypeImportOnDemandDeclarationName ';' -/.$putCase consumeTypeImportOnDemandDeclaration(); $break ./ - -TypeImportOnDemandDeclarationName ::= 'import' Name '.' '*' -/.$putCase consumeTypeImportOnDemandDeclarationName(); $break ./ - -TypeDeclaration -> ClassDeclaration -TypeDeclaration -> InterfaceDeclaration --- this declaration in part of a list od declaration and we will --- use and optimized list length calculation process --- thus we decrement the number while it will be incremend..... -TypeDeclaration ::= ';' -/. $putCase consumeEmptyTypeDeclaration(); $break ./ - ---18.7 Only in the LALR(1) Grammar - -Modifiers ::= Modifier -Modifiers ::= Modifiers Modifier - -Modifier -> 'public' -Modifier -> 'protected' -Modifier -> 'private' -Modifier -> 'static' -Modifier -> 'abstract' -Modifier -> 'final' -Modifier -> 'native' -Modifier -> 'synchronized' -Modifier -> 'transient' -Modifier -> 'volatile' -Modifier -> 'strictfp' - ---18.8 Productions from 8: Class Declarations ---ClassModifier ::= --- 'abstract' --- | 'final' --- | 'public' ---18.8.1 Productions from 8.1: Class Declarations + case 169 : // System.out.println("InterfaceHeaderName ::= Modifiersopt interface Identifier"); + consumeInterfaceHeaderName(); + break; -ClassDeclaration ::= ClassHeader ClassBody -/.$putCase consumeClassDeclaration(); $break ./ + case 171 : // System.out.println("InterfaceHeaderExtends ::= extends InterfaceTypeList"); + consumeInterfaceHeaderExtends(); + break; -ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt -/.$putCase consumeClassHeader(); $break ./ - -ClassHeaderName ::= Modifiersopt 'class' 'Identifier' -/.$putCase consumeClassHeaderName(); $break ./ - -ClassHeaderExtends ::= 'extends' ClassType -/.$putCase consumeClassHeaderExtends(); $break ./ - -ClassHeaderImplements ::= 'implements' InterfaceTypeList -/.$putCase consumeClassHeaderImplements(); $break ./ - -InterfaceTypeList -> InterfaceType -InterfaceTypeList ::= InterfaceTypeList ',' InterfaceType -/.$putCase consumeInterfaceTypeList(); $break ./ - -InterfaceType ::= ClassOrInterfaceType -/.$putCase consumeInterfaceType(); $break ./ - -ClassBody ::= '{' ClassBodyDeclarationsopt '}' - -ClassBodyDeclarations ::= ClassBodyDeclaration -ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration -/.$putCase consumeClassBodyDeclarations(); $break ./ - -ClassBodyDeclaration -> ClassMemberDeclaration -ClassBodyDeclaration -> StaticInitializer -ClassBodyDeclaration -> ConstructorDeclaration ---1.1 feature -ClassBodyDeclaration ::= Diet NestedMethod Block -/.$putCase consumeClassBodyDeclaration(); $break ./ -Diet ::= $empty -/.$putCase consumeDiet(); $break./ - -Initializer ::= Diet NestedMethod Block -/.$putCase consumeClassBodyDeclaration(); $break ./ - -ClassMemberDeclaration -> FieldDeclaration -ClassMemberDeclaration -> MethodDeclaration ---1.1 feature -ClassMemberDeclaration -> ClassDeclaration ---1.1 feature -ClassMemberDeclaration -> InterfaceDeclaration - --- Empty declarations are not valid Java ClassMemberDeclarations. --- However, since the current (2/14/97) Java compiler accepts them --- (in fact, some of the official tests contain this erroneous --- syntax) - -GenericMethodDeclaration -> MethodDeclaration -GenericMethodDeclaration -> ConstructorDeclaration - -ClassMemberDeclaration ::= ';' -/.$putCase consumeEmptyClassMemberDeclaration(); $break./ - ---18.8.2 Productions from 8.3: Field Declarations ---VariableModifier ::= --- 'public' --- | 'protected' --- | 'private' --- | 'static' --- | 'final' --- | 'transient' --- | 'volatile' + case 174 : // System.out.println("InterfaceMemberDeclarations ::= InterfaceMemberDeclarations..."); + consumeInterfaceMemberDeclarations(); + break; -FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';' -/.$putCase consumeFieldDeclaration(); $break ./ + case 175 : // System.out.println("InterfaceMemberDeclaration ::= SEMICOLON"); + consumeEmptyInterfaceMemberDeclaration(); + break; -VariableDeclarators -> VariableDeclarator -VariableDeclarators ::= VariableDeclarators ',' VariableDeclarator -/.$putCase consumeVariableDeclarators(); $break ./ + case 178 : // System.out.println("InterfaceMemberDeclaration ::= InvalidMethodDeclaration"); + ignoreMethodBody(); + break; -VariableDeclarator ::= VariableDeclaratorId EnterVariable ExitVariableWithoutInitialization + case 179 : // System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody"); + ignoreInvalidConstructorDeclaration(true); + break; -VariableDeclarator ::= VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization + case 180 : // System.out.println("InvalidConstructorDeclaration ::= ConstructorHeader SEMICOLON"); + ignoreInvalidConstructorDeclaration(false); + break; -EnterVariable ::= $empty -/.$putCase consumeEnterVariable(); $break ./ + case 186 : // System.out.println("ArrayInitializer ::= LBRACE ,opt RBRACE"); + consumeEmptyArrayInitializer(); + break; -ExitVariableWithInitialization ::= $empty -/.$putCase consumeExitVariableWithInitialization(); $break ./ + case 187 : // System.out.println("ArrayInitializer ::= LBRACE VariableInitializers RBRACE"); + consumeArrayInitializer(); + break; -ExitVariableWithoutInitialization ::= $empty -/.$putCase consumeExitVariableWithoutInitialization(); $break ./ + case 188 : // System.out.println("ArrayInitializer ::= LBRACE VariableInitializers COMMA RBRACE"); + consumeArrayInitializer(); + break; -ForceNoDiet ::= $empty -/.$putCase consumeForceNoDiet(); $break ./ -RestoreDiet ::= $empty -/.$putCase consumeRestoreDiet(); $break ./ + case 190 : // System.out.println("VariableInitializers ::= VariableInitializers COMMA VariableInitializer"); + consumeVariableInitializers(); + break; -VariableDeclaratorId ::= 'Identifier' Dimsopt + case 191 : // System.out.println("Block ::= OpenBlock LBRACE BlockStatementsopt RBRACE"); + consumeBlock(); + break; -VariableInitializer -> Expression -VariableInitializer -> ArrayInitializer + case 192 : // System.out.println("OpenBlock ::="); + consumeOpenBlock(); + break; ---18.8.3 Productions from 8.4: Method Declarations ---MethodModifier ::= --- 'public' --- | 'protected' --- | 'private' --- | 'static' --- | 'abstract' --- | 'final' --- | 'native' --- | 'synchronized' --- + case 194 : // System.out.println("BlockStatements ::= BlockStatements BlockStatement"); + consumeBlockStatements(); + break; -MethodDeclaration -> AbstractMethodDeclaration -MethodDeclaration ::= MethodHeader MethodBody -/.$putCase // set to true to consume a method with a body - consumeMethodDeclaration(true); $break ./ + case 198 : // System.out.println("BlockStatement ::= InvalidInterfaceDeclaration"); + ignoreInterfaceDeclaration(); + break; -AbstractMethodDeclaration ::= MethodHeader ';' -/.$putCase // set to false to consume a method without body - consumeMethodDeclaration(false); $break ./ + case 199 : // System.out.println("LocalVariableDeclarationStatement ::= LocalVariableDeclaration SEMICOLON"); + consumeLocalVariableDeclarationStatement(); + break; -MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims MethodHeaderThrowsClauseopt -/.$putCase consumeMethodHeader(); $break ./ + case 200 : // System.out.println("LocalVariableDeclaration ::= Type PushModifiers VariableDeclarators"); + consumeLocalVariableDeclaration(); + break; -MethodPushModifiersHeader ::= MethodPushModifiersHeaderName MethodHeaderParameters MethodHeaderExtendedDims MethodHeaderThrowsClauseopt -/.$putCase consumeMethodHeader(); $break ./ + case 201 : // System.out.println("LocalVariableDeclaration ::= Modifiers Type PushModifiers VariableDeclarators"); + consumeLocalVariableDeclaration(); + break; -MethodPushModifiersHeaderName ::= Modifiers Type PushModifiers 'Identifier' '(' -/.$putCase consumeMethodPushModifiersHeaderName(); $break ./ + case 202 : // System.out.println("PushModifiers ::="); + consumePushModifiers(); + break; -MethodPushModifiersHeaderName ::= Type PushModifiers 'Identifier' '(' -/.$putCase consumeMethodPushModifiersHeaderName(); $break ./ + case 226 : // System.out.println("EmptyStatement ::= SEMICOLON"); + consumeEmptyStatement(); + break; -MethodHeaderName ::= Modifiersopt Type 'Identifier' '(' -/.$putCase consumeMethodHeaderName(); $break ./ + case 227 : // System.out.println("LabeledStatement ::= Identifier COLON Statement"); + consumeStatementLabel(); + break; -MethodHeaderParameters ::= FormalParameterListopt ')' -/.$putCase consumeMethodHeaderParameters(); $break ./ + case 228 : // System.out.println("LabeledStatementNoShortIf ::= Identifier COLON StatementNoShortIf"); + consumeStatementLabel(); + break; -MethodHeaderExtendedDims ::= Dimsopt -/.$putCase consumeMethodHeaderExtendedDims(); $break ./ + case 229 : // System.out.println("ExpressionStatement ::= StatementExpression SEMICOLON"); + consumeExpressionStatement(); + break; -MethodHeaderThrowsClause ::= 'throws' ClassTypeList -/.$putCase consumeMethodHeaderThrowsClause(); $break ./ + case 237 : // System.out.println("IfThenStatement ::= if LPAREN Expression RPAREN Statement"); + consumeStatementIfNoElse(); + break; -ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters MethodHeaderThrowsClauseopt -/.$putCase consumeConstructorHeader(); $break ./ + case 238 : // System.out.println("IfThenElseStatement ::= if LPAREN Expression RPAREN StatementNoShortIf else..."); + consumeStatementIfWithElse(); + break; -ConstructorHeaderName ::= Modifiersopt 'Identifier' '(' -/.$putCase consumeConstructorHeaderName(); $break ./ + case 239 : // System.out.println("IfThenElseStatementNoShortIf ::= if LPAREN Expression RPAREN StatementNoShortIf..."); + consumeStatementIfWithElse(); + break; -FormalParameterList -> FormalParameter -FormalParameterList ::= FormalParameterList ',' FormalParameter -/.$putCase consumeFormalParameterList(); $break ./ + case 240 : // System.out.println("SwitchStatement ::= switch OpenBlock LPAREN Expression RPAREN SwitchBlock"); + consumeStatementSwitch(); + break; ---1.1 feature -FormalParameter ::= Modifiersopt Type VariableDeclaratorId -/.$putCase // the boolean is used to know if the modifiers should be reset - consumeFormalParameter(); $break ./ + case 241 : // System.out.println("SwitchBlock ::= LBRACE RBRACE"); + consumeEmptySwitchBlock(); + break; -ClassTypeList -> ClassTypeElt -ClassTypeList ::= ClassTypeList ',' ClassTypeElt -/.$putCase consumeClassTypeList(); $break ./ + case 244 : // System.out.println("SwitchBlock ::= LBRACE SwitchBlockStatements SwitchLabels RBRACE"); + consumeSwitchBlock(); + break; -ClassTypeElt ::= ClassType -/.$putCase consumeClassTypeElt(); $break ./ + case 246 : // System.out.println("SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement"); + consumeSwitchBlockStatements(); + break; + case 247 : // System.out.println("SwitchBlockStatement ::= SwitchLabels BlockStatements"); + consumeSwitchBlockStatement(); + break; -MethodBody ::= NestedMethod '{' BlockStatementsopt '}' -/.$putCase consumeMethodBody(); $break ./ + case 249 : // System.out.println("SwitchLabels ::= SwitchLabels SwitchLabel"); + consumeSwitchLabels(); + break; -NestedMethod ::= $empty -/.$putCase consumeNestedMethod(); $break ./ + case 250 : // System.out.println("SwitchLabel ::= case ConstantExpression COLON"); + consumeCaseLabel(); + break; ---18.8.4 Productions from 8.5: Static Initializers + case 251 : // System.out.println("SwitchLabel ::= default COLON"); + consumeDefaultLabel(); + break; -StaticInitializer ::= StaticOnly Block -/.$putCase consumeStaticInitializer(); $break./ + case 252 : // System.out.println("WhileStatement ::= while LPAREN Expression RPAREN Statement"); + consumeStatementWhile(); + break; -StaticOnly ::= 'static' -/.$putCase consumeStaticOnly(); $break ./ + case 253 : // System.out.println("WhileStatementNoShortIf ::= while LPAREN Expression RPAREN StatementNoShortIf"); + consumeStatementWhile(); + break; ---18.8.5 Productions from 8.6: Constructor Declarations ---ConstructorModifier ::= --- 'public' --- | 'protected' --- | 'private' --- --- -ConstructorDeclaration ::= ConstructorHeader ConstructorBody -/.$putCase consumeConstructorDeclaration() ; $break ./ + case 254 : // System.out.println("DoStatement ::= do Statement while LPAREN Expression RPAREN SEMICOLON"); + consumeStatementDo(); + break; --- These rules are added to be able to parse constructors with no body -ConstructorDeclaration ::= ConstructorHeader ';' -/.$putCase consumeInvalidConstructorDeclaration() ; $break ./ + case 255 : // System.out.println("ForStatement ::= for LPAREN ForInitopt SEMICOLON Expressionopt SEMICOLON..."); + consumeStatementFor(); + break; --- the rules ExplicitConstructorInvocationopt has been expanded --- in the rule below in order to make the grammar lalr(1). --- ConstructorBody ::= '{' ExplicitConstructorInvocationopt BlockStatementsopt '}' --- Other inlining has occured into the next rule too.... + case 256 : // System.out.println("ForStatementNoShortIf ::= for LPAREN ForInitopt SEMICOLON Expressionopt SEMICOLON"); + consumeStatementFor(); + break; -ConstructorBody ::= NestedMethod '{' ConstructorBlockStatementsopt '}' -/.$putCase consumeConstructorBody(); $break ./ + case 257 : // System.out.println("ForInit ::= StatementExpressionList"); + consumeForInit(); + break; -ConstructorBlockStatementsopt -> BlockStatementsopt + case 261 : // System.out.println("StatementExpressionList ::= StatementExpressionList COMMA StatementExpression"); + consumeStatementExpressionList(); + break; -ConstructorBlockStatementsopt -> ExplicitConstructorInvocation + case 262 : // System.out.println("AssertStatement ::= assert Expression SEMICOLON"); + consumeSimpleAssertStatement(); + break; -ConstructorBlockStatementsopt ::= ExplicitConstructorInvocation BlockStatements -/.$putCase consumeConstructorBlockStatements(); $break ./ + case 263 : // System.out.println("AssertStatement ::= assert Expression COLON Expression SEMICOLON"); + consumeAssertStatement(); + break; -ExplicitConstructorInvocation ::= 'this' '(' ArgumentListopt ')' ';' -/.$putCase consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.This); $break ./ + case 264 : // System.out.println("BreakStatement ::= break SEMICOLON"); + consumeStatementBreak(); + break; -ExplicitConstructorInvocation ::= 'super' '(' ArgumentListopt ')' ';' -/.$putCase consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.Super); $break ./ + case 265 : // System.out.println("BreakStatement ::= break Identifier SEMICOLON"); + consumeStatementBreakWithLabel(); + break; ---1.1 feature -ExplicitConstructorInvocation ::= Primary '.' 'super' '(' ArgumentListopt ')' ';' -/.$putCase consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.Super); $break ./ + case 266 : // System.out.println("ContinueStatement ::= continue SEMICOLON"); + consumeStatementContinue(); + break; ---1.1 feature -ExplicitConstructorInvocation ::= Name '.' 'super' '(' ArgumentListopt ')' ';' -/.$putCase consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.Super); $break ./ + case 267 : // System.out.println("ContinueStatement ::= continue Identifier SEMICOLON"); + consumeStatementContinueWithLabel(); + break; ---1.1 feature -ExplicitConstructorInvocation ::= Primary '.' 'this' '(' ArgumentListopt ')' ';' -/.$putCase consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.This); $break ./ + case 268 : // System.out.println("ReturnStatement ::= return Expressionopt SEMICOLON"); + consumeStatementReturn(); + break; ---1.1 feature -ExplicitConstructorInvocation ::= Name '.' 'this' '(' ArgumentListopt ')' ';' -/.$putCase consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.This); $break ./ + case 269 : // System.out.println("ThrowStatement ::= throw Expression SEMICOLON"); + consumeStatementThrow(); ---18.9 Productions from 9: Interface Declarations + break; ---18.9.1 Productions from 9.1: Interface Declarations ---InterfaceModifier ::= --- 'public' --- | 'abstract' --- -InterfaceDeclaration ::= InterfaceHeader InterfaceBody -/.$putCase consumeInterfaceDeclaration(); $break ./ + case 270 : // System.out.println("SynchronizedStatement ::= OnlySynchronized LPAREN Expression RPAREN Block"); + consumeStatementSynchronized(); + break; -InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt -/.$putCase consumeInterfaceHeader(); $break ./ + case 271 : // System.out.println("OnlySynchronized ::= synchronized"); + consumeOnlySynchronized(); + break; -InterfaceHeaderName ::= Modifiersopt 'interface' 'Identifier' -/.$putCase consumeInterfaceHeaderName(); $break ./ + case 272 : // System.out.println("TryStatement ::= try Block Catches"); + consumeStatementTry(false); + break; --- This rule will be used to accept inner local interface and then report a relevant error message -InvalidInterfaceDeclaration -> InterfaceHeader InterfaceBody + case 273 : // System.out.println("TryStatement ::= try Block Catchesopt Finally"); + consumeStatementTry(true); + break; -InterfaceHeaderExtends ::= 'extends' InterfaceTypeList -/.$putCase consumeInterfaceHeaderExtends(); $break ./ + case 275 : // System.out.println("Catches ::= Catches CatchClause"); + consumeCatches(); + break; -InterfaceBody ::= '{' InterfaceMemberDeclarationsopt '}' - -InterfaceMemberDeclarations -> InterfaceMemberDeclaration -InterfaceMemberDeclarations ::= InterfaceMemberDeclarations InterfaceMemberDeclaration -/.$putCase consumeInterfaceMemberDeclarations(); $break ./ - ---same as for class members -InterfaceMemberDeclaration ::= ';' -/.$putCase consumeEmptyInterfaceMemberDeclaration(); $break ./ + case 276 : // System.out.println("CatchClause ::= catch LPAREN FormalParameter RPAREN Block"); + consumeStatementCatch(); + break; --- This rule is added to be able to parse non abstract method inside interface and then report a relevent error message -InvalidMethodDeclaration -> MethodHeader MethodBody + case 278 : // System.out.println("PushLPAREN ::= LPAREN"); + consumeLeftParen(); + break; -InterfaceMemberDeclaration -> ConstantDeclaration -InterfaceMemberDeclaration ::= InvalidMethodDeclaration -/.$putCase ignoreMethodBody(); $break ./ - --- These rules are added to be able to parse constructors inside interface and then report a relevent error message -InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody -/.$putCase ignoreInvalidConstructorDeclaration(true); $break ./ - -InvalidConstructorDeclaration ::= ConstructorHeader ';' -/.$putCase ignoreInvalidConstructorDeclaration(false); $break ./ - -InterfaceMemberDeclaration -> AbstractMethodDeclaration -InterfaceMemberDeclaration -> InvalidConstructorDeclaration - ---1.1 feature -InterfaceMemberDeclaration -> ClassDeclaration ---1.1 feature -InterfaceMemberDeclaration -> InterfaceDeclaration - -ConstantDeclaration -> FieldDeclaration - -ArrayInitializer ::= '{' ,opt '}' -/.$putCase consumeEmptyArrayInitializer(); $break ./ -ArrayInitializer ::= '{' VariableInitializers '}' -/.$putCase consumeArrayInitializer(); $break ./ -ArrayInitializer ::= '{' VariableInitializers , '}' -/.$putCase consumeArrayInitializer(); $break ./ + case 279 : // System.out.println("PushRPAREN ::= RPAREN"); + consumeRightParen(); + break; -VariableInitializers ::= VariableInitializer -VariableInitializers ::= VariableInitializers ',' VariableInitializer -/.$putCase consumeVariableInitializers(); $break ./ + case 283 : // System.out.println("PrimaryNoNewArray ::= this"); + consumePrimaryNoNewArrayThis(); + break; -Block ::= OpenBlock '{' BlockStatementsopt '}' -/.$putCase consumeBlock(); $break ./ -OpenBlock ::= $empty -/.$putCase consumeOpenBlock() ; $break ./ - -BlockStatements -> BlockStatement -BlockStatements ::= BlockStatements BlockStatement -/.$putCase consumeBlockStatements() ; $break ./ - -BlockStatement -> LocalVariableDeclarationStatement -BlockStatement -> Statement ---1.1 feature -BlockStatement -> ClassDeclaration -BlockStatement ::= InvalidInterfaceDeclaration -/.$putCase ignoreInterfaceDeclaration(); $break ./ - -LocalVariableDeclarationStatement ::= LocalVariableDeclaration ';' -/.$putCase consumeLocalVariableDeclarationStatement(); $break ./ - -LocalVariableDeclaration ::= Type PushModifiers VariableDeclarators -/.$putCase consumeLocalVariableDeclaration(); $break ./ - --- 1.1 feature --- The modifiers part of this rule makes the grammar more permissive. --- The only modifier here is final. We put Modifiers to allow multiple modifiers --- This will require to check the validity of the modifier - -LocalVariableDeclaration ::= Modifiers Type PushModifiers VariableDeclarators -/.$putCase consumeLocalVariableDeclaration(); $break ./ - -PushModifiers ::= $empty -/.$putCase consumePushModifiers(); $break ./ - -Statement -> StatementWithoutTrailingSubstatement -Statement -> LabeledStatement -Statement -> IfThenStatement -Statement -> IfThenElseStatement -Statement -> WhileStatement -Statement -> ForStatement - -StatementNoShortIf -> StatementWithoutTrailingSubstatement -StatementNoShortIf -> LabeledStatementNoShortIf -StatementNoShortIf -> IfThenElseStatementNoShortIf -StatementNoShortIf -> WhileStatementNoShortIf -StatementNoShortIf -> ForStatementNoShortIf + case 284 : // System.out.println("PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN"); + consumePrimaryNoNewArray(); + break; -StatementWithoutTrailingSubstatement -> AssertStatement -StatementWithoutTrailingSubstatement -> Block -StatementWithoutTrailingSubstatement -> EmptyStatement -StatementWithoutTrailingSubstatement -> ExpressionStatement -StatementWithoutTrailingSubstatement -> SwitchStatement -StatementWithoutTrailingSubstatement -> DoStatement -StatementWithoutTrailingSubstatement -> BreakStatement -StatementWithoutTrailingSubstatement -> ContinueStatement -StatementWithoutTrailingSubstatement -> ReturnStatement -StatementWithoutTrailingSubstatement -> SynchronizedStatement -StatementWithoutTrailingSubstatement -> ThrowStatement -StatementWithoutTrailingSubstatement -> TryStatement - -EmptyStatement ::= ';' -/.$putCase consumeEmptyStatement(); $break ./ - -LabeledStatement ::= 'Identifier' ':' Statement -/.$putCase consumeStatementLabel() ; $break ./ - -LabeledStatementNoShortIf ::= 'Identifier' ':' StatementNoShortIf -/.$putCase consumeStatementLabel() ; $break ./ - -ExpressionStatement ::= StatementExpression ';' -/. $putCase consumeExpressionStatement(); $break ./ - -StatementExpression ::= Assignment -StatementExpression ::= PreIncrementExpression -StatementExpression ::= PreDecrementExpression -StatementExpression ::= PostIncrementExpression -StatementExpression ::= PostDecrementExpression -StatementExpression ::= MethodInvocation -StatementExpression ::= ClassInstanceCreationExpression - -IfThenStatement ::= 'if' '(' Expression ')' Statement -/.$putCase consumeStatementIfNoElse(); $break ./ - -IfThenElseStatement ::= 'if' '(' Expression ')' StatementNoShortIf 'else' Statement -/.$putCase consumeStatementIfWithElse(); $break ./ + case 287 : // System.out.println("PrimaryNoNewArray ::= Name DOT this"); + consumePrimaryNoNewArrayNameThis(); + break; -IfThenElseStatementNoShortIf ::= 'if' '(' Expression ')' StatementNoShortIf 'else' StatementNoShortIf -/.$putCase consumeStatementIfWithElse(); $break ./ + case 288 : // System.out.println("PrimaryNoNewArray ::= Name DOT super"); + consumePrimaryNoNewArrayNameSuper(); + break; -SwitchStatement ::= 'switch' OpenBlock '(' Expression ')' SwitchBlock -/.$putCase consumeStatementSwitch() ; $break ./ + case 289 : // System.out.println("PrimaryNoNewArray ::= Name DOT class"); + consumePrimaryNoNewArrayName(); + break; -SwitchBlock ::= '{' '}' -/.$putCase consumeEmptySwitchBlock() ; $break ./ + case 290 : // System.out.println("PrimaryNoNewArray ::= ArrayType DOT class"); + consumePrimaryNoNewArrayArrayType(); + break; -SwitchBlock ::= '{' SwitchBlockStatements '}' -SwitchBlock ::= '{' SwitchLabels '}' -SwitchBlock ::= '{' SwitchBlockStatements SwitchLabels '}' -/.$putCase consumeSwitchBlock() ; $break ./ + case 291 : // System.out.println("PrimaryNoNewArray ::= PrimitiveType DOT class"); + consumePrimaryNoNewArrayPrimitiveType(); + break; -SwitchBlockStatements -> SwitchBlockStatement -SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement -/.$putCase consumeSwitchBlockStatements() ; $break ./ + case 294 : // System.out.println("AllocationHeader ::= new ClassType LPAREN ArgumentListopt RPAREN"); + consumeAllocationHeader(); + break; -SwitchBlockStatement ::= SwitchLabels BlockStatements -/.$putCase consumeSwitchBlockStatement() ; $break ./ + case 295 : // System.out.println("ClassInstanceCreationExpression ::= new ClassType LPAREN ArgumentListopt RPAREN..."); + consumeClassInstanceCreationExpression(); + break; -SwitchLabels -> SwitchLabel -SwitchLabels ::= SwitchLabels SwitchLabel -/.$putCase consumeSwitchLabels() ; $break ./ + case 296 : // System.out.println("ClassInstanceCreationExpression ::= Primary DOT new SimpleName LPAREN..."); + consumeClassInstanceCreationExpressionQualified(); + break; -SwitchLabel ::= 'case' ConstantExpression ':' -/. $putCase consumeCaseLabel(); $break ./ + case 297 : // System.out.println("ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName new..."); + consumeClassInstanceCreationExpressionQualified(); + break; -SwitchLabel ::= 'default' ':' -/. $putCase consumeDefaultLabel(); $break ./ + case 298 : // System.out.println("ClassInstanceCreationExpressionName ::= Name DOT"); + consumeClassInstanceCreationExpressionName(); + break; -WhileStatement ::= 'while' '(' Expression ')' Statement -/.$putCase consumeStatementWhile() ; $break ./ + case 299 : // System.out.println("ClassBodyopt ::="); + consumeClassBodyopt(); + break; -WhileStatementNoShortIf ::= 'while' '(' Expression ')' StatementNoShortIf -/.$putCase consumeStatementWhile() ; $break ./ + case 301 : // System.out.println("EnterAnonymousClassBody ::="); + consumeEnterAnonymousClassBody(); + break; -DoStatement ::= 'do' Statement 'while' '(' Expression ')' ';' -/.$putCase consumeStatementDo() ; $break ./ + case 303 : // System.out.println("ArgumentList ::= ArgumentList COMMA Expression"); + consumeArgumentList(); + break; -ForStatement ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' Statement -/.$putCase consumeStatementFor() ; $break ./ -ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' StatementNoShortIf -/.$putCase consumeStatementFor() ; $break ./ + case 304 : // System.out.println("ArrayCreationExpression ::= new PrimitiveType DimWithOrWithOutExprs..."); + consumeArrayCreationExpression(); + break; ---the minus one allows to avoid a stack-to-stack transfer -ForInit ::= StatementExpressionList -/.$putCase consumeForInit() ; $break ./ -ForInit -> LocalVariableDeclaration + case 305 : // System.out.println("ArrayCreationExpression ::= new ClassOrInterfaceType DimWithOrWithOutExprs..."); + consumeArrayCreationExpression(); + break; -ForUpdate -> StatementExpressionList + case 307 : // System.out.println("DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr"); + consumeDimWithOrWithOutExprs(); + break; -StatementExpressionList -> StatementExpression -StatementExpressionList ::= StatementExpressionList ',' StatementExpression -/.$putCase consumeStatementExpressionList() ; $break ./ + case 309 : // System.out.println("DimWithOrWithOutExpr ::= LBRACKET RBRACKET"); + consumeDimWithOrWithOutExpr(); + break; --- 1.4 feature -AssertStatement ::= 'assert' Expression ';' -/.$putCase consumeSimpleAssertStatement() ; $break ./ + case 310 : // System.out.println("Dims ::= DimsLoop"); + consumeDims(); + break; -AssertStatement ::= 'assert' Expression ':' Expression ';' -/.$putCase consumeAssertStatement() ; $break ./ - -BreakStatement ::= 'break' ';' -/.$putCase consumeStatementBreak() ; $break ./ + case 313 : // System.out.println("OneDimLoop ::= LBRACKET RBRACKET"); + consumeOneDimLoop(); + break; -BreakStatement ::= 'break' Identifier ';' -/.$putCase consumeStatementBreakWithLabel() ; $break ./ + case 314 : // System.out.println("FieldAccess ::= Primary DOT Identifier"); + consumeFieldAccess(false); + break; -ContinueStatement ::= 'continue' ';' -/.$putCase consumeStatementContinue() ; $break ./ + case 315 : // System.out.println("FieldAccess ::= super DOT Identifier"); + consumeFieldAccess(true); + break; -ContinueStatement ::= 'continue' Identifier ';' -/.$putCase consumeStatementContinueWithLabel() ; $break ./ + case 316 : // System.out.println("MethodInvocation ::= Name LPAREN ArgumentListopt RPAREN"); + consumeMethodInvocationName(); + break; -ReturnStatement ::= 'return' Expressionopt ';' -/.$putCase consumeStatementReturn() ; $break ./ + case 317 : // System.out.println("MethodInvocation ::= Primary DOT Identifier LPAREN ArgumentListopt RPAREN"); + consumeMethodInvocationPrimary(); + break; -ThrowStatement ::= 'throw' Expression ';' -/.$putCase consumeStatementThrow(); -$break ./ + case 318 : // System.out.println("MethodInvocation ::= super DOT Identifier LPAREN ArgumentListopt RPAREN"); + consumeMethodInvocationSuper(); + break; -SynchronizedStatement ::= OnlySynchronized '(' Expression ')' Block -/.$putCase consumeStatementSynchronized(); $break ./ -OnlySynchronized ::= 'synchronized' -/.$putCase consumeOnlySynchronized(); $break ./ + case 319 : // System.out.println("ArrayAccess ::= Name LBRACKET Expression RBRACKET"); + consumeArrayAccess(true); + break; + case 320 : // System.out.println("ArrayAccess ::= PrimaryNoNewArray LBRACKET Expression RBRACKET"); + consumeArrayAccess(false); + break; -TryStatement ::= 'try' Block Catches -/.$putCase consumeStatementTry(false); $break ./ -TryStatement ::= 'try' Block Catchesopt Finally -/.$putCase consumeStatementTry(true); $break ./ + case 322 : // System.out.println("PostfixExpression ::= Name"); + consumePostfixExpression(); + break; -Catches -> CatchClause -Catches ::= Catches CatchClause -/.$putCase consumeCatches(); $break ./ + case 325 : // System.out.println("PostIncrementExpression ::= PostfixExpression PLUS_PLUS"); + consumeUnaryExpression(OperatorExpression.PLUS, true); + break; -CatchClause ::= 'catch' '(' FormalParameter ')' Block -/.$putCase consumeStatementCatch() ; $break ./ + case 326 : // System.out.println("PostDecrementExpression ::= PostfixExpression MINUS_MINUS"); + consumeUnaryExpression(OperatorExpression.MINUS, true); + break; -Finally ::= 'finally' Block + case 327 : // System.out.println("PushPosition ::="); + consumePushPosition(); + break; ---18.12 Productions from 14: Expressions + case 330 : // System.out.println("UnaryExpression ::= PLUS PushPosition UnaryExpression"); + consumeUnaryExpression(OperatorExpression.PLUS); + break; ---for source positionning purpose -PushLPAREN ::= '(' -/.$putCase consumeLeftParen(); $break ./ -PushRPAREN ::= ')' -/.$putCase consumeRightParen(); $break ./ + case 331 : // System.out.println("UnaryExpression ::= MINUS PushPosition UnaryExpression"); + consumeUnaryExpression(OperatorExpression.MINUS); + break; -Primary -> PrimaryNoNewArray -Primary -> ArrayCreationExpression + case 333 : // System.out.println("PreIncrementExpression ::= PLUS_PLUS PushPosition UnaryExpression"); + consumeUnaryExpression(OperatorExpression.PLUS, false); + break; -PrimaryNoNewArray -> Literal -PrimaryNoNewArray ::= 'this' -/.$putCase consumePrimaryNoNewArrayThis(); $break ./ + case 334 : // System.out.println("PreDecrementExpression ::= MINUS_MINUS PushPosition UnaryExpression"); + consumeUnaryExpression(OperatorExpression.MINUS, false); + break; -PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN -/.$putCase consumePrimaryNoNewArray(); $break ./ + case 336 : // System.out.println("UnaryExpressionNotPlusMinus ::= TWIDDLE PushPosition UnaryExpression"); + consumeUnaryExpression(OperatorExpression.TWIDDLE); + break; -PrimaryNoNewArray -> ClassInstanceCreationExpression -PrimaryNoNewArray -> FieldAccess ---1.1 feature -PrimaryNoNewArray ::= Name '.' 'this' -/.$putCase consumePrimaryNoNewArrayNameThis(); $break ./ -PrimaryNoNewArray ::= Name '.' 'super' -/.$putCase consumePrimaryNoNewArrayNameSuper(); $break ./ + case 337 : // System.out.println("UnaryExpressionNotPlusMinus ::= NOT PushPosition UnaryExpression"); + consumeUnaryExpression(OperatorExpression.NOT); + break; ---1.1 feature ---PrimaryNoNewArray ::= Type '.' 'class' ---inline Type in the previous rule in order to make the grammar LL1 instead --- of LL2. The result is the 3 next rules. -PrimaryNoNewArray ::= Name '.' 'class' -/.$putCase consumePrimaryNoNewArrayName(); $break ./ + case 339 : // System.out.println("CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN UnaryExpression"); + consumeCastExpression(); + break; -PrimaryNoNewArray ::= ArrayType '.' 'class' -/.$putCase consumePrimaryNoNewArrayArrayType(); $break ./ + case 340 : // System.out.println("CastExpression ::= PushLPAREN Name Dims PushRPAREN UnaryExpressionNotPlusMinus"); + consumeCastExpression(); + break; -PrimaryNoNewArray ::= PrimitiveType '.' 'class' -/.$putCase consumePrimaryNoNewArrayPrimitiveType(); $break ./ + case 341 : // System.out.println("CastExpression ::= PushLPAREN Expression PushRPAREN UnaryExpressionNotPlusMinus"); + consumeCastExpressionLL1(); + break; -PrimaryNoNewArray -> MethodInvocation -PrimaryNoNewArray -> ArrayAccess + case 343 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression MULTIPLY UnaryExpression"); + consumeBinaryExpression(OperatorExpression.MULTIPLY); + break; ---1.1 feature --- --- In Java 1.0 a ClassBody could not appear at all in a --- ClassInstanceCreationExpression. --- + case 344 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression DIVIDE UnaryExpression"); + consumeBinaryExpression(OperatorExpression.DIVIDE); + break; -AllocationHeader ::= 'new' ClassType '(' ArgumentListopt ')' -/.$putCase consumeAllocationHeader(); $break ./ + case 345 : // System.out.println("MultiplicativeExpression ::= MultiplicativeExpression REMAINDER UnaryExpression"); + consumeBinaryExpression(OperatorExpression.REMAINDER); + break; -ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt -/.$putCase consumeClassInstanceCreationExpression(); $break ./ ---1.1 feature + case 347 : // System.out.println("AdditiveExpression ::= AdditiveExpression PLUS MultiplicativeExpression"); + consumeBinaryExpression(OperatorExpression.PLUS); + break; -ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt -/.$putCase consumeClassInstanceCreationExpressionQualified() ; $break ./ + case 348 : // System.out.println("AdditiveExpression ::= AdditiveExpression MINUS MultiplicativeExpression"); + consumeBinaryExpression(OperatorExpression.MINUS); + break; ---1.1 feature -ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt -/.$putCase consumeClassInstanceCreationExpressionQualified() ; $break ./ + case 350 : // System.out.println("ShiftExpression ::= ShiftExpression LEFT_SHIFT AdditiveExpression"); + consumeBinaryExpression(OperatorExpression.LEFT_SHIFT); + break; -ClassInstanceCreationExpressionName ::= Name '.' -/.$putCase consumeClassInstanceCreationExpressionName() ; $break ./ - -ClassBodyopt ::= $empty --test made using null as contents -/.$putCase consumeClassBodyopt(); $break ./ -ClassBodyopt ::= EnterAnonymousClassBody ClassBody - -EnterAnonymousClassBody ::= $empty -/.$putCase consumeEnterAnonymousClassBody(); $break ./ - -ArgumentList ::= Expression -ArgumentList ::= ArgumentList ',' Expression -/.$putCase consumeArgumentList(); $break ./ - ---Thess rules are re-written in order to be ll1 ---ArrayCreationExpression ::= 'new' ArrayType ArrayInitializer ---ArrayCreationExpression ::= 'new' PrimitiveType DimExprs Dimsopt ---ArrayCreationExpression ::= 'new' ClassOrInterfaceType DimExprs Dimsopt ---DimExprs ::= DimExpr ---DimExprs ::= DimExprs DimExpr - -ArrayCreationExpression ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializeropt -/.$putCase consumeArrayCreationExpression(); $break ./ -ArrayCreationExpression ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializeropt -/.$putCase consumeArrayCreationExpression(); $break ./ - -DimWithOrWithOutExprs ::= DimWithOrWithOutExpr -DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr -/.$putCase consumeDimWithOrWithOutExprs(); $break ./ - -DimWithOrWithOutExpr ::= '[' Expression ']' -DimWithOrWithOutExpr ::= '[' ']' -/. $putCase consumeDimWithOrWithOutExpr(); $break ./ --- ----------------------------------------------- - -Dims ::= DimsLoop -/. $putCase consumeDims(); $break ./ -DimsLoop -> OneDimLoop -DimsLoop ::= DimsLoop OneDimLoop -OneDimLoop ::= '[' ']' -/. $putCase consumeOneDimLoop(); $break ./ - -FieldAccess ::= Primary '.' 'Identifier' -/.$putCase consumeFieldAccess(false); $break ./ - -FieldAccess ::= 'super' '.' 'Identifier' -/.$putCase consumeFieldAccess(true); $break ./ - -MethodInvocation ::= Name '(' ArgumentListopt ')' -/.$putCase consumeMethodInvocationName(); $break ./ - -MethodInvocation ::= Primary '.' 'Identifier' '(' ArgumentListopt ')' -/.$putCase consumeMethodInvocationPrimary(); $break ./ - -MethodInvocation ::= 'super' '.' 'Identifier' '(' ArgumentListopt ')' -/.$putCase consumeMethodInvocationSuper(); $break ./ - -ArrayAccess ::= Name '[' Expression ']' -/.$putCase consumeArrayAccess(true); $break ./ -ArrayAccess ::= PrimaryNoNewArray '[' Expression ']' -/.$putCase consumeArrayAccess(false); $break ./ - -PostfixExpression -> Primary -PostfixExpression ::= Name -/.$putCase consumePostfixExpression(); $break ./ -PostfixExpression -> PostIncrementExpression -PostfixExpression -> PostDecrementExpression - -PostIncrementExpression ::= PostfixExpression '++' -/.$putCase consumeUnaryExpression(OperatorExpression.PLUS,true); $break ./ - -PostDecrementExpression ::= PostfixExpression '--' -/.$putCase consumeUnaryExpression(OperatorExpression.MINUS,true); $break ./ - ---for source managment purpose -PushPosition ::= $empty - /.$putCase consumePushPosition(); $break ./ - -UnaryExpression -> PreIncrementExpression -UnaryExpression -> PreDecrementExpression -UnaryExpression ::= '+' PushPosition UnaryExpression -/.$putCase consumeUnaryExpression(OperatorExpression.PLUS); $break ./ -UnaryExpression ::= '-' PushPosition UnaryExpression -/.$putCase consumeUnaryExpression(OperatorExpression.MINUS); $break ./ -UnaryExpression -> UnaryExpressionNotPlusMinus - -PreIncrementExpression ::= '++' PushPosition UnaryExpression -/.$putCase consumeUnaryExpression(OperatorExpression.PLUS,false); $break ./ - -PreDecrementExpression ::= '--' PushPosition UnaryExpression -/.$putCase consumeUnaryExpression(OperatorExpression.MINUS,false); $break ./ - -UnaryExpressionNotPlusMinus -> PostfixExpression -UnaryExpressionNotPlusMinus ::= '~' PushPosition UnaryExpression -/.$putCase consumeUnaryExpression(OperatorExpression.TWIDDLE); $break ./ -UnaryExpressionNotPlusMinus ::= '!' PushPosition UnaryExpression -/.$putCase consumeUnaryExpression(OperatorExpression.NOT); $break ./ -UnaryExpressionNotPlusMinus -> CastExpression - -CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN UnaryExpression -/.$putCase consumeCastExpression(); $break ./ - CastExpression ::= PushLPAREN Name Dims PushRPAREN UnaryExpressionNotPlusMinus -/.$putCase consumeCastExpression(); $break ./ --- Expression is here only in order to make the grammar LL1 -CastExpression ::= PushLPAREN Expression PushRPAREN UnaryExpressionNotPlusMinus -/.$putCase consumeCastExpressionLL1(); $break ./ - -MultiplicativeExpression -> UnaryExpression -MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression -/.$putCase consumeBinaryExpression(OperatorExpression.MULTIPLY); $break ./ -MultiplicativeExpression ::= MultiplicativeExpression '/' UnaryExpression -/.$putCase consumeBinaryExpression(OperatorExpression.DIVIDE); $break ./ -MultiplicativeExpression ::= MultiplicativeExpression '%' UnaryExpression -/.$putCase consumeBinaryExpression(OperatorExpression.REMAINDER); $break ./ - -AdditiveExpression -> MultiplicativeExpression -AdditiveExpression ::= AdditiveExpression '+' MultiplicativeExpression -/.$putCase consumeBinaryExpression(OperatorExpression.PLUS); $break ./ -AdditiveExpression ::= AdditiveExpression '-' MultiplicativeExpression -/.$putCase consumeBinaryExpression(OperatorExpression.MINUS); $break ./ - -ShiftExpression -> AdditiveExpression -ShiftExpression ::= ShiftExpression '<<' AdditiveExpression -/.$putCase consumeBinaryExpression(OperatorExpression.LEFT_SHIFT); $break ./ -ShiftExpression ::= ShiftExpression '>>' AdditiveExpression -/.$putCase consumeBinaryExpression(OperatorExpression.RIGHT_SHIFT); $break ./ -ShiftExpression ::= ShiftExpression '>>>' AdditiveExpression -/.$putCase consumeBinaryExpression(OperatorExpression.UNSIGNED_RIGHT_SHIFT); $break ./ - -RelationalExpression -> ShiftExpression -RelationalExpression ::= RelationalExpression '<' ShiftExpression -/.$putCase consumeBinaryExpression(OperatorExpression.LESS); $break ./ -RelationalExpression ::= RelationalExpression '>' ShiftExpression -/.$putCase consumeBinaryExpression(OperatorExpression.GREATER); $break ./ -RelationalExpression ::= RelationalExpression '<=' ShiftExpression -/.$putCase consumeBinaryExpression(OperatorExpression.LESS_EQUAL); $break ./ -RelationalExpression ::= RelationalExpression '>=' ShiftExpression -/.$putCase consumeBinaryExpression(OperatorExpression.GREATER_EQUAL); $break ./ -RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType -/.$putCase consumeInstanceOfExpression(OperatorExpression.INSTANCEOF); $break ./ - -EqualityExpression -> RelationalExpression -EqualityExpression ::= EqualityExpression '==' RelationalExpression -/.$putCase consumeEqualityExpression(OperatorExpression.EQUAL_EQUAL); $break ./ -EqualityExpression ::= EqualityExpression '!=' RelationalExpression -/.$putCase consumeEqualityExpression(OperatorExpression.NOT_EQUAL); $break ./ - -AndExpression -> EqualityExpression -AndExpression ::= AndExpression '&' EqualityExpression -/.$putCase consumeBinaryExpression(OperatorExpression.AND); $break ./ - -ExclusiveOrExpression -> AndExpression -ExclusiveOrExpression ::= ExclusiveOrExpression '^' AndExpression -/.$putCase consumeBinaryExpression(OperatorExpression.XOR); $break ./ - -InclusiveOrExpression -> ExclusiveOrExpression -InclusiveOrExpression ::= InclusiveOrExpression '|' ExclusiveOrExpression -/.$putCase consumeBinaryExpression(OperatorExpression.OR); $break ./ - -ConditionalAndExpression -> InclusiveOrExpression -ConditionalAndExpression ::= ConditionalAndExpression '&&' InclusiveOrExpression -/.$putCase consumeBinaryExpression(OperatorExpression.AND_AND); $break ./ - -ConditionalOrExpression -> ConditionalAndExpression -ConditionalOrExpression ::= ConditionalOrExpression '||' ConditionalAndExpression -/.$putCase consumeBinaryExpression(OperatorExpression.OR_OR); $break ./ - -ConditionalExpression -> ConditionalOrExpression -ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' ConditionalExpression -/.$putCase consumeConditionalExpression(OperatorExpression.QUESTIONCOLON) ; $break ./ - -AssignmentExpression -> ConditionalExpression -AssignmentExpression -> Assignment - -Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression -/.$putCase consumeAssignment(); $break ./ - --- this rule is added to parse an array initializer in a assigment and then report a syntax error knowing the exact senario -InvalidArrayInitializerAssignement ::= LeftHandSide AssignmentOperator ArrayInitializer -Assignment ::= InvalidArrayInitializerAssignement -/.$putcase ignoreExpressionAssignment();$break ./ - -LeftHandSide ::= Name -/.$putCase consumeLeftHandSide(); $break ./ -LeftHandSide -> FieldAccess -LeftHandSide -> ArrayAccess - -AssignmentOperator ::= '=' -/.$putCase consumeAssignmentOperator(EQUAL); $break ./ -AssignmentOperator ::= '*=' -/.$putCase consumeAssignmentOperator(MULTIPLY); $break ./ -AssignmentOperator ::= '/=' -/.$putCase consumeAssignmentOperator(DIVIDE); $break ./ -AssignmentOperator ::= '%=' -/.$putCase consumeAssignmentOperator(REMAINDER); $break ./ -AssignmentOperator ::= '+=' -/.$putCase consumeAssignmentOperator(PLUS); $break ./ -AssignmentOperator ::= '-=' -/.$putCase consumeAssignmentOperator(MINUS); $break ./ -AssignmentOperator ::= '<<=' -/.$putCase consumeAssignmentOperator(LEFT_SHIFT); $break ./ -AssignmentOperator ::= '>>=' -/.$putCase consumeAssignmentOperator(RIGHT_SHIFT); $break ./ -AssignmentOperator ::= '>>>=' -/.$putCase consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT); $break ./ -AssignmentOperator ::= '&=' -/.$putCase consumeAssignmentOperator(AND); $break ./ -AssignmentOperator ::= '^=' -/.$putCase consumeAssignmentOperator(XOR); $break ./ -AssignmentOperator ::= '|=' -/.$putCase consumeAssignmentOperator(OR); $break ./ - -Expression -> AssignmentExpression - -ConstantExpression -> Expression - --- The following rules are for optional nonterminals. --- - -PackageDeclarationopt -> $empty -PackageDeclarationopt -> PackageDeclaration - -ClassHeaderExtendsopt ::= $empty -ClassHeaderExtendsopt -> ClassHeaderExtends - -Expressionopt ::= $empty -/.$putCase consumeEmptyExpression(); $break ./ -Expressionopt -> Expression - - ---------------------------------------------------------------------------------------- --- --- The rules below are for optional terminal symbols. An optional comma, --- is only used in the context of an array initializer - It is a --- "syntactic sugar" that otherwise serves no other purpose. By contrast, --- an optional identifier is used in the definition of a break and --- continue statement. When the identifier does not appear, a NULL --- is produced. When the identifier is present, the user should use the --- corresponding TOKEN(i) method. See break statement as an example. --- ---------------------------------------------------------------------------------------- - -,opt -> $empty -,opt -> , - -ImportDeclarationsopt ::= $empty -/.$putCase consumeEmptyImportDeclarationsopt(); $break ./ -ImportDeclarationsopt ::= ImportDeclarations -/.$putCase consumeImportDeclarationsopt(); $break ./ - - -TypeDeclarationsopt ::= $empty -/.$putCase consumeEmptyTypeDeclarationsopt(); $break ./ -TypeDeclarationsopt ::= TypeDeclarations -/.$putCase consumeTypeDeclarationsopt(); $break ./ - -ClassBodyDeclarationsopt ::= $empty -/.$putCase consumeEmptyClassBodyDeclarationsopt(); $break ./ -ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations -/.$putCase consumeClassBodyDeclarationsopt(); $break ./ - -Modifiersopt ::= $empty -/. $putCase consumeDefaultModifiers(); $break ./ -Modifiersopt ::= Modifiers -/.$putCase consumeModifiers(); $break ./ - -BlockStatementsopt ::= $empty -/.$putCase consumeEmptyBlockStatementsopt(); $break ./ -BlockStatementsopt -> BlockStatements - -Dimsopt ::= $empty -/. $putCase consumeEmptyDimsopt(); $break ./ -Dimsopt -> Dims - -ArgumentListopt ::= $empty -/. $putCase consumeEmptyArgumentListopt(); $break ./ -ArgumentListopt -> ArgumentList - -MethodHeaderThrowsClauseopt ::= $empty -MethodHeaderThrowsClauseopt -> MethodHeaderThrowsClause - -FormalParameterListopt ::= $empty -/.$putcase consumeFormalParameterListopt(); $break ./ -FormalParameterListopt -> FormalParameterList - -ClassHeaderImplementsopt ::= $empty -ClassHeaderImplementsopt -> ClassHeaderImplements - -InterfaceMemberDeclarationsopt ::= $empty -/. $putCase consumeEmptyInterfaceMemberDeclarationsopt(); $break ./ -InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations -/. $putCase consumeInterfaceMemberDeclarationsopt(); $break ./ - -NestedType ::= $empty -/.$putCase consumeNestedType(); $break./ - -ForInitopt ::= $empty -/. $putCase consumeEmptyForInitopt(); $break ./ -ForInitopt -> ForInit - -ForUpdateopt ::= $empty -/. $putCase consumeEmptyForUpdateopt(); $break ./ - ForUpdateopt -> ForUpdate - -InterfaceHeaderExtendsopt ::= $empty -InterfaceHeaderExtendsopt -> InterfaceHeaderExtends - -Catchesopt ::= $empty -/. $putCase consumeEmptyCatchesopt(); $break ./ -Catchesopt -> Catches - -ArrayInitializeropt ::= $empty -/. $putCase consumeEmptyArrayInitializeropt(); $break ./ -ArrayInitializeropt -> ArrayInitializer - -/. } -} ./ - ---------------------------------------------------------------------------------------- - -$names - --- BodyMarker ::= '"class Identifier { ... MethodHeader "' - --- void ::= 'void' - -PLUS_PLUS ::= '++' -MINUS_MINUS ::= '--' -EQUAL_EQUAL ::= '==' -LESS_EQUAL ::= '<=' -GREATER_EQUAL ::= '>=' -NOT_EQUAL ::= '!=' -LEFT_SHIFT ::= '<<' -RIGHT_SHIFT ::= '>>' -UNSIGNED_RIGHT_SHIFT ::= '>>>' -PLUS_EQUAL ::= '+=' -MINUS_EQUAL ::= '-=' -MULTIPLY_EQUAL ::= '*=' -DIVIDE_EQUAL ::= '/=' -AND_EQUAL ::= '&=' -OR_EQUAL ::= '|=' -XOR_EQUAL ::= '^=' -REMAINDER_EQUAL ::= '%=' -LEFT_SHIFT_EQUAL ::= '<<=' -RIGHT_SHIFT_EQUAL ::= '>>=' -UNSIGNED_RIGHT_SHIFT_EQUAL ::= '>>>=' -OR_OR ::= '||' -AND_AND ::= '&&' - -PLUS ::= '+' -MINUS ::= '-' -NOT ::= '!' -REMAINDER ::= '%' -XOR ::= '^' -AND ::= '&' -MULTIPLY ::= '*' -OR ::= '|' -TWIDDLE ::= '~' -DIVIDE ::= '/' -GREATER ::= '>' -LESS ::= '<' -LPAREN ::= '(' -RPAREN ::= ')' -LBRACE ::= '{' -RBRACE ::= '}' -LBRACKET ::= '[' -RBRACKET ::= ']' -SEMICOLON ::= ';' -QUESTION ::= '?' -COLON ::= ':' -COMMA ::= ',' -DOT ::= '.' -EQUAL ::= '=' - -$end --- need a carriage return after the $end -*/ -} -protected void ignoreExpressionAssignment() { - // Assignment ::= InvalidArrayInitializerAssignement - // encoded operator would be: intStack[intPtr] - intPtr--; - ArrayInitializer arrayInitializer = (ArrayInitializer) expressionStack[expressionPtr--]; - expressionLengthPtr -- ; - // report a syntax error and abort parsing - problemReporter().arrayConstantsOnlyInArrayInitializers(arrayInitializer.sourceStart, arrayInitializer.sourceEnd); -} -protected void ignoreInterfaceDeclaration() { - // BlockStatement ::= InvalidInterfaceDeclaration - //InterfaceDeclaration ::= Modifiersopt 'interface' 'Identifier' ExtendsInterfacesopt InterfaceHeader InterfaceBody - - // length declarations - int length; - if ((length = astLengthStack[astLengthPtr--]) != 0) { - //there are length declarations - //dispatch according to the type of the declarations - dispatchDeclarationInto(length); - } - - flushAnnotationsDefinedPriorTo(endStatementPosition); - - // report the problem and continue parsing - TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; - typeDecl.bodyEnd = endStatementPosition; - problemReporter().cannotDeclareLocalInterface(typeDecl.name, typeDecl.sourceStart, typeDecl.sourceEnd); - - // mark fields and initializer with local type mark if needed - markFieldsWithLocalType(typeDecl); - - // remove the ast node created in interface header - astPtr--; - // Don't create an astnode for this inner interface, but have to push - // a 0 on the astLengthStack to be consistent with the reduction made - // at the end of the method: - // public void parse(MethodDeclaration md, CompilationUnitDeclaration unit) - pushOnAstLengthStack(0); -} -protected void ignoreInvalidConstructorDeclaration(boolean hasBody) { - // InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody ==> true - // InvalidConstructorDeclaration ::= ConstructorHeader ';' ==> false - - /* - astStack : modifiers arguments throws statements - identifierStack : name - ==> - astStack : MethodDeclaration - identifierStack : - */ - - //must provide a default constructor call when needed - - if (hasBody) { - // pop the position of the { (body of the method) pushed in block decl - intPtr--; - } - - //statements - if (hasBody) { - realBlockPtr--; - } - - int length; - if (hasBody && ((length = astLengthStack[astLengthPtr--]) != 0)) { - astPtr -= length; - } -} -protected void ignoreMethodBody() { - // InterfaceMemberDeclaration ::= InvalidMethodDeclaration - - /* - astStack : modifiers arguments throws statements - identifierStack : type name - intStack : dim dim dim - ==> - astStack : MethodDeclaration - identifierStack : - intStack : - */ - - // pop the position of the { (body of the method) pushed in block decl - intPtr--; - // retrieve end position of method declarator - - //statements - realBlockPtr--; - int length; - if ((length = astLengthStack[astLengthPtr--]) != 0) { - astPtr -= length; - } - - //watch for } that could be given as a unicode ! ( u007D is '}' ) - MethodDeclaration md = (MethodDeclaration) astStack[astPtr]; - md.bodyEnd = endPosition; - md.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); - - // report the problem and continue the parsing - narrowing the problem onto the method - problemReporter().abstractMethodNeedingNoBody(md); -} -public void initialize() { - //positionning the parser for a new compilation unit - //avoiding stack reallocation and all that.... - astPtr = -1; - astLengthPtr = -1; - expressionPtr = -1; - expressionLengthPtr = -1; - identifierPtr = -1; - identifierLengthPtr = -1; - intPtr = -1; - nestedMethod[nestedType = 0] = 0; // need to reset for further reuse - variablesCounter[nestedType] = 0; - dimensions = 0 ; - realBlockPtr = -1; - compilationUnit = null; - referenceContext = null; - endStatementPosition = 0; - - //remove objects from stack too, while the same parser/compiler couple is - //re-used between two compilations .... - - int astLength = astStack.length; - if (noAstNodes.length < astLength){ - noAstNodes = new AstNode[astLength]; - //System.out.println("Resized AST stacks : "+ astLength); - - } - System.arraycopy(noAstNodes, 0, astStack, 0, astLength); - - int expressionLength = expressionStack.length; - if (noExpressions.length < expressionLength){ - noExpressions = new Expression[expressionLength]; - //System.out.println("Resized EXPR stacks : "+ expressionLength); - } - System.arraycopy(noExpressions, 0, expressionStack, 0, expressionLength); - - // reset scanner state - scanner.commentPtr = -1; - scanner.eofPosition = Integer.MAX_VALUE; - - resetModifiers(); - - // recovery - lastCheckPoint = -1; - currentElement = null; - restartRecovery = false; - hasReportedError = false; - recoveredStaticInitializerStart = 0; - lastIgnoredToken = -1; - lastErrorEndPosition = -1; - listLength = 0; -} -public void initializeScanner(){ - this.scanner = new Scanner(false, false, this.problemReporter.options.getNonExternalizedStringLiteralSeverity() != ProblemSeverities.Ignore , this.assertMode); -} -public final static void initTables() throws java.io.IOException { - - final String prefix = FILEPREFIX; - int i = 0; - lhs = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$ - char[] chars = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$ - check_table = new short[chars.length]; - for (int c = chars.length; c-- > 0;) { - check_table[c] = (short) (chars[c] - 32768); - } - asb = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$ - asr = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$ - symbol_index = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$ - action = lhs; -} -public final void jumpOverMethodBody() { - //on diet parsing.....do not buffer method statements + case 351 : // System.out.println("ShiftExpression ::= ShiftExpression RIGHT_SHIFT AdditiveExpression"); + consumeBinaryExpression(OperatorExpression.RIGHT_SHIFT); + break; - //the scanner.diet is reinitialized to false - //automatically by the scanner once it has jumped over - //the statements + case 352 : // System.out.println("ShiftExpression ::= ShiftExpression UNSIGNED_RIGHT_SHIFT AdditiveExpression"); + consumeBinaryExpression(OperatorExpression.UNSIGNED_RIGHT_SHIFT); + break; - if (diet && (dietInt == 0)) - scanner.diet = true; -} -protected void markCurrentMethodWithLocalType() { - if (this.currentElement != null) return; // this is already done in the recovery code - for (int i = this.astPtr; i >= 0; i--) { - AstNode node = this.astStack[i]; - if (node instanceof AbstractMethodDeclaration - || node instanceof TypeDeclaration) { // mark type for now: all fields will be marked when added to this type - node.bits |= AstNode.HasLocalTypeMASK; - return; - } - } - // default to reference context (case of parse method body) - if (this.referenceContext instanceof AbstractMethodDeclaration - || this.referenceContext instanceof TypeDeclaration) { - ((AstNode)this.referenceContext).bits |= AstNode.HasLocalTypeMASK; - } -} -protected void markFieldsWithLocalType(TypeDeclaration type) { - if (type.fields == null || (type.bits & AstNode.HasLocalTypeMASK) == 0) return; - for (int i = 0, length = type.fields.length; i < length; i++) { - type.fields[i].bits |= AstNode.HasLocalTypeMASK; - } -} -/* - * Move checkpoint location (current implementation is moving it by one token) - * - * Answers true if successfully moved checkpoint (i.e. did not attempt to move it - * beyond end of file). - */ -protected boolean moveRecoveryCheckpoint() { - - int pos = lastCheckPoint; - /* reset scanner, and move checkpoint by one token */ - scanner.startPosition = pos; - scanner.currentPosition = pos; - scanner.diet = false; // quit jumping over method bodies - - /* if about to restart, then no need to shift token */ - if (restartRecovery){ - lastIgnoredToken = -1; - return true; - } - - /* protect against shifting on an invalid token */ - lastIgnoredToken = nextIgnoredToken; - nextIgnoredToken = -1; - do { - try { - nextIgnoredToken = scanner.getNextToken(); - if(scanner.currentPosition == scanner.startPosition){ - scanner.currentPosition++; // on fake completion identifier - nextIgnoredToken = -1; - } - - } catch(InvalidInputException e){ - pos = scanner.currentPosition; - } - } while (nextIgnoredToken < 0); - - if (nextIgnoredToken == TokenNameEOF) { // no more recovery after this point - if (currentToken == TokenNameEOF) { // already tried one iteration on EOF - return false; - } - } - lastCheckPoint = scanner.currentPosition; - - /* reset scanner again to previous checkpoint location*/ - scanner.startPosition = pos; - scanner.currentPosition = pos; - scanner.commentPtr = -1; - - return true; - -/* - The following implementation moves the checkpoint location by one line: - - int pos = lastCheckPoint; - // reset scanner, and move checkpoint by one token - scanner.startPosition = pos; - scanner.currentPosition = pos; - scanner.diet = false; // quit jumping over method bodies - - // if about to restart, then no need to shift token - if (restartRecovery){ - lastIgnoredToken = -1; - return true; - } - - // protect against shifting on an invalid token - lastIgnoredToken = nextIgnoredToken; - nextIgnoredToken = -1; - - boolean wasTokenizingWhiteSpace = scanner.tokenizeWhiteSpace; - scanner.tokenizeWhiteSpace = true; - checkpointMove: - do { - try { - nextIgnoredToken = scanner.getNextToken(); - switch(nextIgnoredToken){ - case Scanner.TokenNameWHITESPACE : - if(scanner.getLineNumber(scanner.startPosition) - == scanner.getLineNumber(scanner.currentPosition)){ - nextIgnoredToken = -1; - } - break; - case TokenNameSEMICOLON : - case TokenNameLBRACE : - case TokenNameRBRACE : - break; - case TokenNameIdentifier : - if(scanner.currentPosition == scanner.startPosition){ - scanner.currentPosition++; // on fake completion identifier - } - default: - nextIgnoredToken = -1; - break; - case TokenNameEOF : - break checkpointMove; - } - } catch(InvalidInputException e){ - pos = scanner.currentPosition; - } - } while (nextIgnoredToken < 0); - scanner.tokenizeWhiteSpace = wasTokenizingWhiteSpace; - - if (nextIgnoredToken == TokenNameEOF) { // no more recovery after this point - if (currentToken == TokenNameEOF) { // already tried one iteration on EOF - return false; - } - } - lastCheckPoint = scanner.currentPosition; - - // reset scanner again to previous checkpoint location - scanner.startPosition = pos; - scanner.currentPosition = pos; - scanner.commentPtr = -1; - - return true; -*/ -} -protected MessageSend newMessageSend() { - // '(' ArgumentListopt ')' - // the arguments are on the expression stack - - MessageSend m = new MessageSend(); - int length; - if ((length = expressionLengthStack[expressionLengthPtr--]) != 0) { - expressionPtr -= length; - System.arraycopy( - expressionStack, - expressionPtr + 1, - m.arguments = new Expression[length], - 0, - length); - }; - return m; -} -protected static int ntAction(int state, int sym) { - return action[state + sym]; -} -private final void optimizedConcatNodeLists() { - /*back from a recursive loop. Virtualy group the - astNode into an array using astLengthStack*/ - - /* - * This is a case where you have two sublists into the astStack that you want - * to merge in one list. There is no action required on the astStack. The only - * thing you need to do is merge the two lengths specified on the astStackLength. - * The top two length are for example: - * ... p n - * and you want to result in a list like: - * ... n+p - * This means that the p could be equals to 0 in case there is no astNode pushed - * on the astStack. - * Look at the InterfaceMemberDeclarations for an example. - * This case optimizes the fact that p == 1. - */ - - astLengthStack[--astLengthPtr]++; -} -protected static int original_state(int state) { - return -check(state); -} -/*main loop of the automat -When a rule is reduced, the method consumeRule(int) is called with the number -of the consumed rule. When a terminal is consumed, the method consumeToken(int) is -called in order to remember (when needed) the consumed token */ -// (int)asr[asi(act)] -// name[symbol_index[currentKind]] -protected void parse() { - - hasReportedError = false; - int act = START_STATE; - stateStackTop = -1; - currentToken = getFirstToken(); - ProcessTerminals : for (;;) { - try { - stack[++stateStackTop] = act; - } catch (IndexOutOfBoundsException e) { - int oldStackLength = stack.length; - int oldStack[] = stack; - stack = new int[oldStackLength + StackIncrement]; - System.arraycopy(oldStack, 0, stack, 0, oldStackLength); - stack[stateStackTop] = act; - }; - - act = tAction(act, currentToken); - - if (act == ERROR_ACTION || restartRecovery) { - int errorPos = scanner.currentPosition; - if (!hasReportedError){ - this.reportSyntaxError(ERROR_ACTION, currentToken, stateStackTop); - hasReportedError = true; - } - if (resumeOnSyntaxError()) { - if (act == ERROR_ACTION) lastErrorEndPosition = errorPos; - act = START_STATE; - stateStackTop = -1; - currentToken = getFirstToken(); - continue ProcessTerminals; - } else { - act = ERROR_ACTION; - } break ProcessTerminals; - } - if (act <= NUM_RULES) - stateStackTop--; - else - if (act > ERROR_ACTION) { /* shift-reduce */ - consumeToken(currentToken); - if (currentElement != null) this.recoveryTokenCheck(); - try{ - currentToken = scanner.getNextToken(); - } catch(InvalidInputException e){ - if (!hasReportedError){ - this.problemReporter().scannerError(this, e.getMessage()); - hasReportedError = true; - } - lastCheckPoint = scanner.currentPosition; - restartRecovery = true; - } - act -= ERROR_ACTION; - } else - if (act < ACCEPT_ACTION) { /* shift */ - consumeToken(currentToken); - if (currentElement != null) this.recoveryTokenCheck(); - try{ - currentToken = scanner.getNextToken(); - } catch(InvalidInputException e){ - if (!hasReportedError){ - this.problemReporter().scannerError(this, e.getMessage()); - hasReportedError = true; - } - lastCheckPoint = scanner.currentPosition; - restartRecovery = true; - } - continue ProcessTerminals; - } else - break ProcessTerminals; - - ProcessNonTerminals : do { /* reduce */ - consumeRule(act); - stateStackTop -= (rhs[act] - 1); - act = ntAction(stack[stateStackTop], lhs[act]); - } while (act <= NUM_RULES); - } - endParse(act); -} -// A P I - -public void parse(ConstructorDeclaration cd, CompilationUnitDeclaration unit) { - //only parse the method body of cd - //fill out its statements - - //convert bugs into parse error - - initialize(); - goForConstructorBody(); - nestedMethod[nestedType]++; - - referenceContext = cd; - compilationUnit = unit; - - scanner.resetTo(cd.sourceEnd + 1, cd.declarationSourceEnd); - try { - parse(); - } catch (AbortCompilation ex) { - lastAct = ERROR_ACTION; - } finally { - nestedMethod[nestedType]--; - } - - if (lastAct == ERROR_ACTION) { - initialize(); - return; - } - - //statements - cd.explicitDeclarations = realBlockStack[realBlockPtr--]; - int length; - if ((length = astLengthStack[astLengthPtr--]) != 0) { - astPtr -= length; - if (astStack[astPtr + 1] instanceof ExplicitConstructorCall) - //avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ? - { - System.arraycopy( - astStack, - astPtr + 2, - cd.statements = new Statement[length - 1], - 0, - length - 1); - cd.constructorCall = (ExplicitConstructorCall) astStack[astPtr + 1]; - } else { //need to add explicitly the super(); - System.arraycopy( - astStack, - astPtr + 1, - cd.statements = new Statement[length], - 0, - length); - cd.constructorCall = SuperReference.implicitSuperConstructorCall(); - } - } else { - cd.constructorCall = SuperReference.implicitSuperConstructorCall(); - } - - if (cd.constructorCall.sourceEnd == 0) { - cd.constructorCall.sourceEnd = cd.sourceEnd; - cd.constructorCall.sourceStart = cd.sourceStart; - } -} -// A P I - -public void parse( - Initializer ini, - TypeDeclaration type, - CompilationUnitDeclaration unit) { - //only parse the method body of md - //fill out method statements - - //convert bugs into parse error - - initialize(); - goForInitializer(); - nestedMethod[nestedType]++; - - referenceContext = type; - compilationUnit = unit; - - scanner.resetTo(ini.sourceStart, ini.sourceEnd); // just on the beginning { - try { - parse(); - } catch (AbortCompilation ex) { - lastAct = ERROR_ACTION; - } finally { - nestedMethod[nestedType]--; - } - - if (lastAct == ERROR_ACTION) { - return; - } - - ini.block = ((Initializer) astStack[astPtr]).block; - - // mark initializer with local type if one was found during parsing - if ((type.bits & AstNode.HasLocalTypeMASK) != 0) { - ini.bits |= AstNode.HasLocalTypeMASK; - } -} -// A P I - -public void parse(MethodDeclaration md, CompilationUnitDeclaration unit) { - //only parse the method body of md - //fill out method statements - - //convert bugs into parse error - - if (md.isAbstract()) - return; - if (md.isNative()) - return; - if ((md.modifiers & AccSemicolonBody) != 0) - return; - - initialize(); - goForMethodBody(); - nestedMethod[nestedType]++; - - referenceContext = md; - compilationUnit = unit; - - scanner.resetTo(md.sourceEnd + 1, md.declarationSourceEnd); - // reset the scanner to parser from { down to } - try { - parse(); - } catch (AbortCompilation ex) { - lastAct = ERROR_ACTION; - } finally { - nestedMethod[nestedType]--; - } - - if (lastAct == ERROR_ACTION) { - return; - } - - //refill statements - md.explicitDeclarations = realBlockStack[realBlockPtr--]; - int length; - if ((length = astLengthStack[astLengthPtr--]) != 0) - System.arraycopy( - astStack, - (astPtr -= length) + 1, - md.statements = new Statement[length], - 0, - length); -} -// A P I - -public CompilationUnitDeclaration parse( - ICompilationUnit sourceUnit, - CompilationResult compilationResult) { - // parses a compilation unit and manages error handling (even bugs....) - - CompilationUnitDeclaration unit; - try { - /* automaton initialization */ - initialize(); - goForCompilationUnit(); - - /* scanner initialization */ - scanner.setSource(sourceUnit.getContents()); - - /* unit creation */ - referenceContext = - compilationUnit = - new CompilationUnitDeclaration( - problemReporter, - compilationResult, - scanner.source.length); - /* run automaton */ - parse(); - } finally { - unit = compilationUnit; - compilationUnit = null; // reset parser - } - return unit; -} -// A P I - -public CompilationUnitDeclaration parse( - ICompilationUnit sourceUnit, - CompilationResult compilationResult, - int start, - int end) { - // parses a compilation unit and manages error handling (even bugs....) - - CompilationUnitDeclaration unit; - try { - /* automaton initialization */ - initialize(); - goForCompilationUnit(); - - /* scanner initialization */ - scanner.setSource(sourceUnit.getContents()); - scanner.resetTo(start, end); - /* unit creation */ - referenceContext = - compilationUnit = - new CompilationUnitDeclaration( - problemReporter, - compilationResult, - scanner.source.length); - /* run automaton */ - parse(); - } finally { - unit = compilationUnit; - compilationUnit = null; // reset parser - } - return unit; -} -/** - * Returns this parser's problem reporter initialized with its reference context. - * Also it is assumed that a problem is going to be reported, so initializes - * the compilation result's line positions. - */ -public ProblemReporter problemReporter(){ - if (scanner.recordLineSeparator) { - compilationUnit.compilationResult.lineSeparatorPositions = scanner.getLineEnds(); - } - problemReporter.referenceContext = referenceContext; - return problemReporter; -} -protected void pushIdentifier() { - /*push the consumeToken on the identifier stack. - Increase the total number of identifier in the stack. - identifierPtr points on the next top */ - - try { - identifierStack[++identifierPtr] = scanner.getCurrentIdentifierSource(); - identifierPositionStack[identifierPtr] = - (((long) scanner.startPosition) << 32) + (scanner.currentPosition - 1); - } catch (IndexOutOfBoundsException e) { - /*---stack reallaocation (identifierPtr is correct)---*/ - int oldStackLength = identifierStack.length; - char[][] oldStack = identifierStack; - identifierStack = new char[oldStackLength + 20][]; - System.arraycopy(oldStack, 0, identifierStack, 0, oldStackLength); - identifierStack[identifierPtr] = scanner.getCurrentTokenSource(); - /*identifier position stack*/ - long[] oldPos = identifierPositionStack; - identifierPositionStack = new long[oldStackLength + 20]; - System.arraycopy(oldPos, 0, identifierPositionStack, 0, oldStackLength); - identifierPositionStack[identifierPtr] = - (((long) scanner.startPosition) << 32) + (scanner.currentPosition - 1); - }; - - try { - identifierLengthStack[++identifierLengthPtr] = 1; - } catch (IndexOutOfBoundsException e) { - /*---stack reallocation (identifierLengthPtr is correct)---*/ - int oldStackLength = identifierLengthStack.length; - int oldStack[] = identifierLengthStack; - identifierLengthStack = new int[oldStackLength + 10]; - System.arraycopy(oldStack, 0, identifierLengthStack, 0, oldStackLength); - identifierLengthStack[identifierLengthPtr] = 1; - }; + case 354 : // System.out.println("RelationalExpression ::= RelationalExpression LESS ShiftExpression"); + consumeBinaryExpression(OperatorExpression.LESS); + break; -} -protected void pushIdentifier(int flag) { - /*push a special flag on the stack : - -zero stands for optional Name - -negative number for direct ref to base types. - identifierLengthPtr points on the top */ - - try { - identifierLengthStack[++identifierLengthPtr] = flag; - } catch (IndexOutOfBoundsException e) { - /*---stack reallaocation (identifierLengthPtr is correct)---*/ - int oldStackLength = identifierLengthStack.length; - int oldStack[] = identifierLengthStack; - identifierLengthStack = new int[oldStackLength + 10]; - System.arraycopy(oldStack, 0, identifierLengthStack, 0, oldStackLength); - identifierLengthStack[identifierLengthPtr] = flag; - }; + case 355 : // System.out.println("RelationalExpression ::= RelationalExpression GREATER ShiftExpression"); + consumeBinaryExpression(OperatorExpression.GREATER); + break; -} -protected void pushOnAstLengthStack(int pos) { - try { - astLengthStack[++astLengthPtr] = pos; - } catch (IndexOutOfBoundsException e) { - int oldStackLength = astLengthStack.length; - int[] oldPos = astLengthStack; - astLengthStack = new int[oldStackLength + StackIncrement]; - System.arraycopy(oldPos, 0, astLengthStack, 0, oldStackLength); - astLengthStack[astLengthPtr] = pos; - } -} -protected void pushOnAstStack(AstNode node) { - /*add a new obj on top of the ast stack - astPtr points on the top*/ - - try { - astStack[++astPtr] = node; - } catch (IndexOutOfBoundsException e) { - int oldStackLength = astStack.length; - AstNode[] oldStack = astStack; - astStack = new AstNode[oldStackLength + AstStackIncrement]; - System.arraycopy(oldStack, 0, astStack, 0, oldStackLength); - astPtr = oldStackLength; - astStack[astPtr] = node; - } - - try { - astLengthStack[++astLengthPtr] = 1; - } catch (IndexOutOfBoundsException e) { - int oldStackLength = astLengthStack.length; - int[] oldPos = astLengthStack; - astLengthStack = new int[oldStackLength + AstStackIncrement]; - System.arraycopy(oldPos, 0, astLengthStack, 0, oldStackLength); - astLengthStack[astLengthPtr] = 1; - } -} -protected void pushOnExpressionStack(Expression expr) { - - try { - expressionStack[++expressionPtr] = expr; - } catch (IndexOutOfBoundsException e) { - //expressionPtr is correct - int oldStackLength = expressionStack.length; - Expression[] oldStack = expressionStack; - expressionStack = new Expression[oldStackLength + ExpressionStackIncrement]; - System.arraycopy(oldStack, 0, expressionStack, 0, oldStackLength); - expressionStack[expressionPtr] = expr; - } - - try { - expressionLengthStack[++expressionLengthPtr] = 1; - } catch (IndexOutOfBoundsException e) { - int oldStackLength = expressionLengthStack.length; - int[] oldPos = expressionLengthStack; - expressionLengthStack = new int[oldStackLength + ExpressionStackIncrement]; - System.arraycopy(oldPos, 0, expressionLengthStack, 0, oldStackLength); - expressionLengthStack[expressionLengthPtr] = 1; - } -} -protected void pushOnExpressionStackLengthStack(int pos) { - try { - expressionLengthStack[++expressionLengthPtr] = pos; - } catch (IndexOutOfBoundsException e) { - int oldStackLength = expressionLengthStack.length; - int[] oldPos = expressionLengthStack; - expressionLengthStack = new int[oldStackLength + StackIncrement]; - System.arraycopy(oldPos, 0, expressionLengthStack, 0, oldStackLength); - expressionLengthStack[expressionLengthPtr] = pos; - } -} -protected void pushOnIntStack(int pos) { - - try { - intStack[++intPtr] = pos; - } catch (IndexOutOfBoundsException e) { - //intPtr is correct - int oldStackLength = intStack.length; - int oldStack[] = intStack; - intStack = new int[oldStackLength + StackIncrement]; - System.arraycopy(oldStack, 0, intStack, 0, oldStackLength); - intStack[intPtr] = pos; - } -} -protected static char[] readTable(String filename) throws java.io.IOException { - - //files are located at Parser.class directory - - InputStream stream = new BufferedInputStream(Parser.class.getResourceAsStream(filename)); - if (stream == null) { - throw new java.io.IOException(Util.bind("parser.missingFile",filename)); //$NON-NLS-1$ - } - byte[] bytes = null; - try { - bytes = Util.getInputStreamAsByteArray(stream, -1); - } finally { - try { - stream.close(); - } catch (IOException e) { - } - } - - //minimal integrity check (even size expected) - int length = bytes.length; - if (length % 2 != 0) - throw new java.io.IOException(Util.bind("parser.corruptedFile",filename)); //$NON-NLS-1$ - - // convert bytes into chars - char[] chars = new char[length / 2]; - int i = 0; - int charIndex = 0; - - while (true) { - chars[charIndex++] = (char) (((bytes[i++] & 0xFF) << 8) + (bytes[i++] & 0xFF)); - if (i == length) - break; - } - return chars; -} -/* Token check performed on every token shift once having entered - * recovery mode. - */ -public void recoveryTokenCheck() { - switch (currentToken) { - case TokenNameLBRACE : { - RecoveredElement newElement = - currentElement.updateOnOpeningBrace(scanner.currentPosition - 1); - lastCheckPoint = scanner.currentPosition; - if (newElement != null){ // null means nothing happened - restartRecovery = true; // opening brace detected - currentElement = newElement; - } - break; - } - case TokenNameRBRACE : { - endPosition = this.flushAnnotationsDefinedPriorTo(scanner.currentPosition - 1); - RecoveredElement newElement = - currentElement.updateOnClosingBrace(scanner.startPosition, scanner.currentPosition -1); - lastCheckPoint = scanner.currentPosition; - if (newElement != currentElement){ - currentElement = newElement; - } - } - } -} -protected void reportSyntaxError(int act, int currentKind, int stateStackTop) { - - /* remember current scanner position */ - int startPos = scanner.startPosition; - int currentPos = scanner.currentPosition; - - String[] expectings; - String tokenName = name[symbol_index[currentKind]]; - - //fetch all "accurate" possible terminals that could recover the error - int start, end = start = asi(stack[stateStackTop]); - while (asr[end] != 0) - end++; - int length = end - start; - expectings = new String[length]; - if (length != 0) { - char[] indexes = new char[length]; - System.arraycopy(asr, start, indexes, 0, length); - for (int i = 0; i < length; i++) { - expectings[i] = name[symbol_index[indexes[i]]]; - } - } - - //if the pb is an EOF, try to tell the user that they are some - if (tokenName.equals(UNEXPECTED_EOF)) { - if (!this.checkAndReportBracketAnomalies(problemReporter())) { - char[] tokenSource; - try { - tokenSource = this.scanner.getCurrentTokenSource(); - } catch (Exception e) { - tokenSource = new char[] {}; - } - problemReporter().parseError( - this.scanner.startPosition, - this.scanner.currentPosition - 1, - tokenSource, - tokenName, - expectings); - } - } else { //the next test is HEAVILY grammar DEPENDENT. - if ((length == 2) - && (tokenName.equals(";")) //$NON-NLS-1$ - && (expectings[0] == "++") //$NON-NLS-1$ - && (expectings[1] == "--") //$NON-NLS-1$ - && (expressionPtr > -1)) { - // the ; is not the expected token ==> it ends a statement when an expression is not ended - problemReporter().invalidExpressionAsStatement(expressionStack[expressionPtr]); - } else { - char[] tokenSource; - try { - tokenSource = this.scanner.getCurrentTokenSource(); - } catch (Exception e) { - tokenSource = new char[] {}; - } - problemReporter().parseError( - this.scanner.startPosition, - this.scanner.currentPosition - 1, - tokenSource, - tokenName, - expectings); - this.checkAndReportBracketAnomalies(problemReporter()); - } - } - /* reset scanner where it was */ - scanner.startPosition = startPos; - scanner.currentPosition = currentPos; -} -protected void resetModifiers() { - modifiers = AccDefault; - modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int) - scanner.commentPtr = -1; -} -/* - * Reset context so as to resume to regular parse loop - */ -protected void resetStacks() { - - astPtr = -1; - astLengthPtr = -1; - expressionPtr = -1; - expressionLengthPtr = -1; - identifierPtr = -1; - identifierLengthPtr = -1; - intPtr = -1; - nestedMethod[nestedType = 0] = 0; // need to reset for further reuse - variablesCounter[nestedType] = 0; - dimensions = 0 ; - realBlockStack[realBlockPtr = 0] = 0; - recoveredStaticInitializerStart = 0; - listLength = 0; -} -/* - * Reset context so as to resume to regular parse loop - * If unable to reset for resuming, answers false. - * - * Move checkpoint location, reset internal stacks and - * decide which grammar goal is activated. - */ -protected boolean resumeAfterRecovery() { - - // reset internal stacks - this.resetStacks(); - - /* attempt to move checkpoint location */ - if (!this.moveRecoveryCheckpoint()) return false; - - // only look for headers - if (referenceContext instanceof CompilationUnitDeclaration){ - goForHeaders(); - diet = true; // passed this point, will not consider method bodies - return true; - } - // does not know how to restart - return false; -} -/* - * Syntax error was detected. Will attempt to perform some recovery action in order - * to resume to the regular parse loop. - */ -protected boolean resumeOnSyntaxError() { - - /* request recovery initialization */ - if (currentElement == null){ - currentElement = - this.buildInitialRecoveryState(); // build some recovered elements - } - /* do not investigate deeper in recovery when no recovered element */ - if (currentElement == null) return false; - - /* manual forced recovery restart - after headers */ - if (restartRecovery){ - restartRecovery = false; - } - /* update recovery state with current error state of the parser */ - this.updateRecoveryState(); - - /* attempt to reset state in order to resume to parse loop */ - return this.resumeAfterRecovery(); -} -protected static int tAction(int state, int sym) { - return action[check(state + sym) == sym ? state + sym : state]; -} -public String toString() { - - String s = "identifierStack : char[][] = {"; //$NON-NLS-1$ - for (int i = 0; i <= identifierPtr; i++) { - s = s + "\"" + String.valueOf(identifierStack[i]) + "\","; //$NON-NLS-1$ //$NON-NLS-2$ - }; - s = s + "}\n"; //$NON-NLS-1$ - - s = s + "identierLengthStack : int[] = {"; //$NON-NLS-1$ - for (int i = 0; i <= identifierLengthPtr; i++) { - s = s + identifierLengthStack[i] + ","; //$NON-NLS-1$ - }; - s = s + "}\n"; //$NON-NLS-1$ - - s = s + "astLengthStack : int[] = {"; //$NON-NLS-1$ - for (int i = 0; i <= astLengthPtr; i++) { - s = s + astLengthStack[i] + ","; //$NON-NLS-1$ - }; - s = s + "}\n"; //$NON-NLS-1$ - s = s + "astPtr : int = " + String.valueOf(astPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ - - s = s + "intStack : int[] = {"; //$NON-NLS-1$ - for (int i = 0; i <= intPtr; i++) { - s = s + intStack[i] + ","; //$NON-NLS-1$ - }; - s = s + "}\n"; //$NON-NLS-1$ - - s = s + "expressionLengthStack : int[] = {"; //$NON-NLS-1$ - for (int i = 0; i <= expressionLengthPtr; i++) { - s = s + expressionLengthStack[i] + ","; //$NON-NLS-1$ - }; - s = s + "}\n"; //$NON-NLS-1$ - - s = s + "expressionPtr : int = " + String.valueOf(expressionPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ - - s = s + "\n\n\n----------------Scanner--------------\n" + scanner.toString(); //$NON-NLS-1$ - return s; + case 356 : // System.out.println("RelationalExpression ::= RelationalExpression LESS_EQUAL ShiftExpression"); + consumeBinaryExpression(OperatorExpression.LESS_EQUAL); + break; -} -/* - * Update recovery state based on current parser/scanner state - */ -protected void updateRecoveryState() { - - /* expose parser state to recovery state */ - currentElement.updateFromParserState(); - - /* check and update recovered state based on current token, - this action is also performed when shifting token after recovery - got activated once. - */ - this.recoveryTokenCheck(); -} -protected void updateSourceDeclarationParts(int variableDeclaratorsCounter) { - //fields is a definition of fields that are grouped together like in - //public int[] a, b[], c - //which results into 3 fields. - - FieldDeclaration field; - int endTypeDeclarationPosition = - -1 + astStack[astPtr - variableDeclaratorsCounter + 1].sourceStart; - for (int i = 0; i < variableDeclaratorsCounter - 1; i++) { - //last one is special(see below) - field = (FieldDeclaration) astStack[astPtr - i - 1]; - field.endPart1Position = endTypeDeclarationPosition; - field.endPart2Position = -1 + astStack[astPtr - i].sourceStart; - } - //last one - (field = (FieldDeclaration) astStack[astPtr]).endPart1Position = - endTypeDeclarationPosition; - field.endPart2Position = field.declarationSourceEnd; + case 357 : // System.out.println("RelationalExpression ::= RelationalExpression GREATER_EQUAL ShiftExpression"); + consumeBinaryExpression(OperatorExpression.GREATER_EQUAL); + break; -} -protected void updateSourcePosition(Expression exp) { - //update the source Position of the expression + case 358 : // System.out.println("RelationalExpression ::= RelationalExpression instanceof ReferenceType"); + consumeInstanceOfExpression(OperatorExpression.INSTANCEOF); + break; - //intStack : int int - //--> - //intStack : + case 360 : // System.out.println("EqualityExpression ::= EqualityExpression EQUAL_EQUAL RelationalExpression"); + consumeEqualityExpression(OperatorExpression.EQUAL_EQUAL); + break; - exp.sourceEnd = intStack[intPtr--]; - exp.sourceStart = intStack[intPtr--]; -} + case 361 : // System.out.println("EqualityExpression ::= EqualityExpression NOT_EQUAL RelationalExpression"); + consumeEqualityExpression(OperatorExpression.NOT_EQUAL); + break; + + case 363 : // System.out.println("AndExpression ::= AndExpression AND EqualityExpression"); + consumeBinaryExpression(OperatorExpression.AND); + break; + + case 365 : // System.out.println("ExclusiveOrExpression ::= ExclusiveOrExpression XOR AndExpression"); + consumeBinaryExpression(OperatorExpression.XOR); + break; + + case 367 : // System.out.println("InclusiveOrExpression ::= InclusiveOrExpression OR ExclusiveOrExpression"); + consumeBinaryExpression(OperatorExpression.OR); + break; + + case 369 : // System.out.println("ConditionalAndExpression ::= ConditionalAndExpression AND_AND InclusiveOrExpression"); + consumeBinaryExpression(OperatorExpression.AND_AND); + break; + + case 371 : // System.out.println("ConditionalOrExpression ::= ConditionalOrExpression OR_OR ConditionalAndExpression"); + consumeBinaryExpression(OperatorExpression.OR_OR); + break; + + case 373 : // System.out.println("ConditionalExpression ::= ConditionalOrExpression QUESTION Expression COLON..."); + consumeConditionalExpression(OperatorExpression.QUESTIONCOLON); + break; + + case 376 : // System.out.println("Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression"); + consumeAssignment(); + break; + + case 378 : // System.out.println("Assignment ::= InvalidArrayInitializerAssignement"); + ignoreExpressionAssignment(); + break; + + case 379 : // System.out.println("LeftHandSide ::= Name"); + consumeLeftHandSide(); + break; + + case 382 : // System.out.println("AssignmentOperator ::= EQUAL"); + consumeAssignmentOperator(EQUAL); + break; + + case 383 : // System.out.println("AssignmentOperator ::= MULTIPLY_EQUAL"); + consumeAssignmentOperator(MULTIPLY); + break; + + case 384 : // System.out.println("AssignmentOperator ::= DIVIDE_EQUAL"); + consumeAssignmentOperator(DIVIDE); + break; + + case 385 : // System.out.println("AssignmentOperator ::= REMAINDER_EQUAL"); + consumeAssignmentOperator(REMAINDER); + break; + + case 386 : // System.out.println("AssignmentOperator ::= PLUS_EQUAL"); + consumeAssignmentOperator(PLUS); + break; + + case 387 : // System.out.println("AssignmentOperator ::= MINUS_EQUAL"); + consumeAssignmentOperator(MINUS); + break; + + case 388 : // System.out.println("AssignmentOperator ::= LEFT_SHIFT_EQUAL"); + consumeAssignmentOperator(LEFT_SHIFT); + break; + + case 389 : // System.out.println("AssignmentOperator ::= RIGHT_SHIFT_EQUAL"); + consumeAssignmentOperator(RIGHT_SHIFT); + break; + + case 390 : // System.out.println("AssignmentOperator ::= UNSIGNED_RIGHT_SHIFT_EQUAL"); + consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT); + break; + + case 391 : // System.out.println("AssignmentOperator ::= AND_EQUAL"); + consumeAssignmentOperator(AND); + break; + + case 392 : // System.out.println("AssignmentOperator ::= XOR_EQUAL"); + consumeAssignmentOperator(XOR); + break; + + case 393 : // System.out.println("AssignmentOperator ::= OR_EQUAL"); + consumeAssignmentOperator(OR); + break; + + case 400 : // System.out.println("Expressionopt ::="); + consumeEmptyExpression(); + break; + + case 404 : // System.out.println("ImportDeclarationsopt ::="); + consumeEmptyImportDeclarationsopt(); + break; + + case 405 : // System.out.println("ImportDeclarationsopt ::= ImportDeclarations"); + consumeImportDeclarationsopt(); + break; + + case 406 : // System.out.println("TypeDeclarationsopt ::="); + consumeEmptyTypeDeclarationsopt(); + break; + + case 407 : // System.out.println("TypeDeclarationsopt ::= TypeDeclarations"); + consumeTypeDeclarationsopt(); + break; + + case 408 : // System.out.println("ClassBodyDeclarationsopt ::="); + consumeEmptyClassBodyDeclarationsopt(); + break; + + case 409 : // System.out.println("ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations"); + consumeClassBodyDeclarationsopt(); + break; + + case 410 : // System.out.println("Modifiersopt ::="); + consumeDefaultModifiers(); + break; + + case 411 : // System.out.println("Modifiersopt ::= Modifiers"); + consumeModifiers(); + break; + + case 412 : // System.out.println("BlockStatementsopt ::="); + consumeEmptyBlockStatementsopt(); + break; + + case 414 : // System.out.println("Dimsopt ::="); + consumeEmptyDimsopt(); + break; + + case 416 : // System.out.println("ArgumentListopt ::="); + consumeEmptyArgumentListopt(); + break; + + case 420 : // System.out.println("FormalParameterListopt ::="); + consumeFormalParameterListopt(); + break; + + case 424 : // System.out.println("InterfaceMemberDeclarationsopt ::="); + consumeEmptyInterfaceMemberDeclarationsopt(); + break; + + case 425 : // System.out.println("InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations"); + consumeInterfaceMemberDeclarationsopt(); + break; + + case 426 : // System.out.println("NestedType ::="); + consumeNestedType(); + break; + + case 427 : // System.out.println("ForInitopt ::="); + consumeEmptyForInitopt(); + break; + + case 429 : // System.out.println("ForUpdateopt ::="); + consumeEmptyForUpdateopt(); + break; + + case 433 : // System.out.println("Catchesopt ::="); + consumeEmptyCatchesopt(); + break; + + case 435 : // System.out.println("ArrayInitializeropt ::="); + consumeEmptyArrayInitializeropt(); + break; + + } + } + + protected void consumeSimpleAssertStatement() { + // AssertStatement ::= 'assert' Expression ';' + expressionLengthPtr--; + pushOnAstStack(new AssertStatement(expressionStack[expressionPtr--], intStack[intPtr--])); + } + + protected void consumeSingleTypeImportDeclaration() { + // SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';' + + ImportReference impt = (ImportReference) astStack[astPtr]; + // flush annotations defined prior to import statements + impt.declarationEnd = endStatementPosition; + impt.declarationSourceEnd = this.flushAnnotationsDefinedPriorTo(impt.declarationSourceEnd); + + // recovery + if (currentElement != null) { + lastCheckPoint = impt.declarationSourceEnd + 1; + currentElement = currentElement.add(impt, 0); + lastIgnoredToken = -1; + restartRecovery = true; + // used to avoid branching back into the regular automaton + } + } + protected void consumeSingleTypeImportDeclarationName() { + // SingleTypeImportDeclarationName ::= 'import' Name + /* push an ImportRef build from the last name + stored in the identifier stack. */ + + ImportReference impt; + int length; + char[][] tokens = new char[length = identifierLengthStack[identifierLengthPtr--]][]; + identifierPtr -= length; + long[] positions = new long[length]; + System.arraycopy(identifierStack, identifierPtr + 1, tokens, 0, length); + System.arraycopy(identifierPositionStack, identifierPtr + 1, positions, 0, length); + pushOnAstStack(impt = new ImportReference(tokens, positions, false)); + + if (currentToken == TokenNameSEMICOLON) { + impt.declarationSourceEnd = scanner.currentPosition - 1; + } else { + impt.declarationSourceEnd = impt.sourceEnd; + } + impt.declarationEnd = impt.declarationSourceEnd; + //endPosition is just before the ; + impt.declarationSourceStart = intStack[intPtr--]; + + // recovery + if (currentElement != null) { + lastCheckPoint = impt.declarationSourceEnd + 1; + currentElement = currentElement.add(impt, 0); + lastIgnoredToken = -1; + restartRecovery = true; // used to avoid branching back into the regular automaton + } + } + protected void consumeStatementBreak() { + // BreakStatement ::= 'break' ';' + // break pushs a position on intStack in case there is no label + + pushOnAstStack(new Break(null, intStack[intPtr--], endPosition)); + } + protected void consumeStatementBreakWithLabel() { + // BreakStatement ::= 'break' Identifier ';' + // break pushs a position on intStack in case there is no label + + pushOnAstStack(new Break(identifierStack[identifierPtr--], intStack[intPtr--], endPosition)); + identifierLengthPtr--; + } + protected void consumeStatementCatch() { + // CatchClause ::= 'catch' '(' FormalParameter ')' Block + + //catch are stored directly into the Try + //has they always comes two by two.... + //we remove one entry from the astlengthPtr. + //The construction of the try statement must + //then fetch the catches using 2*i and 2*i + 1 + + astLengthPtr--; + listLength = 0; // reset formalParameter counter (incremented for catch variable) + } + protected void consumeStatementContinue() { + // ContinueStatement ::= 'continue' ';' + // continue pushs a position on intStack in case there is no label + + pushOnAstStack(new Continue(null, intStack[intPtr--], endPosition)); + } + protected void consumeStatementContinueWithLabel() { + // ContinueStatement ::= 'continue' Identifier ';' + // continue pushs a position on intStack in case there is no label + + pushOnAstStack(new Continue(identifierStack[identifierPtr--], intStack[intPtr--], endPosition)); + identifierLengthPtr--; + } + protected void consumeStatementDo() { + // DoStatement ::= 'do' Statement 'while' '(' Expression ')' ';' + + //the 'while' pushes a value on intStack that we need to remove + intPtr--; + + //optimize the push/pop + Statement action = (Statement) astStack[astPtr]; + if (action instanceof EmptyStatement && problemReporter.options.complianceLevel <= CompilerOptions.JDK1_3) { + expressionLengthPtr--; + astStack[astPtr] = new DoStatement(expressionStack[expressionPtr--], null, intStack[intPtr--], endPosition); + } else { + expressionLengthPtr--; + astStack[astPtr] = new DoStatement(expressionStack[expressionPtr--], action, intStack[intPtr--], endPosition); + } + } + protected void consumeStatementExpressionList() { + // StatementExpressionList ::= StatementExpressionList ',' StatementExpression + concatExpressionLists(); + } + protected void consumeStatementFor() { + // ForStatement ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' Statement + // ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' StatementNoShortIf + + int length; + Expression cond = null; + Statement[] inits, updates; + Statement action; + boolean scope = true; + + //statements + astLengthPtr--; // we need to consume it + action = (Statement) astStack[astPtr--]; + if (action instanceof EmptyStatement && problemReporter.options.complianceLevel <= CompilerOptions.JDK1_3) { + action = null; + } + + //updates are on the expresion stack + if ((length = expressionLengthStack[expressionLengthPtr--]) == 0) { + updates = null; + } else { + expressionPtr -= length; + System.arraycopy(expressionStack, expressionPtr + 1, updates = new Statement[length], 0, length); + } + + if (expressionLengthStack[expressionLengthPtr--] != 0) + cond = expressionStack[expressionPtr--]; + + //inits may be on two different stacks + if ((length = astLengthStack[astLengthPtr--]) == 0) { + inits = null; + scope = false; + } else { + if (length == -1) { //on expressionStack + scope = false; + length = expressionLengthStack[expressionLengthPtr--]; + expressionPtr -= length; + System.arraycopy(expressionStack, expressionPtr + 1, inits = new Statement[length], 0, length); + } else { //on astStack + astPtr -= length; + System.arraycopy(astStack, astPtr + 1, inits = new Statement[length], 0, length); + } + }; + if (action instanceof Block) { + pushOnAstStack(new ForStatement(inits, cond, updates, action, scope, intStack[intPtr--], endStatementPosition)); + } else { + pushOnAstStack(new ForStatement(inits, cond, updates, action, scope, intStack[intPtr--], endPosition)); + } + } + protected void consumeStatementIfNoElse() { + // IfThenStatement ::= 'if' '(' Expression ')' Statement + + //optimize the push/pop + expressionLengthPtr--; + Statement thenStatement = (Statement) astStack[astPtr]; + if (thenStatement instanceof Block) { + astStack[astPtr] = new IfStatement(expressionStack[expressionPtr--], thenStatement, intStack[intPtr--], endStatementPosition); + } else if (thenStatement instanceof EmptyStatement) { + astStack[astPtr] = new IfStatement(expressionStack[expressionPtr--], Block.None, intStack[intPtr--], endStatementPosition); + } else { + astStack[astPtr] = new IfStatement(expressionStack[expressionPtr--], thenStatement, intStack[intPtr--], endStatementPosition); + } + } + protected void consumeStatementIfWithElse() { + // IfThenElseStatement ::= 'if' '(' Expression ')' StatementNoShortIf 'else' Statement + // IfThenElseStatementNoShortIf ::= 'if' '(' Expression ')' StatementNoShortIf 'else' StatementNoShortIf + + astLengthPtr--; // optimized {..., Then, Else } ==> {..., If } + expressionLengthPtr--; + //optimize the push/pop + Statement elseStatement = (Statement) astStack[astPtr--]; + Statement thenStatement = (Statement) astStack[astPtr]; + if (elseStatement instanceof EmptyStatement) { + elseStatement = Block.None; + } + if (thenStatement instanceof EmptyStatement) { + thenStatement = Block.None; + } + if (elseStatement instanceof Block) { + astStack[astPtr] = + new IfStatement(expressionStack[expressionPtr--], thenStatement, elseStatement, intStack[intPtr--], endStatementPosition); + } else { + astStack[astPtr] = + new IfStatement(expressionStack[expressionPtr--], thenStatement, elseStatement, intStack[intPtr--], endStatementPosition); + } + } + protected void consumeStatementLabel() { + // LabeledStatement ::= 'Identifier' ':' Statement + // LabeledStatementNoShortIf ::= 'Identifier' ':' StatementNoShortIf + + //optimize push/pop + + Statement stmt = (Statement) astStack[astPtr]; + if (stmt instanceof EmptyStatement) { + astStack[astPtr] = + new LabeledStatement( + identifierStack[identifierPtr], + Block.None, + (int) (identifierPositionStack[identifierPtr--] >>> 32), + endStatementPosition); + } else { + astStack[astPtr] = + new LabeledStatement( + identifierStack[identifierPtr], + stmt, + (int) (identifierPositionStack[identifierPtr--] >>> 32), + endStatementPosition); + } + identifierLengthPtr--; + } + protected void consumeStatementReturn() { + // ReturnStatement ::= 'return' Expressionopt ';' + // return pushs a position on intStack in case there is no expression + + if (expressionLengthStack[expressionLengthPtr--] != 0) { + pushOnAstStack(new ReturnStatement(expressionStack[expressionPtr--], intStack[intPtr--], endPosition)); + } else { + pushOnAstStack(new ReturnStatement(null, intStack[intPtr--], endPosition)); + } + } + protected void consumeStatementSwitch() { + // SwitchStatement ::= 'switch' OpenBlock '(' Expression ')' SwitchBlock + + //OpenBlock just makes the semantic action blockStart() + //the block is inlined but a scope need to be created + //if some declaration occurs. + + int length; + SwitchStatement s = new SwitchStatement(); + expressionLengthPtr--; + s.testExpression = expressionStack[expressionPtr--]; + if ((length = astLengthStack[astLengthPtr--]) != 0) { + astPtr -= length; + System.arraycopy(astStack, astPtr + 1, s.statements = new Statement[length], 0, length); + } + s.explicitDeclarations = realBlockStack[realBlockPtr--]; + pushOnAstStack(s); + intPtr--; // because of OpenBlock + s.sourceStart = intStack[intPtr--]; + s.sourceEnd = endStatementPosition; + } + protected void consumeStatementSynchronized() { + // SynchronizedStatement ::= OnlySynchronized '(' Expression ')' Block + //optimize the push/pop + + if (astLengthStack[astLengthPtr] == 0) { + astLengthStack[astLengthPtr] = 1; + expressionLengthPtr--; + astStack[++astPtr] = + new SynchronizedStatement(expressionStack[expressionPtr--], Block.None, intStack[intPtr--], endStatementPosition); + } else { + expressionLengthPtr--; + astStack[astPtr] = + new SynchronizedStatement( + expressionStack[expressionPtr--], + (Block) astStack[astPtr], + intStack[intPtr--], + endStatementPosition); + } + resetModifiers(); + } + protected void consumeStatementThrow() { + // ThrowStatement ::= 'throw' Expression ';' + expressionLengthPtr--; + pushOnAstStack(new ThrowStatement(expressionStack[expressionPtr--], intStack[intPtr--])); + } + protected void consumeStatementTry(boolean withFinally) { + //TryStatement ::= 'try' Block Catches + //TryStatement ::= 'try' Block Catchesopt Finally + + int length; + TryStatement tryStmt = new TryStatement(); + //finally + if (withFinally) { + astLengthPtr--; + tryStmt.finallyBlock = (Block) astStack[astPtr--]; + } + //catches are handle by two [see statementCatch] + if ((length = astLengthStack[astLengthPtr--]) != 0) { + if (length == 1) { + tryStmt.catchBlocks = new Block[] {(Block) astStack[astPtr--] }; + tryStmt.catchArguments = new Argument[] {(Argument) astStack[astPtr--] }; + } else { + Block[] bks = (tryStmt.catchBlocks = new Block[length]); + Argument[] args = (tryStmt.catchArguments = new Argument[length]); + while (length-- > 0) { + bks[length] = (Block) astStack[astPtr--]; + args[length] = (Argument) astStack[astPtr--]; + } + } + } + //try + astLengthPtr--; + tryStmt.tryBlock = (Block) astStack[astPtr--]; + + //positions + tryStmt.sourceEnd = endStatementPosition; + tryStmt.sourceStart = intStack[intPtr--]; + pushOnAstStack(tryStmt); + } + protected void consumeStatementWhile() { + // WhileStatement ::= 'while' '(' Expression ')' Statement + // WhileStatementNoShortIf ::= 'while' '(' Expression ')' StatementNoShortIf + + Statement action = (Statement) astStack[astPtr]; + expressionLengthPtr--; + if (action instanceof Block) { + astStack[astPtr] = new WhileStatement(expressionStack[expressionPtr--], action, intStack[intPtr--], endStatementPosition); + } else { + if (action instanceof EmptyStatement && problemReporter.options.complianceLevel <= CompilerOptions.JDK1_3) { + astStack[astPtr] = new WhileStatement(expressionStack[expressionPtr--], null, intStack[intPtr--], endPosition); + } else { + astStack[astPtr] = new WhileStatement(expressionStack[expressionPtr--], action, intStack[intPtr--], endPosition); + } + } + } + protected void consumeStaticInitializer() { + // StaticInitializer ::= StaticOnly Block + //push an Initializer + //optimize the push/pop + Initializer initializer = new Initializer((Block) astStack[astPtr], AccStatic); + astStack[astPtr] = initializer; + initializer.sourceEnd = endStatementPosition; + initializer.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); + nestedMethod[nestedType]--; + initializer.declarationSourceStart = intStack[intPtr--]; + + // recovery + if (currentElement != null) { + lastCheckPoint = initializer.declarationSourceEnd; + currentElement = currentElement.add(initializer, 0); + lastIgnoredToken = -1; + } + } + protected void consumeStaticOnly() { + // StaticOnly ::= 'static' + int savedModifiersSourceStart = modifiersSourceStart; + checkAnnotation(); // might update declaration source start + if (modifiersSourceStart >= savedModifiersSourceStart) { + modifiersSourceStart = savedModifiersSourceStart; + } + pushOnIntStack(modifiersSourceStart >= 0 ? modifiersSourceStart : scanner.startPosition); + jumpOverMethodBody(); + nestedMethod[nestedType]++; + resetModifiers(); + + // recovery + if (currentElement != null) { + recoveredStaticInitializerStart = intStack[intPtr]; // remember start position only for static initializers + } + } + protected void consumeSwitchBlock() { + // SwitchBlock ::= '{' SwitchBlockStatements SwitchLabels '}' + concatNodeLists(); + } + protected void consumeSwitchBlockStatement() { + // SwitchBlockStatement ::= SwitchLabels BlockStatements + concatNodeLists(); + } + protected void consumeSwitchBlockStatements() { + // SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement + concatNodeLists(); + } + protected void consumeSwitchLabels() { + // SwitchLabels ::= SwitchLabels SwitchLabel + optimizedConcatNodeLists(); + } + protected void consumeToken(int type) { + /* remember the last consumed value */ + /* try to minimize the number of build values */ + if (scanner.wasNonExternalizedStringLiteral) { + StringLiteral[] literals = this.scanner.nonNLSStrings; + // could not reproduce, but this is the only NPE + // added preventive null check see PR 9035 + if (literals != null) { + for (int i = 0, max = literals.length; i < max; i++) { + problemReporter().nonExternalizedStringLiteral(literals[i]); + } + } + scanner.currentLine = null; + scanner.wasNonExternalizedStringLiteral = false; + } + // clear the commentPtr of the scanner in case we read something different from a modifier + switch (type) { + // case TokenNameabstract : + // case TokenNamestrictfp : + // case TokenNamefinal : + // case TokenNamenative : + // case TokenNameprivate : + // case TokenNameprotected : + // case TokenNamepublic : + // case TokenNametransient : + // case TokenNamevolatile : + case TokenNamestatic : + // case TokenNamesynchronized : + break; + default : + scanner.commentPtr = -1; + } + //System.out.println(scanner.toStringAction(type)); + switch (type) { + case TokenNameIdentifier : + pushIdentifier(); + if (scanner.useAssertAsAnIndentifier) { + long positions = identifierPositionStack[identifierPtr]; + problemReporter().useAssertAsAnIdentifier((int) (positions >>> 32), (int) positions); + } + scanner.commentPtr = -1; + break; + // case TokenNameinterface : + // adjustInterfaceModifiers(); + // //'class' is pushing two int (positions) on the stack ==> 'interface' needs to do it too.... + // pushOnIntStack(scanner.startPosition); + // pushOnIntStack(scanner.currentPosition - 1); + // scanner.commentPtr = -1; + // break; + // case TokenNameabstract : + // checkAndSetModifiers(AccAbstract); + // break; + // case TokenNamestrictfp : + // checkAndSetModifiers(AccStrictfp); + // break; + // case TokenNamefinal : + // checkAndSetModifiers(AccFinal); + // break; + // case TokenNamenative : + // checkAndSetModifiers(AccNative); + // break; + // case TokenNameprivate : + // checkAndSetModifiers(AccPrivate); + // break; + // case TokenNameprotected : + // checkAndSetModifiers(AccProtected); + // break; + // case TokenNamepublic : + // checkAndSetModifiers(AccPublic); + // break; + // case TokenNametransient : + // checkAndSetModifiers(AccTransient); + // break; + // case TokenNamevolatile : + // checkAndSetModifiers(AccVolatile); + // break; + case TokenNamestatic : + checkAndSetModifiers(AccStatic); + break; + // case TokenNamesynchronized : + // this.synchronizedBlockSourceStart = scanner.startPosition; + // checkAndSetModifiers(AccSynchronized); + // break; + // //============================== + // case TokenNamevoid : + // pushIdentifier(-T_void); + // pushOnIntStack(scanner.currentPosition - 1); + // pushOnIntStack(scanner.startPosition); + // scanner.commentPtr = -1; + // break; + // //push a default dimension while void is not part of the primitive + // //declaration baseType and so takes the place of a type without getting into + // //regular type parsing that generates a dimension on intStack + // case TokenNameboolean : + // pushIdentifier(-T_boolean); + // pushOnIntStack(scanner.currentPosition - 1); + // pushOnIntStack(scanner.startPosition); + // scanner.commentPtr = -1; + // break; + // case TokenNamebyte : + // pushIdentifier(-T_byte); + // pushOnIntStack(scanner.currentPosition - 1); + // pushOnIntStack(scanner.startPosition); + // scanner.commentPtr = -1; + // break; + // case TokenNamechar : + // pushIdentifier(-T_char); + // pushOnIntStack(scanner.currentPosition - 1); + // pushOnIntStack(scanner.startPosition); + // scanner.commentPtr = -1; + // break; + // case TokenNamedouble : + // pushIdentifier(-T_double); + // pushOnIntStack(scanner.currentPosition - 1); + // pushOnIntStack(scanner.startPosition); + // scanner.commentPtr = -1; + // break; + // case TokenNamefloat : + // pushIdentifier(-T_float); + // pushOnIntStack(scanner.currentPosition - 1); + // pushOnIntStack(scanner.startPosition); + // scanner.commentPtr = -1; + // break; + // case TokenNameint : + // pushIdentifier(-T_int); + // pushOnIntStack(scanner.currentPosition - 1); + // pushOnIntStack(scanner.startPosition); + // scanner.commentPtr = -1; + // break; + // case TokenNamelong : + // pushIdentifier(-T_long); + // pushOnIntStack(scanner.currentPosition - 1); + // pushOnIntStack(scanner.startPosition); + // scanner.commentPtr = -1; + // break; + // case TokenNameshort : + // pushIdentifier(-T_short); + // pushOnIntStack(scanner.currentPosition - 1); + // pushOnIntStack(scanner.startPosition); + // scanner.commentPtr = -1; + // break; + //============================== + case TokenNameIntegerLiteral : + pushOnExpressionStack(new IntLiteral(scanner.getCurrentTokenSource(), scanner.startPosition, scanner.currentPosition - 1)); + scanner.commentPtr = -1; + break; + case TokenNameLongLiteral : + pushOnExpressionStack(new LongLiteral(scanner.getCurrentTokenSource(), scanner.startPosition, scanner.currentPosition - 1)); + scanner.commentPtr = -1; + break; + case TokenNameFloatingPointLiteral : + pushOnExpressionStack( + new FloatLiteral(scanner.getCurrentTokenSource(), scanner.startPosition, scanner.currentPosition - 1)); + scanner.commentPtr = -1; + break; + case TokenNameDoubleLiteral : + pushOnExpressionStack( + new DoubleLiteral(scanner.getCurrentTokenSource(), scanner.startPosition, scanner.currentPosition - 1)); + scanner.commentPtr = -1; + break; + case TokenNameCharacterLiteral : + pushOnExpressionStack(new CharLiteral(scanner.getCurrentTokenSource(), scanner.startPosition, scanner.currentPosition - 1)); + scanner.commentPtr = -1; + break; + case TokenNameStringLiteral : + StringLiteral stringLiteral = + new StringLiteral(scanner.getCurrentTokenSourceString(), scanner.startPosition, scanner.currentPosition - 1); + pushOnExpressionStack(stringLiteral); + scanner.commentPtr = -1; + break; + case TokenNamefalse : + pushOnExpressionStack(new FalseLiteral(scanner.startPosition, scanner.currentPosition - 1)); + scanner.commentPtr = -1; + break; + case TokenNametrue : + pushOnExpressionStack(new TrueLiteral(scanner.startPosition, scanner.currentPosition - 1)); + break; + case TokenNamenull : + pushOnExpressionStack(new NullLiteral(scanner.startPosition, scanner.currentPosition - 1)); + break; + //============================ + // case TokenNamesuper : + // case TokenNamethis : + // endPosition = scanner.currentPosition - 1; + // pushOnIntStack(scanner.startPosition); + // break; + // case TokenNameassert : + // case TokenNameimport : + // case TokenNamepackage : + // case TokenNamethrow : + case TokenNamenew : + case TokenNamedo : + case TokenNameif : + case TokenNamefor : + case TokenNameswitch : + // case TokenNametry : + case TokenNamewhile : + case TokenNamebreak : + case TokenNamecontinue : + case TokenNamereturn : + case TokenNamecase : + pushOnIntStack(scanner.startPosition); + break; + case TokenNameclass : + pushOnIntStack(scanner.currentPosition - 1); + pushOnIntStack(scanner.startPosition); + break; + case TokenNamedefault : + pushOnIntStack(scanner.startPosition); + pushOnIntStack(scanner.currentPosition - 1); + break; + //let extra semantic action decide when to push + case TokenNameRBRACKET : + case TokenNamePLUS : + case TokenNameMINUS : + case TokenNameNOT : + case TokenNameTWIDDLE : + endPosition = scanner.startPosition; + break; + case TokenNamePLUS_PLUS : + case TokenNameMINUS_MINUS : + endPosition = scanner.startPosition; + endStatementPosition = scanner.currentPosition - 1; + break; + case TokenNameRBRACE : + case TokenNameSEMICOLON : + endStatementPosition = scanner.currentPosition - 1; + endPosition = scanner.startPosition - 1; + //the item is not part of the potential futur expression/statement + break; + // in order to handle ( expression) ////// (cast)expression///// foo(x) + case TokenNameRPAREN : + rParenPos = scanner.currentPosition - 1; // position of the end of right parenthesis (in case of unicode \u0029) lex00101 + break; + case TokenNameLPAREN : + lParenPos = scanner.startPosition; + break; + // case TokenNameQUESTION : + // case TokenNameCOMMA : + // case TokenNameCOLON : + // case TokenNameEQUAL : + // case TokenNameLBRACKET : + // case TokenNameDOT : + // case TokenNameERROR : + // case TokenNameEOF : + // case TokenNamecase : + // case TokenNamecatch : + // case TokenNameelse : + // case TokenNameextends : + // case TokenNamefinally : + // case TokenNameimplements : + // case TokenNamethrows : + // case TokenNameinstanceof : + // case TokenNameEQUAL_EQUAL : + // case TokenNameLESS_EQUAL : + // case TokenNameGREATER_EQUAL : + // case TokenNameNOT_EQUAL : + // case TokenNameLEFT_SHIFT : + // case TokenNameRIGHT_SHIFT : + // case TokenNameUNSIGNED_RIGHT_SHIFT : + // case TokenNamePLUS_EQUAL : + // case TokenNameMINUS_EQUAL : + // case TokenNameMULTIPLY_EQUAL : + // case TokenNameDIVIDE_EQUAL : + // case TokenNameAND_EQUAL : + // case TokenNameOR_EQUAL : + // case TokenNameXOR_EQUAL : + // case TokenNameREMAINDER_EQUAL : + // case TokenNameLEFT_SHIFT_EQUAL : + // case TokenNameRIGHT_SHIFT_EQUAL : + // case TokenNameUNSIGNED_RIGHT_SHIFT_EQUAL : + // case TokenNameOR_OR : + // case TokenNameAND_AND : + // case TokenNameREMAINDER : + // case TokenNameXOR : + // case TokenNameAND : + // case TokenNameMULTIPLY : + // case TokenNameOR : + // case TokenNameDIVIDE : + // case TokenNameGREATER : + // case TokenNameLESS : + } + } + protected void consumeTypeDeclarations() { + // TypeDeclarations ::= TypeDeclarations TypeDeclaration + concatNodeLists(); + } + protected void consumeTypeDeclarationsopt() { + // TypeDeclarationsopt ::= TypeDeclarations + int length; + if ((length = astLengthStack[astLengthPtr--]) != 0) { + astPtr -= length; + System.arraycopy(astStack, astPtr + 1, compilationUnit.types = new TypeDeclaration[length], 0, length); + } + } + protected void consumeTypeImportOnDemandDeclaration() { + // TypeImportOnDemandDeclaration ::= TypeImportOnDemandDeclarationName ';' + + ImportReference impt = (ImportReference) astStack[astPtr]; + // flush annotations defined prior to import statements + impt.declarationEnd = endStatementPosition; + impt.declarationSourceEnd = this.flushAnnotationsDefinedPriorTo(impt.declarationSourceEnd); + + // recovery + if (currentElement != null) { + lastCheckPoint = impt.declarationSourceEnd + 1; + currentElement = currentElement.add(impt, 0); + restartRecovery = true; + lastIgnoredToken = -1; + // used to avoid branching back into the regular automaton + } + } + protected void consumeTypeImportOnDemandDeclarationName() { + // TypeImportOnDemandDeclarationName ::= 'import' Name '.' '*' + /* push an ImportRef build from the last name + stored in the identifier stack. */ + + ImportReference impt; + int length; + char[][] tokens = new char[length = identifierLengthStack[identifierLengthPtr--]][]; + identifierPtr -= length; + long[] positions = new long[length]; + System.arraycopy(identifierStack, identifierPtr + 1, tokens, 0, length); + System.arraycopy(identifierPositionStack, identifierPtr + 1, positions, 0, length); + pushOnAstStack(impt = new ImportReference(tokens, positions, true)); + + if (currentToken == TokenNameSEMICOLON) { + impt.declarationSourceEnd = scanner.currentPosition - 1; + } else { + impt.declarationSourceEnd = impt.sourceEnd; + } + impt.declarationEnd = impt.declarationSourceEnd; + //endPosition is just before the ; + impt.declarationSourceStart = intStack[intPtr--]; + + // recovery + if (currentElement != null) { + lastCheckPoint = impt.declarationSourceEnd + 1; + currentElement = currentElement.add(impt, 0); + lastIgnoredToken = -1; + restartRecovery = true; // used to avoid branching back into the regular automaton + } + } + protected void consumeUnaryExpression(int op) { + // UnaryExpression ::= '+' PushPosition UnaryExpression + // UnaryExpression ::= '-' PushPosition UnaryExpression + // UnaryExpressionNotPlusMinus ::= '~' PushPosition UnaryExpression + // UnaryExpressionNotPlusMinus ::= '!' PushPosition UnaryExpression + + //optimize the push/pop + + //handle manually the -2147483648 while it is not a real + //computation of an - and 2147483648 (notice that 2147483648 + //is Integer.MAX_VALUE+1.....) + //Same for -9223372036854775808L ............ + + //intStack have the position of the operator + + Expression r, exp = expressionStack[expressionPtr]; + if (op == MINUS) { + if ((exp instanceof IntLiteral) && (((IntLiteral) exp).mayRepresentMIN_VALUE())) { + r = expressionStack[expressionPtr] = new IntLiteralMinValue(); + } else { + if ((exp instanceof LongLiteral) && (((LongLiteral) exp).mayRepresentMIN_VALUE())) { + r = expressionStack[expressionPtr] = new LongLiteralMinValue(); + } else { + r = expressionStack[expressionPtr] = new UnaryExpression(exp, op); + } + } + } else { + r = expressionStack[expressionPtr] = new UnaryExpression(exp, op); + } + r.sourceStart = intStack[intPtr--]; + r.sourceEnd = exp.sourceEnd; + } + protected void consumeUnaryExpression(int op, boolean post) { + // PreIncrementExpression ::= '++' PushPosition UnaryExpression + // PreDecrementExpression ::= '--' PushPosition UnaryExpression + + // ++ and -- operators + //optimize the push/pop + + //intStack has the position of the operator when prefix + + Expression leftHandSide = expressionStack[expressionPtr]; + if (leftHandSide instanceof Reference) { + // ++foo()++ is unvalid + if (post) { + expressionStack[expressionPtr] = new PostfixExpression(leftHandSide, IntLiteral.One, op, endStatementPosition); + } else { + expressionStack[expressionPtr] = new PrefixExpression(leftHandSide, IntLiteral.One, op, intStack[intPtr--]); + } + } else { + //the ++ or the -- is NOT taken into account if code gen proceeds + if (!post) { + intPtr--; + } + problemReporter().invalidUnaryExpression(leftHandSide); + } + } + protected void consumeVariableDeclarators() { + // VariableDeclarators ::= VariableDeclarators ',' VariableDeclarator + optimizedConcatNodeLists(); + } + protected void consumeVariableInitializers() { + // VariableInitializers ::= VariableInitializers ',' VariableInitializer + concatExpressionLists(); + } + protected TypeReference copyDims(TypeReference typeRef, int dim) { + return typeRef.copyDims(dim); + } + protected FieldDeclaration createFieldDeclaration(Expression initialization, char[] name, int sourceStart, int sourceEnd) { + return new FieldDeclaration(null, name, sourceStart, sourceEnd); + } + + protected LocalDeclaration createLocalDeclaration(Expression initialization, char[] name, int sourceStart, int sourceEnd) { + return new LocalDeclaration(null, name, sourceStart, sourceEnd); + } + + public CompilationUnitDeclaration dietParse(ICompilationUnit sourceUnit, CompilationResult compilationResult) { + + CompilationUnitDeclaration parsedUnit; + boolean old = diet; + try { + diet = true; + parsedUnit = parse(sourceUnit, compilationResult); + } finally { + diet = old; + } + return parsedUnit; + } + protected void dispatchDeclarationInto(int length) { + /* they are length on astStack that should go into + methods fields constructors lists of the typeDecl + + Return if there is a constructor declaration in the methods declaration */ + + // Looks for the size of each array . + + if (length == 0) + return; + int[] flag = new int[length + 1]; //plus one -- see + int size1 = 0, size2 = 0, size3 = 0; + for (int i = length - 1; i >= 0; i--) { + AstNode astNode = astStack[astPtr--]; + if (astNode instanceof AbstractMethodDeclaration) { + //methods and constructors have been regrouped into one single list + flag[i] = 3; + size2++; + } else { + if (astNode instanceof TypeDeclaration) { + flag[i] = 4; + size3++; + } else { + //field + flag[i] = 1; + size1++; + } + } + } + + //arrays creation + TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; + if (size1 != 0) + typeDecl.fields = new FieldDeclaration[size1]; + if (size2 != 0) + typeDecl.methods = new AbstractMethodDeclaration[size2]; + if (size3 != 0) + typeDecl.memberTypes = new MemberTypeDeclaration[size3]; + + //arrays fill up + size1 = size2 = size3 = 0; + int flagI = flag[0], start = 0; + int length2; + for (int end = 0; end <= length; end++) // the plus one allows to + { + if (flagI != flag[end]) //treat the last element as a ended flag..... + { //array copy + switch (flagI) { + case 1 : + size1 += (length2 = end - start); + System.arraycopy(astStack, astPtr + start + 1, typeDecl.fields, size1 - length2, length2); + break; + case 3 : + size2 += (length2 = end - start); + System.arraycopy(astStack, astPtr + start + 1, typeDecl.methods, size2 - length2, length2); + break; + case 4 : + size3 += (length2 = end - start); + System.arraycopy(astStack, astPtr + start + 1, typeDecl.memberTypes, size3 - length2, length2); + break; + }; + flagI = flag[start = end]; + } + } + + if (typeDecl.memberTypes != null) { + for (int i = typeDecl.memberTypes.length - 1; i >= 0; i--) { + typeDecl.memberTypes[i].enclosingType = typeDecl; + } + } + } + protected CompilationUnitDeclaration endParse(int act) { + + this.lastAct = act; + + if (currentElement != null) { + currentElement.topElement().updateParseTree(); + if (VERBOSE_RECOVERY) { + System.out.print(Util.bind("parser.syntaxRecovery")); //$NON-NLS-1$ + System.out.println("--------------------------"); //$NON-NLS-1$ + System.out.println(compilationUnit); + System.out.println("----------------------------------"); //$NON-NLS-1$ + } + } else { + if (diet & VERBOSE_RECOVERY) { + System.out.print(Util.bind("parser.regularParse")); //$NON-NLS-1$ + System.out.println("--------------------------"); //$NON-NLS-1$ + System.out.println(compilationUnit); + System.out.println("----------------------------------"); //$NON-NLS-1$ + } + } + if (scanner.recordLineSeparator) { + compilationUnit.compilationResult.lineSeparatorPositions = scanner.getLineEnds(); + } + return compilationUnit; + } + /* + * Flush annotations defined prior to a given positions. + * + * Note: annotations are stacked in syntactical order + * + * Either answer given , or the end position of a comment line + * immediately following the (same line) + * + * e.g. + * void foo(){ + * } // end of method foo + */ + + public int flushAnnotationsDefinedPriorTo(int position) { + + int lastAnnotationIndex = scanner.commentPtr; + if (lastAnnotationIndex < 0) + return position; // no comment + + // compute the index of the first obsolete comment + int index = lastAnnotationIndex; + int validCount = 0; + while (index >= 0) { + int commentEnd = scanner.commentStops[index]; + if (commentEnd < 0) + commentEnd = -commentEnd; // negative end position for non-javadoc comments + if (commentEnd <= position) { + break; + } + index--; + validCount++; + } + // if the source at is immediately followed by a line comment, then + // flush this comment and shift to the comment end. + if (validCount > 0) { + int immediateCommentEnd = -scanner.commentStops[index + 1]; //non-javadoc comment end positions are negative + if (immediateCommentEnd > 0) { // only tolerating non-javadoc comments + // is there any line break until the end of the immediate comment ? (thus only tolerating line comment) + immediateCommentEnd--; // comment end in one char too far + if (scanner.getLineNumber(position) == scanner.getLineNumber(immediateCommentEnd)) { + position = immediateCommentEnd; + validCount--; // flush this comment + index++; + } + } + } + // position can be located in the middle of a line break + // this is a bug on Windows platform only. + // http://dev.eclipse.org/bugs/show_bug.cgi?id=10557 + char[] source = scanner.source; + + if ((position < source.length) + && (source[position] == '\r') + && ((position + 1) < source.length) + && (source[position + 1] == '\n')) { + position++; + } + if (index < 0) + return position; // no obsolete comment + + if (validCount > 0) { // move valid comment infos, overriding obsolete comment infos + System.arraycopy(scanner.commentStarts, index + 1, scanner.commentStarts, 0, validCount); + System.arraycopy(scanner.commentStops, index + 1, scanner.commentStops, 0, validCount); + } + scanner.commentPtr = validCount - 1; + return position; + } + public final int getFirstToken() { + // the first token is a virtual token that + // allows the parser to parse several goals + // even if they aren't LALR(1).... + // Goal ::= '++' CompilationUnit + // Goal ::= '--' MethodBody + // Goal ::= '==' ConstructorBody + // -- Initializer + // Goal ::= '>>' StaticInitializer + // Goal ::= '>>' Block + // -- error recovery + // Goal ::= '>>>' Headers + // Goal ::= '*' BlockStatements + // Goal ::= '*' MethodPushModifiersHeader + // -- JDOM + // Goal ::= '&&' FieldDeclaration + // Goal ::= '||' ImportDeclaration + // Goal ::= '?' PackageDeclaration + // Goal ::= '+' TypeDeclaration + // Goal ::= '/' GenericMethodDeclaration + // Goal ::= '&' ClassBodyDeclaration + // -- code snippet + // Goal ::= '%' Expression + // -- completion parser + // Goal ::= '!' ConstructorBlockStatementsopt + // Goal ::= '~' BlockStatementsopt + + return firstToken; + } + /* + * Answer back an array of sourceStart/sourceEnd positions of the available JavaDoc comments. + * The array is a flattened structure: 2*n entries with consecutives start and end positions. + * + * If no JavaDoc is available, then null is answered instead of an empty array. + * + * e.g. { 10, 20, 25, 45 } --> javadoc1 from 10 to 20, javadoc2 from 25 to 45 + */ + public int[] getJavaDocPositions() { + + int javadocCount = 0; + for (int i = 0, max = scanner.commentPtr; i <= max; i++) { + // javadoc only (non javadoc comment have negative end positions.) + if (scanner.commentStops[i] > 0) { + javadocCount++; + } + } + if (javadocCount == 0) + return null; + + int[] positions = new int[2 * javadocCount]; + int index = 0; + for (int i = 0, max = scanner.commentPtr; i <= max; i++) { + // javadoc only (non javadoc comment have negative end positions.) + if (scanner.commentStops[i] > 0) { + positions[index++] = scanner.commentStarts[i]; + positions[index++] = scanner.commentStops[i] - 1; //stop is one over + } + } + return positions; + } + protected void getMethodBodies(CompilationUnitDeclaration unit) { + //fill the methods bodies in order for the code to be generated + + if (unit == null) + return; + + if (unit.ignoreMethodBodies) { + unit.ignoreFurtherInvestigation = true; + return; + // if initial diet parse did not work, no need to dig into method bodies. + } + + //real parse of the method.... + this.scanner.setSource(unit.compilationResult.compilationUnit.getContents()); + if (unit.types != null) { + for (int i = unit.types.length; --i >= 0;) + unit.types[i].parseMethod(this, unit); + } + } + protected TypeReference getTypeReference(int dim) { /* build a Reference on a variable that may be qualified or not + This variable is a type reference and dim will be its dimensions*/ + + int length; + TypeReference ref; + if ((length = identifierLengthStack[identifierLengthPtr--]) == 1) { + // single variable reference + if (dim == 0) { + ref = new SingleTypeReference(identifierStack[identifierPtr], identifierPositionStack[identifierPtr--]); + } else { + ref = new ArrayTypeReference(identifierStack[identifierPtr], dim, identifierPositionStack[identifierPtr--]); + ref.sourceEnd = endPosition; + } + } else { + if (length < 0) { //flag for precompiled type reference on base types + ref = TypeReference.baseTypeReference(-length, dim); + ref.sourceStart = intStack[intPtr--]; + if (dim == 0) { + ref.sourceEnd = intStack[intPtr--]; + } else { + intPtr--; + ref.sourceEnd = endPosition; + } + } else { //Qualified variable reference + char[][] tokens = new char[length][]; + identifierPtr -= length; + long[] positions = new long[length]; + System.arraycopy(identifierStack, identifierPtr + 1, tokens, 0, length); + System.arraycopy(identifierPositionStack, identifierPtr + 1, positions, 0, length); + if (dim == 0) { + ref = new QualifiedTypeReference(tokens, positions); + } else { + ref = new ArrayQualifiedTypeReference(tokens, dim, positions); + ref.sourceEnd = endPosition; + } + } + }; + return ref; + } + protected Expression getTypeReference(Expression exp) { + + exp.bits &= ~AstNode.RestrictiveFlagMASK; + exp.bits |= TYPE; + return exp; + } + protected NameReference getUnspecifiedReference() { + /* build a (unspecified) NameReference which may be qualified*/ + + int length; + NameReference ref; + if ((length = identifierLengthStack[identifierLengthPtr--]) == 1) + // single variable reference + ref = new SingleNameReference(identifierStack[identifierPtr], identifierPositionStack[identifierPtr--]); + else + //Qualified variable reference + { + char[][] tokens = new char[length][]; + identifierPtr -= length; + System.arraycopy(identifierStack, identifierPtr + 1, tokens, 0, length); + ref = new QualifiedNameReference(tokens, (int) (identifierPositionStack[identifierPtr + 1] >> 32), // sourceStart + (int) identifierPositionStack[identifierPtr + length]); // sourceEnd + }; + return ref; + } + protected NameReference getUnspecifiedReferenceOptimized() { + /* build a (unspecified) NameReference which may be qualified + The optimization occurs for qualified reference while we are + certain in this case the last item of the qualified name is + a field access. This optimization is IMPORTANT while it results + that when a NameReference is build, the type checker should always + look for that it is not a type reference */ + + int length; + NameReference ref; + if ((length = identifierLengthStack[identifierLengthPtr--]) == 1) { + // single variable reference + ref = new SingleNameReference(identifierStack[identifierPtr], identifierPositionStack[identifierPtr--]); + ref.bits &= ~AstNode.RestrictiveFlagMASK; + ref.bits |= LOCAL | FIELD; + return ref; + } + + //Qualified-variable-reference + //In fact it is variable-reference DOT field-ref , but it would result in a type + //conflict tha can be only reduce by making a superclass (or inetrface ) between + //nameReference and FiledReference or putting FieldReference under NameReference + //or else..........This optimisation is not really relevant so just leave as it is + + char[][] tokens = new char[length][]; + identifierPtr -= length; + System.arraycopy(identifierStack, identifierPtr + 1, tokens, 0, length); + ref = new QualifiedNameReference(tokens, (int) (identifierPositionStack[identifierPtr + 1] >> 32), // sourceStart + (int) identifierPositionStack[identifierPtr + length]); // sourceEnd + ref.bits &= ~AstNode.RestrictiveFlagMASK; + ref.bits |= LOCAL | FIELD; + return ref; + } + public void goForBlockStatementsOrMethodHeaders() { + //tells the scanner to go for block statements or method headers parsing + + firstToken = TokenNameMULTIPLY; + scanner.recordLineSeparator = false; + } + public void goForClassBodyDeclarations() { + //tells the scanner to go for any body declarations parsing + + firstToken = TokenNameAND; + scanner.recordLineSeparator = true; + } + public void goForCompilationUnit() { + //tells the scanner to go for compilation unit parsing + + firstToken = TokenNamePLUS_PLUS; + scanner.linePtr = -1; + scanner.recordLineSeparator = true; + scanner.currentLine = null; + scanner.lines = new ArrayList(); + } + public void goForConstructorBody() { + //tells the scanner to go for compilation unit parsing + + firstToken = TokenNameEQUAL_EQUAL; + scanner.recordLineSeparator = false; + } + public void goForExpression() { + //tells the scanner to go for an expression parsing + + firstToken = TokenNameREMAINDER; + scanner.recordLineSeparator = false; + } + public void goForFieldDeclaration() { + //tells the scanner to go for field declaration parsing + + firstToken = TokenNameAND_AND; + scanner.recordLineSeparator = true; + } + public void goForGenericMethodDeclaration() { + //tells the scanner to go for generic method declarations parsing + + firstToken = TokenNameDIVIDE; + scanner.recordLineSeparator = true; + } + public void goForHeaders() { + //tells the scanner to go for headers only parsing + + firstToken = TokenNameUNSIGNED_RIGHT_SHIFT; + scanner.recordLineSeparator = true; + } + public void goForImportDeclaration() { + //tells the scanner to go for import declaration parsing + + firstToken = TokenNameOR_OR; + scanner.recordLineSeparator = true; + } + public void goForInitializer() { + //tells the scanner to go for initializer parsing + + firstToken = TokenNameRIGHT_SHIFT; + scanner.recordLineSeparator = false; + } + public void goForMethodBody() { + //tells the scanner to go for method body parsing + + firstToken = TokenNameMINUS_MINUS; + scanner.recordLineSeparator = false; + } + public void goForPackageDeclaration() { + //tells the scanner to go for package declaration parsing + + firstToken = TokenNameQUESTION; + scanner.recordLineSeparator = true; + } + public void goForTypeDeclaration() { + //tells the scanner to go for type (interface or class) declaration parsing + + firstToken = TokenNamePLUS; + scanner.recordLineSeparator = true; + } + public final static void grammar() { + /* + --main options + %options ACTION, AN=JavaAction.java, GP=java, + %options FILE-PREFIX=java, ESCAPE=$, PREFIX=TokenName, OUTPUT-SIZE=125 , + %options NOGOTO-DEFAULT, SINGLE-PRODUCTIONS, LALR=1 , TABLE=TIME , + + --error recovering options..... + %options ERROR_MAPS + + --grammar understanding options + %options first follow + %options TRACE=FULL , + %options VERBOSE + + --Usefull macros helping reading/writing semantic actions + $Define + $putCase + /. case $rule_number : // System.out.println("$rule_text"); + ./ + + $break + /. + break ; + ./ + + -- here it starts really ------------------------------------------ + $Terminals + + Identifier + + abstract assert boolean break byte case catch char class + continue default do double else extends false final finally float + for if implements import instanceof int + interface long native new null package private + protected public return short static strictfp super switch + synchronized this throw throws transient true try void + volatile while + + IntegerLiteral + LongLiteral + FloatingPointLiteral + DoubleLiteral + CharacterLiteral + StringLiteral + + PLUS_PLUS + MINUS_MINUS + EQUAL_EQUAL + LESS_EQUAL + GREATER_EQUAL + NOT_EQUAL + LEFT_SHIFT + RIGHT_SHIFT + UNSIGNED_RIGHT_SHIFT + PLUS_EQUAL + MINUS_EQUAL + MULTIPLY_EQUAL + DIVIDE_EQUAL + AND_EQUAL + OR_EQUAL + XOR_EQUAL + REMAINDER_EQUAL + LEFT_SHIFT_EQUAL + RIGHT_SHIFT_EQUAL + UNSIGNED_RIGHT_SHIFT_EQUAL + OR_OR + AND_AND + PLUS + MINUS + NOT + REMAINDER + XOR + AND + MULTIPLY + OR + TWIDDLE + DIVIDE + GREATER + LESS + LPAREN + RPAREN + LBRACE + RBRACE + LBRACKET + RBRACKET + SEMICOLON + QUESTION + COLON + COMMA + DOT + EQUAL + + -- BodyMarker + + $Alias + + '++' ::= PLUS_PLUS + '--' ::= MINUS_MINUS + '==' ::= EQUAL_EQUAL + '<=' ::= LESS_EQUAL + '>=' ::= GREATER_EQUAL + '!=' ::= NOT_EQUAL + '<<' ::= LEFT_SHIFT + '>>' ::= RIGHT_SHIFT + '>>>' ::= UNSIGNED_RIGHT_SHIFT + '+=' ::= PLUS_EQUAL + '-=' ::= MINUS_EQUAL + '*=' ::= MULTIPLY_EQUAL + '/=' ::= DIVIDE_EQUAL + '&=' ::= AND_EQUAL + '|=' ::= OR_EQUAL + '^=' ::= XOR_EQUAL + '%=' ::= REMAINDER_EQUAL + '<<=' ::= LEFT_SHIFT_EQUAL + '>>=' ::= RIGHT_SHIFT_EQUAL + '>>>=' ::= UNSIGNED_RIGHT_SHIFT_EQUAL + '||' ::= OR_OR + '&&' ::= AND_AND + + '+' ::= PLUS + '-' ::= MINUS + '!' ::= NOT + '%' ::= REMAINDER + '^' ::= XOR + '&' ::= AND + '*' ::= MULTIPLY + '|' ::= OR + '~' ::= TWIDDLE + '/' ::= DIVIDE + '>' ::= GREATER + '<' ::= LESS + '(' ::= LPAREN + ')' ::= RPAREN + '{' ::= LBRACE + '}' ::= RBRACE + '[' ::= LBRACKET + ']' ::= RBRACKET + ';' ::= SEMICOLON + '?' ::= QUESTION + ':' ::= COLON + ',' ::= COMMA + '.' ::= DOT + '=' ::= EQUAL + + $Start + Goal + + $Rules + + /. // This method is part of an automatic generation : do NOT edit-modify + protected void consumeRule(int act) { + switch ( act ) { + ./ + + + + Goal ::= '++' CompilationUnit + Goal ::= '--' MethodBody + Goal ::= '==' ConstructorBody + -- Initializer + Goal ::= '>>' StaticInitializer + Goal ::= '>>' Initializer + -- error recovery + Goal ::= '>>>' Headers + Goal ::= '*' BlockStatements + Goal ::= '*' MethodPushModifiersHeader + Goal ::= '*' CatchHeader + -- JDOM + Goal ::= '&&' FieldDeclaration + Goal ::= '||' ImportDeclaration + Goal ::= '?' PackageDeclaration + Goal ::= '+' TypeDeclaration + Goal ::= '/' GenericMethodDeclaration + Goal ::= '&' ClassBodyDeclaration + -- code snippet + Goal ::= '%' Expression + -- completion parser + Goal ::= '!' ConstructorBlockStatementsopt + Goal ::= '~' BlockStatementsopt + + Literal -> IntegerLiteral + Literal -> LongLiteral + Literal -> FloatingPointLiteral + Literal -> DoubleLiteral + Literal -> CharacterLiteral + Literal -> StringLiteral + Literal -> null + Literal -> BooleanLiteral + BooleanLiteral -> true + BooleanLiteral -> false + + ------------------------------------------------------------- + ------------------------------------------------------------- + --a Type results in both a push of its dimension(s) and its name(s). + + Type ::= PrimitiveType + /.$putCase consumePrimitiveType(); $break ./ + Type -> ReferenceType + + PrimitiveType -> NumericType + NumericType -> IntegralType + NumericType -> FloatingPointType + + PrimitiveType -> 'boolean' + PrimitiveType -> 'void' + IntegralType -> 'byte' + IntegralType -> 'short' + IntegralType -> 'int' + IntegralType -> 'long' + IntegralType -> 'char' + FloatingPointType -> 'float' + FloatingPointType -> 'double' + + ReferenceType ::= ClassOrInterfaceType + /.$putCase consumeReferenceType(); $break ./ + ReferenceType -> ArrayType -- here a push of dimensions is done, that explains the two previous push 0 + + ClassOrInterfaceType -> Name + + -- + -- These rules have been rewritten to avoid some conflicts introduced + -- by adding the 1.1 features + -- + -- ArrayType ::= PrimitiveType '[' ']' + -- ArrayType ::= Name '[' ']' + -- ArrayType ::= ArrayType '[' ']' + -- + + ArrayType ::= PrimitiveType Dims + ArrayType ::= Name Dims + + ClassType -> ClassOrInterfaceType + + + -------------------------------------------------------------- + -------------------------------------------------------------- + + Name -> SimpleName + Name -> QualifiedName + + SimpleName -> 'Identifier' + + QualifiedName ::= Name '.' SimpleName + /.$putCase consumeQualifiedName(); $break ./ + + CompilationUnit ::= EnterCompilationUnit PackageDeclarationopt ImportDeclarationsopt TypeDeclarationsopt + /.$putCase consumeCompilationUnit(); $break ./ + + EnterCompilationUnit ::= $empty + /.$putCase consumeEnterCompilationUnit(); $break ./ + + Headers -> Header + Headers ::= Headers Header + + Header -> ImportDeclaration + Header -> PackageDeclaration + Header -> ClassHeader + Header -> InterfaceHeader + Header -> StaticInitializer + Header -> MethodHeader + Header -> ConstructorHeader + Header -> FieldDeclaration + Header -> AllocationHeader + + CatchHeader ::= 'catch' '(' FormalParameter ')' '{' + /.$putCase consumeCatchHeader(); $break ./ + + ImportDeclarations -> ImportDeclaration + ImportDeclarations ::= ImportDeclarations ImportDeclaration + /.$putCase consumeImportDeclarations(); $break ./ + + TypeDeclarations -> TypeDeclaration + TypeDeclarations ::= TypeDeclarations TypeDeclaration + /.$putCase consumeTypeDeclarations(); $break ./ + + PackageDeclaration ::= PackageDeclarationName ';' + /.$putCase consumePackageDeclaration(); $break ./ + + PackageDeclarationName ::= 'package' Name + /.$putCase consumePackageDeclarationName(); $break ./ + + ImportDeclaration -> SingleTypeImportDeclaration + ImportDeclaration -> TypeImportOnDemandDeclaration + + SingleTypeImportDeclaration ::= SingleTypeImportDeclarationName ';' + /.$putCase consumeSingleTypeImportDeclaration(); $break ./ + + SingleTypeImportDeclarationName ::= 'import' Name + /.$putCase consumeSingleTypeImportDeclarationName(); $break ./ + + TypeImportOnDemandDeclaration ::= TypeImportOnDemandDeclarationName ';' + /.$putCase consumeTypeImportOnDemandDeclaration(); $break ./ + + TypeImportOnDemandDeclarationName ::= 'import' Name '.' '*' + /.$putCase consumeTypeImportOnDemandDeclarationName(); $break ./ + + TypeDeclaration -> ClassDeclaration + TypeDeclaration -> InterfaceDeclaration + -- this declaration in part of a list od declaration and we will + -- use and optimized list length calculation process + -- thus we decrement the number while it will be incremend..... + TypeDeclaration ::= ';' + /. $putCase consumeEmptyTypeDeclaration(); $break ./ + + --18.7 Only in the LALR(1) Grammar + + Modifiers ::= Modifier + Modifiers ::= Modifiers Modifier + + Modifier -> 'public' + Modifier -> 'protected' + Modifier -> 'private' + Modifier -> 'static' + Modifier -> 'abstract' + Modifier -> 'final' + Modifier -> 'native' + Modifier -> 'synchronized' + Modifier -> 'transient' + Modifier -> 'volatile' + Modifier -> 'strictfp' + + --18.8 Productions from 8: Class Declarations + --ClassModifier ::= + -- 'abstract' + -- | 'final' + -- | 'public' + --18.8.1 Productions from 8.1: Class Declarations + + ClassDeclaration ::= ClassHeader ClassBody + /.$putCase consumeClassDeclaration(); $break ./ + + ClassHeader ::= ClassHeaderName ClassHeaderExtendsopt ClassHeaderImplementsopt + /.$putCase consumeClassHeader(); $break ./ + + ClassHeaderName ::= Modifiersopt 'class' 'Identifier' + /.$putCase consumeClassHeaderName(); $break ./ + + ClassHeaderExtends ::= 'extends' ClassType + /.$putCase consumeClassHeaderExtends(); $break ./ + + ClassHeaderImplements ::= 'implements' InterfaceTypeList + /.$putCase consumeClassHeaderImplements(); $break ./ + + InterfaceTypeList -> InterfaceType + InterfaceTypeList ::= InterfaceTypeList ',' InterfaceType + /.$putCase consumeInterfaceTypeList(); $break ./ + + InterfaceType ::= ClassOrInterfaceType + /.$putCase consumeInterfaceType(); $break ./ + + ClassBody ::= '{' ClassBodyDeclarationsopt '}' + + ClassBodyDeclarations ::= ClassBodyDeclaration + ClassBodyDeclarations ::= ClassBodyDeclarations ClassBodyDeclaration + /.$putCase consumeClassBodyDeclarations(); $break ./ + + ClassBodyDeclaration -> ClassMemberDeclaration + ClassBodyDeclaration -> StaticInitializer + ClassBodyDeclaration -> ConstructorDeclaration + --1.1 feature + ClassBodyDeclaration ::= Diet NestedMethod Block + /.$putCase consumeClassBodyDeclaration(); $break ./ + Diet ::= $empty + /.$putCase consumeDiet(); $break./ + + Initializer ::= Diet NestedMethod Block + /.$putCase consumeClassBodyDeclaration(); $break ./ + + ClassMemberDeclaration -> FieldDeclaration + ClassMemberDeclaration -> MethodDeclaration + --1.1 feature + ClassMemberDeclaration -> ClassDeclaration + --1.1 feature + ClassMemberDeclaration -> InterfaceDeclaration + + -- Empty declarations are not valid Java ClassMemberDeclarations. + -- However, since the current (2/14/97) Java compiler accepts them + -- (in fact, some of the official tests contain this erroneous + -- syntax) + + GenericMethodDeclaration -> MethodDeclaration + GenericMethodDeclaration -> ConstructorDeclaration + + ClassMemberDeclaration ::= ';' + /.$putCase consumeEmptyClassMemberDeclaration(); $break./ + + --18.8.2 Productions from 8.3: Field Declarations + --VariableModifier ::= + -- 'public' + -- | 'protected' + -- | 'private' + -- | 'static' + -- | 'final' + -- | 'transient' + -- | 'volatile' + + FieldDeclaration ::= Modifiersopt Type VariableDeclarators ';' + /.$putCase consumeFieldDeclaration(); $break ./ + + VariableDeclarators -> VariableDeclarator + VariableDeclarators ::= VariableDeclarators ',' VariableDeclarator + /.$putCase consumeVariableDeclarators(); $break ./ + + VariableDeclarator ::= VariableDeclaratorId EnterVariable ExitVariableWithoutInitialization + + VariableDeclarator ::= VariableDeclaratorId EnterVariable '=' ForceNoDiet VariableInitializer RestoreDiet ExitVariableWithInitialization + + EnterVariable ::= $empty + /.$putCase consumeEnterVariable(); $break ./ + + ExitVariableWithInitialization ::= $empty + /.$putCase consumeExitVariableWithInitialization(); $break ./ + + ExitVariableWithoutInitialization ::= $empty + /.$putCase consumeExitVariableWithoutInitialization(); $break ./ + + ForceNoDiet ::= $empty + /.$putCase consumeForceNoDiet(); $break ./ + RestoreDiet ::= $empty + /.$putCase consumeRestoreDiet(); $break ./ + + VariableDeclaratorId ::= 'Identifier' Dimsopt + + VariableInitializer -> Expression + VariableInitializer -> ArrayInitializer + + --18.8.3 Productions from 8.4: Method Declarations + --MethodModifier ::= + -- 'public' + -- | 'protected' + -- | 'private' + -- | 'static' + -- | 'abstract' + -- | 'final' + -- | 'native' + -- | 'synchronized' + -- + + MethodDeclaration -> AbstractMethodDeclaration + MethodDeclaration ::= MethodHeader MethodBody + /.$putCase // set to true to consume a method with a body + consumeMethodDeclaration(true); $break ./ + + AbstractMethodDeclaration ::= MethodHeader ';' + /.$putCase // set to false to consume a method without body + consumeMethodDeclaration(false); $break ./ + + MethodHeader ::= MethodHeaderName MethodHeaderParameters MethodHeaderExtendedDims MethodHeaderThrowsClauseopt + /.$putCase consumeMethodHeader(); $break ./ + + MethodPushModifiersHeader ::= MethodPushModifiersHeaderName MethodHeaderParameters MethodHeaderExtendedDims MethodHeaderThrowsClauseopt + /.$putCase consumeMethodHeader(); $break ./ + + MethodPushModifiersHeaderName ::= Modifiers Type PushModifiers 'Identifier' '(' + /.$putCase consumeMethodPushModifiersHeaderName(); $break ./ + + MethodPushModifiersHeaderName ::= Type PushModifiers 'Identifier' '(' + /.$putCase consumeMethodPushModifiersHeaderName(); $break ./ + + MethodHeaderName ::= Modifiersopt Type 'Identifier' '(' + /.$putCase consumeMethodHeaderName(); $break ./ + + MethodHeaderParameters ::= FormalParameterListopt ')' + /.$putCase consumeMethodHeaderParameters(); $break ./ + + MethodHeaderExtendedDims ::= Dimsopt + /.$putCase consumeMethodHeaderExtendedDims(); $break ./ + + MethodHeaderThrowsClause ::= 'throws' ClassTypeList + /.$putCase consumeMethodHeaderThrowsClause(); $break ./ + + ConstructorHeader ::= ConstructorHeaderName MethodHeaderParameters MethodHeaderThrowsClauseopt + /.$putCase consumeConstructorHeader(); $break ./ + + ConstructorHeaderName ::= Modifiersopt 'Identifier' '(' + /.$putCase consumeConstructorHeaderName(); $break ./ + + FormalParameterList -> FormalParameter + FormalParameterList ::= FormalParameterList ',' FormalParameter + /.$putCase consumeFormalParameterList(); $break ./ + + --1.1 feature + FormalParameter ::= Modifiersopt Type VariableDeclaratorId + /.$putCase // the boolean is used to know if the modifiers should be reset + consumeFormalParameter(); $break ./ + + ClassTypeList -> ClassTypeElt + ClassTypeList ::= ClassTypeList ',' ClassTypeElt + /.$putCase consumeClassTypeList(); $break ./ + + ClassTypeElt ::= ClassType + /.$putCase consumeClassTypeElt(); $break ./ + + + MethodBody ::= NestedMethod '{' BlockStatementsopt '}' + /.$putCase consumeMethodBody(); $break ./ + + NestedMethod ::= $empty + /.$putCase consumeNestedMethod(); $break ./ + + --18.8.4 Productions from 8.5: Static Initializers + + StaticInitializer ::= StaticOnly Block + /.$putCase consumeStaticInitializer(); $break./ + + StaticOnly ::= 'static' + /.$putCase consumeStaticOnly(); $break ./ + + --18.8.5 Productions from 8.6: Constructor Declarations + --ConstructorModifier ::= + -- 'public' + -- | 'protected' + -- | 'private' + -- + -- + ConstructorDeclaration ::= ConstructorHeader ConstructorBody + /.$putCase consumeConstructorDeclaration() ; $break ./ + + -- These rules are added to be able to parse constructors with no body + ConstructorDeclaration ::= ConstructorHeader ';' + /.$putCase consumeInvalidConstructorDeclaration() ; $break ./ + + -- the rules ExplicitConstructorInvocationopt has been expanded + -- in the rule below in order to make the grammar lalr(1). + -- ConstructorBody ::= '{' ExplicitConstructorInvocationopt BlockStatementsopt '}' + -- Other inlining has occured into the next rule too.... + + ConstructorBody ::= NestedMethod '{' ConstructorBlockStatementsopt '}' + /.$putCase consumeConstructorBody(); $break ./ + + ConstructorBlockStatementsopt -> BlockStatementsopt + + ConstructorBlockStatementsopt -> ExplicitConstructorInvocation + + ConstructorBlockStatementsopt ::= ExplicitConstructorInvocation BlockStatements + /.$putCase consumeConstructorBlockStatements(); $break ./ + + ExplicitConstructorInvocation ::= 'this' '(' ArgumentListopt ')' ';' + /.$putCase consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.This); $break ./ + + ExplicitConstructorInvocation ::= 'super' '(' ArgumentListopt ')' ';' + /.$putCase consumeExplicitConstructorInvocation(0,ExplicitConstructorCall.Super); $break ./ + + --1.1 feature + ExplicitConstructorInvocation ::= Primary '.' 'super' '(' ArgumentListopt ')' ';' + /.$putCase consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.Super); $break ./ + + --1.1 feature + ExplicitConstructorInvocation ::= Name '.' 'super' '(' ArgumentListopt ')' ';' + /.$putCase consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.Super); $break ./ + + --1.1 feature + ExplicitConstructorInvocation ::= Primary '.' 'this' '(' ArgumentListopt ')' ';' + /.$putCase consumeExplicitConstructorInvocation(1, ExplicitConstructorCall.This); $break ./ + + --1.1 feature + ExplicitConstructorInvocation ::= Name '.' 'this' '(' ArgumentListopt ')' ';' + /.$putCase consumeExplicitConstructorInvocation(2, ExplicitConstructorCall.This); $break ./ + + --18.9 Productions from 9: Interface Declarations + + --18.9.1 Productions from 9.1: Interface Declarations + --InterfaceModifier ::= + -- 'public' + -- | 'abstract' + -- + InterfaceDeclaration ::= InterfaceHeader InterfaceBody + /.$putCase consumeInterfaceDeclaration(); $break ./ + + InterfaceHeader ::= InterfaceHeaderName InterfaceHeaderExtendsopt + /.$putCase consumeInterfaceHeader(); $break ./ + + InterfaceHeaderName ::= Modifiersopt 'interface' 'Identifier' + /.$putCase consumeInterfaceHeaderName(); $break ./ + + -- This rule will be used to accept inner local interface and then report a relevant error message + InvalidInterfaceDeclaration -> InterfaceHeader InterfaceBody + + InterfaceHeaderExtends ::= 'extends' InterfaceTypeList + /.$putCase consumeInterfaceHeaderExtends(); $break ./ + + InterfaceBody ::= '{' InterfaceMemberDeclarationsopt '}' + + InterfaceMemberDeclarations -> InterfaceMemberDeclaration + InterfaceMemberDeclarations ::= InterfaceMemberDeclarations InterfaceMemberDeclaration + /.$putCase consumeInterfaceMemberDeclarations(); $break ./ + + --same as for class members + InterfaceMemberDeclaration ::= ';' + /.$putCase consumeEmptyInterfaceMemberDeclaration(); $break ./ + + -- This rule is added to be able to parse non abstract method inside interface and then report a relevent error message + InvalidMethodDeclaration -> MethodHeader MethodBody + + InterfaceMemberDeclaration -> ConstantDeclaration + InterfaceMemberDeclaration ::= InvalidMethodDeclaration + /.$putCase ignoreMethodBody(); $break ./ + + -- These rules are added to be able to parse constructors inside interface and then report a relevent error message + InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody + /.$putCase ignoreInvalidConstructorDeclaration(true); $break ./ + + InvalidConstructorDeclaration ::= ConstructorHeader ';' + /.$putCase ignoreInvalidConstructorDeclaration(false); $break ./ + + InterfaceMemberDeclaration -> AbstractMethodDeclaration + InterfaceMemberDeclaration -> InvalidConstructorDeclaration + + --1.1 feature + InterfaceMemberDeclaration -> ClassDeclaration + --1.1 feature + InterfaceMemberDeclaration -> InterfaceDeclaration + + ConstantDeclaration -> FieldDeclaration + + ArrayInitializer ::= '{' ,opt '}' + /.$putCase consumeEmptyArrayInitializer(); $break ./ + ArrayInitializer ::= '{' VariableInitializers '}' + /.$putCase consumeArrayInitializer(); $break ./ + ArrayInitializer ::= '{' VariableInitializers , '}' + /.$putCase consumeArrayInitializer(); $break ./ + + VariableInitializers ::= VariableInitializer + VariableInitializers ::= VariableInitializers ',' VariableInitializer + /.$putCase consumeVariableInitializers(); $break ./ + + Block ::= OpenBlock '{' BlockStatementsopt '}' + /.$putCase consumeBlock(); $break ./ + OpenBlock ::= $empty + /.$putCase consumeOpenBlock() ; $break ./ + + BlockStatements -> BlockStatement + BlockStatements ::= BlockStatements BlockStatement + /.$putCase consumeBlockStatements() ; $break ./ + + BlockStatement -> LocalVariableDeclarationStatement + BlockStatement -> Statement + --1.1 feature + BlockStatement -> ClassDeclaration + BlockStatement ::= InvalidInterfaceDeclaration + /.$putCase ignoreInterfaceDeclaration(); $break ./ + + LocalVariableDeclarationStatement ::= LocalVariableDeclaration ';' + /.$putCase consumeLocalVariableDeclarationStatement(); $break ./ + + LocalVariableDeclaration ::= Type PushModifiers VariableDeclarators + /.$putCase consumeLocalVariableDeclaration(); $break ./ + + -- 1.1 feature + -- The modifiers part of this rule makes the grammar more permissive. + -- The only modifier here is final. We put Modifiers to allow multiple modifiers + -- This will require to check the validity of the modifier + + LocalVariableDeclaration ::= Modifiers Type PushModifiers VariableDeclarators + /.$putCase consumeLocalVariableDeclaration(); $break ./ + + PushModifiers ::= $empty + /.$putCase consumePushModifiers(); $break ./ + + Statement -> StatementWithoutTrailingSubstatement + Statement -> LabeledStatement + Statement -> IfThenStatement + Statement -> IfThenElseStatement + Statement -> WhileStatement + Statement -> ForStatement + + StatementNoShortIf -> StatementWithoutTrailingSubstatement + StatementNoShortIf -> LabeledStatementNoShortIf + StatementNoShortIf -> IfThenElseStatementNoShortIf + StatementNoShortIf -> WhileStatementNoShortIf + StatementNoShortIf -> ForStatementNoShortIf + + StatementWithoutTrailingSubstatement -> AssertStatement + StatementWithoutTrailingSubstatement -> Block + StatementWithoutTrailingSubstatement -> EmptyStatement + StatementWithoutTrailingSubstatement -> ExpressionStatement + StatementWithoutTrailingSubstatement -> SwitchStatement + StatementWithoutTrailingSubstatement -> DoStatement + StatementWithoutTrailingSubstatement -> BreakStatement + StatementWithoutTrailingSubstatement -> ContinueStatement + StatementWithoutTrailingSubstatement -> ReturnStatement + StatementWithoutTrailingSubstatement -> SynchronizedStatement + StatementWithoutTrailingSubstatement -> ThrowStatement + StatementWithoutTrailingSubstatement -> TryStatement + + EmptyStatement ::= ';' + /.$putCase consumeEmptyStatement(); $break ./ + + LabeledStatement ::= 'Identifier' ':' Statement + /.$putCase consumeStatementLabel() ; $break ./ + + LabeledStatementNoShortIf ::= 'Identifier' ':' StatementNoShortIf + /.$putCase consumeStatementLabel() ; $break ./ + + ExpressionStatement ::= StatementExpression ';' + /. $putCase consumeExpressionStatement(); $break ./ + + StatementExpression ::= Assignment + StatementExpression ::= PreIncrementExpression + StatementExpression ::= PreDecrementExpression + StatementExpression ::= PostIncrementExpression + StatementExpression ::= PostDecrementExpression + StatementExpression ::= MethodInvocation + StatementExpression ::= ClassInstanceCreationExpression + + IfThenStatement ::= 'if' '(' Expression ')' Statement + /.$putCase consumeStatementIfNoElse(); $break ./ + + IfThenElseStatement ::= 'if' '(' Expression ')' StatementNoShortIf 'else' Statement + /.$putCase consumeStatementIfWithElse(); $break ./ + + IfThenElseStatementNoShortIf ::= 'if' '(' Expression ')' StatementNoShortIf 'else' StatementNoShortIf + /.$putCase consumeStatementIfWithElse(); $break ./ + + SwitchStatement ::= 'switch' OpenBlock '(' Expression ')' SwitchBlock + /.$putCase consumeStatementSwitch() ; $break ./ + + SwitchBlock ::= '{' '}' + /.$putCase consumeEmptySwitchBlock() ; $break ./ + + SwitchBlock ::= '{' SwitchBlockStatements '}' + SwitchBlock ::= '{' SwitchLabels '}' + SwitchBlock ::= '{' SwitchBlockStatements SwitchLabels '}' + /.$putCase consumeSwitchBlock() ; $break ./ + + SwitchBlockStatements -> SwitchBlockStatement + SwitchBlockStatements ::= SwitchBlockStatements SwitchBlockStatement + /.$putCase consumeSwitchBlockStatements() ; $break ./ + + SwitchBlockStatement ::= SwitchLabels BlockStatements + /.$putCase consumeSwitchBlockStatement() ; $break ./ + + SwitchLabels -> SwitchLabel + SwitchLabels ::= SwitchLabels SwitchLabel + /.$putCase consumeSwitchLabels() ; $break ./ + + SwitchLabel ::= 'case' ConstantExpression ':' + /. $putCase consumeCaseLabel(); $break ./ + + SwitchLabel ::= 'default' ':' + /. $putCase consumeDefaultLabel(); $break ./ + + WhileStatement ::= 'while' '(' Expression ')' Statement + /.$putCase consumeStatementWhile() ; $break ./ + + WhileStatementNoShortIf ::= 'while' '(' Expression ')' StatementNoShortIf + /.$putCase consumeStatementWhile() ; $break ./ + + DoStatement ::= 'do' Statement 'while' '(' Expression ')' ';' + /.$putCase consumeStatementDo() ; $break ./ + + ForStatement ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' Statement + /.$putCase consumeStatementFor() ; $break ./ + ForStatementNoShortIf ::= 'for' '(' ForInitopt ';' Expressionopt ';' ForUpdateopt ')' StatementNoShortIf + /.$putCase consumeStatementFor() ; $break ./ + + --the minus one allows to avoid a stack-to-stack transfer + ForInit ::= StatementExpressionList + /.$putCase consumeForInit() ; $break ./ + ForInit -> LocalVariableDeclaration + + ForUpdate -> StatementExpressionList + + StatementExpressionList -> StatementExpression + StatementExpressionList ::= StatementExpressionList ',' StatementExpression + /.$putCase consumeStatementExpressionList() ; $break ./ + + -- 1.4 feature + AssertStatement ::= 'assert' Expression ';' + /.$putCase consumeSimpleAssertStatement() ; $break ./ + + AssertStatement ::= 'assert' Expression ':' Expression ';' + /.$putCase consumeAssertStatement() ; $break ./ + + BreakStatement ::= 'break' ';' + /.$putCase consumeStatementBreak() ; $break ./ + + BreakStatement ::= 'break' Identifier ';' + /.$putCase consumeStatementBreakWithLabel() ; $break ./ + + ContinueStatement ::= 'continue' ';' + /.$putCase consumeStatementContinue() ; $break ./ + + ContinueStatement ::= 'continue' Identifier ';' + /.$putCase consumeStatementContinueWithLabel() ; $break ./ + + ReturnStatement ::= 'return' Expressionopt ';' + /.$putCase consumeStatementReturn() ; $break ./ + + ThrowStatement ::= 'throw' Expression ';' + /.$putCase consumeStatementThrow(); + $break ./ + + SynchronizedStatement ::= OnlySynchronized '(' Expression ')' Block + /.$putCase consumeStatementSynchronized(); $break ./ + OnlySynchronized ::= 'synchronized' + /.$putCase consumeOnlySynchronized(); $break ./ + + + TryStatement ::= 'try' Block Catches + /.$putCase consumeStatementTry(false); $break ./ + TryStatement ::= 'try' Block Catchesopt Finally + /.$putCase consumeStatementTry(true); $break ./ + + Catches -> CatchClause + Catches ::= Catches CatchClause + /.$putCase consumeCatches(); $break ./ + + CatchClause ::= 'catch' '(' FormalParameter ')' Block + /.$putCase consumeStatementCatch() ; $break ./ + + Finally ::= 'finally' Block + + --18.12 Productions from 14: Expressions + + --for source positionning purpose + PushLPAREN ::= '(' + /.$putCase consumeLeftParen(); $break ./ + PushRPAREN ::= ')' + /.$putCase consumeRightParen(); $break ./ + + Primary -> PrimaryNoNewArray + Primary -> ArrayCreationExpression + + PrimaryNoNewArray -> Literal + PrimaryNoNewArray ::= 'this' + /.$putCase consumePrimaryNoNewArrayThis(); $break ./ + + PrimaryNoNewArray ::= PushLPAREN Expression PushRPAREN + /.$putCase consumePrimaryNoNewArray(); $break ./ + + PrimaryNoNewArray -> ClassInstanceCreationExpression + PrimaryNoNewArray -> FieldAccess + --1.1 feature + PrimaryNoNewArray ::= Name '.' 'this' + /.$putCase consumePrimaryNoNewArrayNameThis(); $break ./ + PrimaryNoNewArray ::= Name '.' 'super' + /.$putCase consumePrimaryNoNewArrayNameSuper(); $break ./ + + --1.1 feature + --PrimaryNoNewArray ::= Type '.' 'class' + --inline Type in the previous rule in order to make the grammar LL1 instead + -- of LL2. The result is the 3 next rules. + PrimaryNoNewArray ::= Name '.' 'class' + /.$putCase consumePrimaryNoNewArrayName(); $break ./ + + PrimaryNoNewArray ::= ArrayType '.' 'class' + /.$putCase consumePrimaryNoNewArrayArrayType(); $break ./ + + PrimaryNoNewArray ::= PrimitiveType '.' 'class' + /.$putCase consumePrimaryNoNewArrayPrimitiveType(); $break ./ + + PrimaryNoNewArray -> MethodInvocation + PrimaryNoNewArray -> ArrayAccess + + --1.1 feature + -- + -- In Java 1.0 a ClassBody could not appear at all in a + -- ClassInstanceCreationExpression. + -- + + AllocationHeader ::= 'new' ClassType '(' ArgumentListopt ')' + /.$putCase consumeAllocationHeader(); $break ./ + + ClassInstanceCreationExpression ::= 'new' ClassType '(' ArgumentListopt ')' ClassBodyopt + /.$putCase consumeClassInstanceCreationExpression(); $break ./ + --1.1 feature + + ClassInstanceCreationExpression ::= Primary '.' 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt + /.$putCase consumeClassInstanceCreationExpressionQualified() ; $break ./ + + --1.1 feature + ClassInstanceCreationExpression ::= ClassInstanceCreationExpressionName 'new' SimpleName '(' ArgumentListopt ')' ClassBodyopt + /.$putCase consumeClassInstanceCreationExpressionQualified() ; $break ./ + + ClassInstanceCreationExpressionName ::= Name '.' + /.$putCase consumeClassInstanceCreationExpressionName() ; $break ./ + + ClassBodyopt ::= $empty --test made using null as contents + /.$putCase consumeClassBodyopt(); $break ./ + ClassBodyopt ::= EnterAnonymousClassBody ClassBody + + EnterAnonymousClassBody ::= $empty + /.$putCase consumeEnterAnonymousClassBody(); $break ./ + + ArgumentList ::= Expression + ArgumentList ::= ArgumentList ',' Expression + /.$putCase consumeArgumentList(); $break ./ + + --Thess rules are re-written in order to be ll1 + --ArrayCreationExpression ::= 'new' ArrayType ArrayInitializer + --ArrayCreationExpression ::= 'new' PrimitiveType DimExprs Dimsopt + --ArrayCreationExpression ::= 'new' ClassOrInterfaceType DimExprs Dimsopt + --DimExprs ::= DimExpr + --DimExprs ::= DimExprs DimExpr + + ArrayCreationExpression ::= 'new' PrimitiveType DimWithOrWithOutExprs ArrayInitializeropt + /.$putCase consumeArrayCreationExpression(); $break ./ + ArrayCreationExpression ::= 'new' ClassOrInterfaceType DimWithOrWithOutExprs ArrayInitializeropt + /.$putCase consumeArrayCreationExpression(); $break ./ + + DimWithOrWithOutExprs ::= DimWithOrWithOutExpr + DimWithOrWithOutExprs ::= DimWithOrWithOutExprs DimWithOrWithOutExpr + /.$putCase consumeDimWithOrWithOutExprs(); $break ./ + + DimWithOrWithOutExpr ::= '[' Expression ']' + DimWithOrWithOutExpr ::= '[' ']' + /. $putCase consumeDimWithOrWithOutExpr(); $break ./ + -- ----------------------------------------------- + + Dims ::= DimsLoop + /. $putCase consumeDims(); $break ./ + DimsLoop -> OneDimLoop + DimsLoop ::= DimsLoop OneDimLoop + OneDimLoop ::= '[' ']' + /. $putCase consumeOneDimLoop(); $break ./ + + FieldAccess ::= Primary '.' 'Identifier' + /.$putCase consumeFieldAccess(false); $break ./ + + FieldAccess ::= 'super' '.' 'Identifier' + /.$putCase consumeFieldAccess(true); $break ./ + + MethodInvocation ::= Name '(' ArgumentListopt ')' + /.$putCase consumeMethodInvocationName(); $break ./ + + MethodInvocation ::= Primary '.' 'Identifier' '(' ArgumentListopt ')' + /.$putCase consumeMethodInvocationPrimary(); $break ./ + + MethodInvocation ::= 'super' '.' 'Identifier' '(' ArgumentListopt ')' + /.$putCase consumeMethodInvocationSuper(); $break ./ + + ArrayAccess ::= Name '[' Expression ']' + /.$putCase consumeArrayAccess(true); $break ./ + ArrayAccess ::= PrimaryNoNewArray '[' Expression ']' + /.$putCase consumeArrayAccess(false); $break ./ + + PostfixExpression -> Primary + PostfixExpression ::= Name + /.$putCase consumePostfixExpression(); $break ./ + PostfixExpression -> PostIncrementExpression + PostfixExpression -> PostDecrementExpression + + PostIncrementExpression ::= PostfixExpression '++' + /.$putCase consumeUnaryExpression(OperatorExpression.PLUS,true); $break ./ + + PostDecrementExpression ::= PostfixExpression '--' + /.$putCase consumeUnaryExpression(OperatorExpression.MINUS,true); $break ./ + + --for source managment purpose + PushPosition ::= $empty + /.$putCase consumePushPosition(); $break ./ + + UnaryExpression -> PreIncrementExpression + UnaryExpression -> PreDecrementExpression + UnaryExpression ::= '+' PushPosition UnaryExpression + /.$putCase consumeUnaryExpression(OperatorExpression.PLUS); $break ./ + UnaryExpression ::= '-' PushPosition UnaryExpression + /.$putCase consumeUnaryExpression(OperatorExpression.MINUS); $break ./ + UnaryExpression -> UnaryExpressionNotPlusMinus + + PreIncrementExpression ::= '++' PushPosition UnaryExpression + /.$putCase consumeUnaryExpression(OperatorExpression.PLUS,false); $break ./ + + PreDecrementExpression ::= '--' PushPosition UnaryExpression + /.$putCase consumeUnaryExpression(OperatorExpression.MINUS,false); $break ./ + + UnaryExpressionNotPlusMinus -> PostfixExpression + UnaryExpressionNotPlusMinus ::= '~' PushPosition UnaryExpression + /.$putCase consumeUnaryExpression(OperatorExpression.TWIDDLE); $break ./ + UnaryExpressionNotPlusMinus ::= '!' PushPosition UnaryExpression + /.$putCase consumeUnaryExpression(OperatorExpression.NOT); $break ./ + UnaryExpressionNotPlusMinus -> CastExpression + + CastExpression ::= PushLPAREN PrimitiveType Dimsopt PushRPAREN UnaryExpression + /.$putCase consumeCastExpression(); $break ./ + CastExpression ::= PushLPAREN Name Dims PushRPAREN UnaryExpressionNotPlusMinus + /.$putCase consumeCastExpression(); $break ./ + -- Expression is here only in order to make the grammar LL1 + CastExpression ::= PushLPAREN Expression PushRPAREN UnaryExpressionNotPlusMinus + /.$putCase consumeCastExpressionLL1(); $break ./ + + MultiplicativeExpression -> UnaryExpression + MultiplicativeExpression ::= MultiplicativeExpression '*' UnaryExpression + /.$putCase consumeBinaryExpression(OperatorExpression.MULTIPLY); $break ./ + MultiplicativeExpression ::= MultiplicativeExpression '/' UnaryExpression + /.$putCase consumeBinaryExpression(OperatorExpression.DIVIDE); $break ./ + MultiplicativeExpression ::= MultiplicativeExpression '%' UnaryExpression + /.$putCase consumeBinaryExpression(OperatorExpression.REMAINDER); $break ./ + + AdditiveExpression -> MultiplicativeExpression + AdditiveExpression ::= AdditiveExpression '+' MultiplicativeExpression + /.$putCase consumeBinaryExpression(OperatorExpression.PLUS); $break ./ + AdditiveExpression ::= AdditiveExpression '-' MultiplicativeExpression + /.$putCase consumeBinaryExpression(OperatorExpression.MINUS); $break ./ + + ShiftExpression -> AdditiveExpression + ShiftExpression ::= ShiftExpression '<<' AdditiveExpression + /.$putCase consumeBinaryExpression(OperatorExpression.LEFT_SHIFT); $break ./ + ShiftExpression ::= ShiftExpression '>>' AdditiveExpression + /.$putCase consumeBinaryExpression(OperatorExpression.RIGHT_SHIFT); $break ./ + ShiftExpression ::= ShiftExpression '>>>' AdditiveExpression + /.$putCase consumeBinaryExpression(OperatorExpression.UNSIGNED_RIGHT_SHIFT); $break ./ + + RelationalExpression -> ShiftExpression + RelationalExpression ::= RelationalExpression '<' ShiftExpression + /.$putCase consumeBinaryExpression(OperatorExpression.LESS); $break ./ + RelationalExpression ::= RelationalExpression '>' ShiftExpression + /.$putCase consumeBinaryExpression(OperatorExpression.GREATER); $break ./ + RelationalExpression ::= RelationalExpression '<=' ShiftExpression + /.$putCase consumeBinaryExpression(OperatorExpression.LESS_EQUAL); $break ./ + RelationalExpression ::= RelationalExpression '>=' ShiftExpression + /.$putCase consumeBinaryExpression(OperatorExpression.GREATER_EQUAL); $break ./ + RelationalExpression ::= RelationalExpression 'instanceof' ReferenceType + /.$putCase consumeInstanceOfExpression(OperatorExpression.INSTANCEOF); $break ./ + + EqualityExpression -> RelationalExpression + EqualityExpression ::= EqualityExpression '==' RelationalExpression + /.$putCase consumeEqualityExpression(OperatorExpression.EQUAL_EQUAL); $break ./ + EqualityExpression ::= EqualityExpression '!=' RelationalExpression + /.$putCase consumeEqualityExpression(OperatorExpression.NOT_EQUAL); $break ./ + + AndExpression -> EqualityExpression + AndExpression ::= AndExpression '&' EqualityExpression + /.$putCase consumeBinaryExpression(OperatorExpression.AND); $break ./ + + ExclusiveOrExpression -> AndExpression + ExclusiveOrExpression ::= ExclusiveOrExpression '^' AndExpression + /.$putCase consumeBinaryExpression(OperatorExpression.XOR); $break ./ + + InclusiveOrExpression -> ExclusiveOrExpression + InclusiveOrExpression ::= InclusiveOrExpression '|' ExclusiveOrExpression + /.$putCase consumeBinaryExpression(OperatorExpression.OR); $break ./ + + ConditionalAndExpression -> InclusiveOrExpression + ConditionalAndExpression ::= ConditionalAndExpression '&&' InclusiveOrExpression + /.$putCase consumeBinaryExpression(OperatorExpression.AND_AND); $break ./ + + ConditionalOrExpression -> ConditionalAndExpression + ConditionalOrExpression ::= ConditionalOrExpression '||' ConditionalAndExpression + /.$putCase consumeBinaryExpression(OperatorExpression.OR_OR); $break ./ + + ConditionalExpression -> ConditionalOrExpression + ConditionalExpression ::= ConditionalOrExpression '?' Expression ':' ConditionalExpression + /.$putCase consumeConditionalExpression(OperatorExpression.QUESTIONCOLON) ; $break ./ + + AssignmentExpression -> ConditionalExpression + AssignmentExpression -> Assignment + + Assignment ::= LeftHandSide AssignmentOperator AssignmentExpression + /.$putCase consumeAssignment(); $break ./ + + -- this rule is added to parse an array initializer in a assigment and then report a syntax error knowing the exact senario + InvalidArrayInitializerAssignement ::= LeftHandSide AssignmentOperator ArrayInitializer + Assignment ::= InvalidArrayInitializerAssignement + /.$putcase ignoreExpressionAssignment();$break ./ + + LeftHandSide ::= Name + /.$putCase consumeLeftHandSide(); $break ./ + LeftHandSide -> FieldAccess + LeftHandSide -> ArrayAccess + + AssignmentOperator ::= '=' + /.$putCase consumeAssignmentOperator(EQUAL); $break ./ + AssignmentOperator ::= '*=' + /.$putCase consumeAssignmentOperator(MULTIPLY); $break ./ + AssignmentOperator ::= '/=' + /.$putCase consumeAssignmentOperator(DIVIDE); $break ./ + AssignmentOperator ::= '%=' + /.$putCase consumeAssignmentOperator(REMAINDER); $break ./ + AssignmentOperator ::= '+=' + /.$putCase consumeAssignmentOperator(PLUS); $break ./ + AssignmentOperator ::= '-=' + /.$putCase consumeAssignmentOperator(MINUS); $break ./ + AssignmentOperator ::= '<<=' + /.$putCase consumeAssignmentOperator(LEFT_SHIFT); $break ./ + AssignmentOperator ::= '>>=' + /.$putCase consumeAssignmentOperator(RIGHT_SHIFT); $break ./ + AssignmentOperator ::= '>>>=' + /.$putCase consumeAssignmentOperator(UNSIGNED_RIGHT_SHIFT); $break ./ + AssignmentOperator ::= '&=' + /.$putCase consumeAssignmentOperator(AND); $break ./ + AssignmentOperator ::= '^=' + /.$putCase consumeAssignmentOperator(XOR); $break ./ + AssignmentOperator ::= '|=' + /.$putCase consumeAssignmentOperator(OR); $break ./ + + Expression -> AssignmentExpression + + ConstantExpression -> Expression + + -- The following rules are for optional nonterminals. + -- + + PackageDeclarationopt -> $empty + PackageDeclarationopt -> PackageDeclaration + + ClassHeaderExtendsopt ::= $empty + ClassHeaderExtendsopt -> ClassHeaderExtends + + Expressionopt ::= $empty + /.$putCase consumeEmptyExpression(); $break ./ + Expressionopt -> Expression + + + --------------------------------------------------------------------------------------- + -- + -- The rules below are for optional terminal symbols. An optional comma, + -- is only used in the context of an array initializer - It is a + -- "syntactic sugar" that otherwise serves no other purpose. By contrast, + -- an optional identifier is used in the definition of a break and + -- continue statement. When the identifier does not appear, a NULL + -- is produced. When the identifier is present, the user should use the + -- corresponding TOKEN(i) method. See break statement as an example. + -- + --------------------------------------------------------------------------------------- + + ,opt -> $empty + ,opt -> , + + ImportDeclarationsopt ::= $empty + /.$putCase consumeEmptyImportDeclarationsopt(); $break ./ + ImportDeclarationsopt ::= ImportDeclarations + /.$putCase consumeImportDeclarationsopt(); $break ./ + + + TypeDeclarationsopt ::= $empty + /.$putCase consumeEmptyTypeDeclarationsopt(); $break ./ + TypeDeclarationsopt ::= TypeDeclarations + /.$putCase consumeTypeDeclarationsopt(); $break ./ + + ClassBodyDeclarationsopt ::= $empty + /.$putCase consumeEmptyClassBodyDeclarationsopt(); $break ./ + ClassBodyDeclarationsopt ::= NestedType ClassBodyDeclarations + /.$putCase consumeClassBodyDeclarationsopt(); $break ./ + + Modifiersopt ::= $empty + /. $putCase consumeDefaultModifiers(); $break ./ + Modifiersopt ::= Modifiers + /.$putCase consumeModifiers(); $break ./ + + BlockStatementsopt ::= $empty + /.$putCase consumeEmptyBlockStatementsopt(); $break ./ + BlockStatementsopt -> BlockStatements + + Dimsopt ::= $empty + /. $putCase consumeEmptyDimsopt(); $break ./ + Dimsopt -> Dims + + ArgumentListopt ::= $empty + /. $putCase consumeEmptyArgumentListopt(); $break ./ + ArgumentListopt -> ArgumentList + + MethodHeaderThrowsClauseopt ::= $empty + MethodHeaderThrowsClauseopt -> MethodHeaderThrowsClause + + FormalParameterListopt ::= $empty + /.$putcase consumeFormalParameterListopt(); $break ./ + FormalParameterListopt -> FormalParameterList + + ClassHeaderImplementsopt ::= $empty + ClassHeaderImplementsopt -> ClassHeaderImplements + + InterfaceMemberDeclarationsopt ::= $empty + /. $putCase consumeEmptyInterfaceMemberDeclarationsopt(); $break ./ + InterfaceMemberDeclarationsopt ::= NestedType InterfaceMemberDeclarations + /. $putCase consumeInterfaceMemberDeclarationsopt(); $break ./ + + NestedType ::= $empty + /.$putCase consumeNestedType(); $break./ + + ForInitopt ::= $empty + /. $putCase consumeEmptyForInitopt(); $break ./ + ForInitopt -> ForInit + + ForUpdateopt ::= $empty + /. $putCase consumeEmptyForUpdateopt(); $break ./ + ForUpdateopt -> ForUpdate + + InterfaceHeaderExtendsopt ::= $empty + InterfaceHeaderExtendsopt -> InterfaceHeaderExtends + + Catchesopt ::= $empty + /. $putCase consumeEmptyCatchesopt(); $break ./ + Catchesopt -> Catches + + ArrayInitializeropt ::= $empty + /. $putCase consumeEmptyArrayInitializeropt(); $break ./ + ArrayInitializeropt -> ArrayInitializer + + /. } + } ./ + + --------------------------------------------------------------------------------------- + + $names + + -- BodyMarker ::= '"class Identifier { ... MethodHeader "' + + -- void ::= 'void' + + PLUS_PLUS ::= '++' + MINUS_MINUS ::= '--' + EQUAL_EQUAL ::= '==' + LESS_EQUAL ::= '<=' + GREATER_EQUAL ::= '>=' + NOT_EQUAL ::= '!=' + LEFT_SHIFT ::= '<<' + RIGHT_SHIFT ::= '>>' + UNSIGNED_RIGHT_SHIFT ::= '>>>' + PLUS_EQUAL ::= '+=' + MINUS_EQUAL ::= '-=' + MULTIPLY_EQUAL ::= '*=' + DIVIDE_EQUAL ::= '/=' + AND_EQUAL ::= '&=' + OR_EQUAL ::= '|=' + XOR_EQUAL ::= '^=' + REMAINDER_EQUAL ::= '%=' + LEFT_SHIFT_EQUAL ::= '<<=' + RIGHT_SHIFT_EQUAL ::= '>>=' + UNSIGNED_RIGHT_SHIFT_EQUAL ::= '>>>=' + OR_OR ::= '||' + AND_AND ::= '&&' + + PLUS ::= '+' + MINUS ::= '-' + NOT ::= '!' + REMAINDER ::= '%' + XOR ::= '^' + AND ::= '&' + MULTIPLY ::= '*' + OR ::= '|' + TWIDDLE ::= '~' + DIVIDE ::= '/' + GREATER ::= '>' + LESS ::= '<' + LPAREN ::= '(' + RPAREN ::= ')' + LBRACE ::= '{' + RBRACE ::= '}' + LBRACKET ::= '[' + RBRACKET ::= ']' + SEMICOLON ::= ';' + QUESTION ::= '?' + COLON ::= ':' + COMMA ::= ',' + DOT ::= '.' + EQUAL ::= '=' + + $end + -- need a carriage return after the $end + */ + } + protected void ignoreExpressionAssignment() { + // Assignment ::= InvalidArrayInitializerAssignement + // encoded operator would be: intStack[intPtr] + intPtr--; + ArrayInitializer arrayInitializer = (ArrayInitializer) expressionStack[expressionPtr--]; + expressionLengthPtr--; + // report a syntax error and abort parsing + problemReporter().arrayConstantsOnlyInArrayInitializers(arrayInitializer.sourceStart, arrayInitializer.sourceEnd); + } + protected void ignoreInterfaceDeclaration() { + // BlockStatement ::= InvalidInterfaceDeclaration + //InterfaceDeclaration ::= Modifiersopt 'interface' 'Identifier' ExtendsInterfacesopt InterfaceHeader InterfaceBody + + // length declarations + int length; + if ((length = astLengthStack[astLengthPtr--]) != 0) { + //there are length declarations + //dispatch according to the type of the declarations + dispatchDeclarationInto(length); + } + + flushAnnotationsDefinedPriorTo(endStatementPosition); + + // report the problem and continue parsing + TypeDeclaration typeDecl = (TypeDeclaration) astStack[astPtr]; + typeDecl.bodyEnd = endStatementPosition; + problemReporter().cannotDeclareLocalInterface(typeDecl.name, typeDecl.sourceStart, typeDecl.sourceEnd); + + // mark fields and initializer with local type mark if needed + markFieldsWithLocalType(typeDecl); + + // remove the ast node created in interface header + astPtr--; + // Don't create an astnode for this inner interface, but have to push + // a 0 on the astLengthStack to be consistent with the reduction made + // at the end of the method: + // public void parse(MethodDeclaration md, CompilationUnitDeclaration unit) + pushOnAstLengthStack(0); + } + protected void ignoreInvalidConstructorDeclaration(boolean hasBody) { + // InvalidConstructorDeclaration ::= ConstructorHeader ConstructorBody ==> true + // InvalidConstructorDeclaration ::= ConstructorHeader ';' ==> false + + /* + astStack : modifiers arguments throws statements + identifierStack : name + ==> + astStack : MethodDeclaration + identifierStack : + */ + + //must provide a default constructor call when needed + + if (hasBody) { + // pop the position of the { (body of the method) pushed in block decl + intPtr--; + } + + //statements + if (hasBody) { + realBlockPtr--; + } + + int length; + if (hasBody && ((length = astLengthStack[astLengthPtr--]) != 0)) { + astPtr -= length; + } + } + protected void ignoreMethodBody() { + // InterfaceMemberDeclaration ::= InvalidMethodDeclaration + + /* + astStack : modifiers arguments throws statements + identifierStack : type name + intStack : dim dim dim + ==> + astStack : MethodDeclaration + identifierStack : + intStack : + */ + + // pop the position of the { (body of the method) pushed in block decl + intPtr--; + // retrieve end position of method declarator + + //statements + realBlockPtr--; + int length; + if ((length = astLengthStack[astLengthPtr--]) != 0) { + astPtr -= length; + } + + //watch for } that could be given as a unicode ! ( u007D is '}' ) + MethodDeclaration md = (MethodDeclaration) astStack[astPtr]; + md.bodyEnd = endPosition; + md.declarationSourceEnd = flushAnnotationsDefinedPriorTo(endStatementPosition); + + // report the problem and continue the parsing - narrowing the problem onto the method + problemReporter().abstractMethodNeedingNoBody(md); + } + public void initialize() { + //positionning the parser for a new compilation unit + //avoiding stack reallocation and all that.... + astPtr = -1; + astLengthPtr = -1; + expressionPtr = -1; + expressionLengthPtr = -1; + identifierPtr = -1; + identifierLengthPtr = -1; + intPtr = -1; + nestedMethod[nestedType = 0] = 0; // need to reset for further reuse + variablesCounter[nestedType] = 0; + dimensions = 0; + realBlockPtr = -1; + compilationUnit = null; + referenceContext = null; + endStatementPosition = 0; + + //remove objects from stack too, while the same parser/compiler couple is + //re-used between two compilations .... + + int astLength = astStack.length; + if (noAstNodes.length < astLength) { + noAstNodes = new AstNode[astLength]; + //System.out.println("Resized AST stacks : "+ astLength); + + } + System.arraycopy(noAstNodes, 0, astStack, 0, astLength); + + int expressionLength = expressionStack.length; + if (noExpressions.length < expressionLength) { + noExpressions = new Expression[expressionLength]; + //System.out.println("Resized EXPR stacks : "+ expressionLength); + } + System.arraycopy(noExpressions, 0, expressionStack, 0, expressionLength); + + // reset scanner state + scanner.commentPtr = -1; + scanner.eofPosition = Integer.MAX_VALUE; + + resetModifiers(); + + // recovery + lastCheckPoint = -1; + currentElement = null; + restartRecovery = false; + hasReportedError = false; + recoveredStaticInitializerStart = 0; + lastIgnoredToken = -1; + lastErrorEndPosition = -1; + listLength = 0; + } + public void initializeScanner() { + this.scanner = + new Scanner( + false, + false, + this.problemReporter.options.getNonExternalizedStringLiteralSeverity() != ProblemSeverities.Ignore, + this.assertMode); + } + public final static void initTables() throws java.io.IOException { + + final String prefix = FILEPREFIX; + int i = 0; + lhs = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$ + char[] chars = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$ + check_table = new short[chars.length]; + for (int c = chars.length; c-- > 0;) { + check_table[c] = (short) (chars[c] - 32768); + } + asb = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$ + asr = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$ + symbol_index = readTable(prefix + (++i) + ".rsc"); //$NON-NLS-1$ + action = lhs; + } + public final void jumpOverMethodBody() { + //on diet parsing.....do not buffer method statements + + //the scanner.diet is reinitialized to false + //automatically by the scanner once it has jumped over + //the statements + + if (diet && (dietInt == 0)) + scanner.diet = true; + } + protected void markCurrentMethodWithLocalType() { + if (this.currentElement != null) + return; // this is already done in the recovery code + for (int i = this.astPtr; i >= 0; i--) { + AstNode node = this.astStack[i]; + if (node instanceof AbstractMethodDeclaration + || node instanceof TypeDeclaration) { // mark type for now: all fields will be marked when added to this type + node.bits |= AstNode.HasLocalTypeMASK; + return; + } + } + // default to reference context (case of parse method body) + if (this.referenceContext instanceof AbstractMethodDeclaration || this.referenceContext instanceof TypeDeclaration) { + ((AstNode) this.referenceContext).bits |= AstNode.HasLocalTypeMASK; + } + } + protected void markFieldsWithLocalType(TypeDeclaration type) { + if (type.fields == null || (type.bits & AstNode.HasLocalTypeMASK) == 0) + return; + for (int i = 0, length = type.fields.length; i < length; i++) { + type.fields[i].bits |= AstNode.HasLocalTypeMASK; + } + } + /* + * Move checkpoint location (current implementation is moving it by one token) + * + * Answers true if successfully moved checkpoint (i.e. did not attempt to move it + * beyond end of file). + */ + protected boolean moveRecoveryCheckpoint() { + + int pos = lastCheckPoint; + /* reset scanner, and move checkpoint by one token */ + scanner.startPosition = pos; + scanner.currentPosition = pos; + scanner.diet = false; // quit jumping over method bodies + + /* if about to restart, then no need to shift token */ + if (restartRecovery) { + lastIgnoredToken = -1; + return true; + } + + /* protect against shifting on an invalid token */ + lastIgnoredToken = nextIgnoredToken; + nextIgnoredToken = -1; + do { + try { + nextIgnoredToken = scanner.getNextToken(); + if (scanner.currentPosition == scanner.startPosition) { + scanner.currentPosition++; // on fake completion identifier + nextIgnoredToken = -1; + } + + } catch (InvalidInputException e) { + pos = scanner.currentPosition; + } + } while (nextIgnoredToken < 0); + + if (nextIgnoredToken == TokenNameEOF) { // no more recovery after this point + if (currentToken == TokenNameEOF) { // already tried one iteration on EOF + return false; + } + } + lastCheckPoint = scanner.currentPosition; + + /* reset scanner again to previous checkpoint location*/ + scanner.startPosition = pos; + scanner.currentPosition = pos; + scanner.commentPtr = -1; + + return true; + + /* + The following implementation moves the checkpoint location by one line: + + int pos = lastCheckPoint; + // reset scanner, and move checkpoint by one token + scanner.startPosition = pos; + scanner.currentPosition = pos; + scanner.diet = false; // quit jumping over method bodies + + // if about to restart, then no need to shift token + if (restartRecovery){ + lastIgnoredToken = -1; + return true; + } + + // protect against shifting on an invalid token + lastIgnoredToken = nextIgnoredToken; + nextIgnoredToken = -1; + + boolean wasTokenizingWhiteSpace = scanner.tokenizeWhiteSpace; + scanner.tokenizeWhiteSpace = true; + checkpointMove: + do { + try { + nextIgnoredToken = scanner.getNextToken(); + switch(nextIgnoredToken){ + case Scanner.TokenNameWHITESPACE : + if(scanner.getLineNumber(scanner.startPosition) + == scanner.getLineNumber(scanner.currentPosition)){ + nextIgnoredToken = -1; + } + break; + case TokenNameSEMICOLON : + case TokenNameLBRACE : + case TokenNameRBRACE : + break; + case TokenNameIdentifier : + if(scanner.currentPosition == scanner.startPosition){ + scanner.currentPosition++; // on fake completion identifier + } + default: + nextIgnoredToken = -1; + break; + case TokenNameEOF : + break checkpointMove; + } + } catch(InvalidInputException e){ + pos = scanner.currentPosition; + } + } while (nextIgnoredToken < 0); + scanner.tokenizeWhiteSpace = wasTokenizingWhiteSpace; + + if (nextIgnoredToken == TokenNameEOF) { // no more recovery after this point + if (currentToken == TokenNameEOF) { // already tried one iteration on EOF + return false; + } + } + lastCheckPoint = scanner.currentPosition; + + // reset scanner again to previous checkpoint location + scanner.startPosition = pos; + scanner.currentPosition = pos; + scanner.commentPtr = -1; + + return true; + */ + } + protected MessageSend newMessageSend() { + // '(' ArgumentListopt ')' + // the arguments are on the expression stack + + MessageSend m = new MessageSend(); + int length; + if ((length = expressionLengthStack[expressionLengthPtr--]) != 0) { + expressionPtr -= length; + System.arraycopy(expressionStack, expressionPtr + 1, m.arguments = new Expression[length], 0, length); + }; + return m; + } + protected static int ntAction(int state, int sym) { + return action[state + sym]; + } + private final void optimizedConcatNodeLists() { + /*back from a recursive loop. Virtualy group the + astNode into an array using astLengthStack*/ + + /* + * This is a case where you have two sublists into the astStack that you want + * to merge in one list. There is no action required on the astStack. The only + * thing you need to do is merge the two lengths specified on the astStackLength. + * The top two length are for example: + * ... p n + * and you want to result in a list like: + * ... n+p + * This means that the p could be equals to 0 in case there is no astNode pushed + * on the astStack. + * Look at the InterfaceMemberDeclarations for an example. + * This case optimizes the fact that p == 1. + */ + + astLengthStack[--astLengthPtr]++; + } + protected static int original_state(int state) { + return -check(state); + } + /*main loop of the automat + When a rule is reduced, the method consumeRule(int) is called with the number + of the consumed rule. When a terminal is consumed, the method consumeToken(int) is + called in order to remember (when needed) the consumed token */ + // (int)asr[asi(act)] + // name[symbol_index[currentKind]] + protected void parse() { + + hasReportedError = false; + int act = START_STATE; + stateStackTop = -1; + currentToken = getFirstToken(); + ProcessTerminals : for (;;) { + try { + stack[++stateStackTop] = act; + } catch (IndexOutOfBoundsException e) { + int oldStackLength = stack.length; + int oldStack[] = stack; + stack = new int[oldStackLength + StackIncrement]; + System.arraycopy(oldStack, 0, stack, 0, oldStackLength); + stack[stateStackTop] = act; + }; + + act = tAction(act, currentToken); + + if (act == ERROR_ACTION || restartRecovery) { + int errorPos = scanner.currentPosition; + if (!hasReportedError) { + this.reportSyntaxError(ERROR_ACTION, currentToken, stateStackTop); + hasReportedError = true; + } + if (resumeOnSyntaxError()) { + if (act == ERROR_ACTION) + lastErrorEndPosition = errorPos; + act = START_STATE; + stateStackTop = -1; + currentToken = getFirstToken(); + continue ProcessTerminals; + } else { + act = ERROR_ACTION; + } + break ProcessTerminals; + } + if (act <= NUM_RULES) + stateStackTop--; + else if (act > ERROR_ACTION) { /* shift-reduce */ + consumeToken(currentToken); + if (currentElement != null) + this.recoveryTokenCheck(); + try { + currentToken = scanner.getNextToken(); + } catch (InvalidInputException e) { + if (!hasReportedError) { + this.problemReporter().scannerError(this, e.getMessage()); + hasReportedError = true; + } + lastCheckPoint = scanner.currentPosition; + restartRecovery = true; + } + act -= ERROR_ACTION; + } else if (act < ACCEPT_ACTION) { /* shift */ + consumeToken(currentToken); + if (currentElement != null) + this.recoveryTokenCheck(); + try { + currentToken = scanner.getNextToken(); + } catch (InvalidInputException e) { + if (!hasReportedError) { + this.problemReporter().scannerError(this, e.getMessage()); + hasReportedError = true; + } + lastCheckPoint = scanner.currentPosition; + restartRecovery = true; + } + continue ProcessTerminals; + } else + break ProcessTerminals; + + ProcessNonTerminals : do { /* reduce */ + consumeRule(act); + stateStackTop -= (rhs[act] - 1); + act = ntAction(stack[stateStackTop], lhs[act]); + } while (act <= NUM_RULES); + } + endParse(act); + } + // A P I + + public void parse(ConstructorDeclaration cd, CompilationUnitDeclaration unit) { + //only parse the method body of cd + //fill out its statements + + //convert bugs into parse error + + initialize(); + goForConstructorBody(); + nestedMethod[nestedType]++; + + referenceContext = cd; + compilationUnit = unit; + + scanner.resetTo(cd.sourceEnd + 1, cd.declarationSourceEnd); + try { + parse(); + } catch (AbortCompilation ex) { + lastAct = ERROR_ACTION; + } finally { + nestedMethod[nestedType]--; + } + + if (lastAct == ERROR_ACTION) { + initialize(); + return; + } + + //statements + cd.explicitDeclarations = realBlockStack[realBlockPtr--]; + int length; + if ((length = astLengthStack[astLengthPtr--]) != 0) { + astPtr -= length; + if (astStack[astPtr + 1] instanceof ExplicitConstructorCall) + //avoid a isSomeThing that would only be used here BUT what is faster between two alternatives ? + { + System.arraycopy(astStack, astPtr + 2, cd.statements = new Statement[length - 1], 0, length - 1); + cd.constructorCall = (ExplicitConstructorCall) astStack[astPtr + 1]; + } else { //need to add explicitly the super(); + System.arraycopy(astStack, astPtr + 1, cd.statements = new Statement[length], 0, length); + cd.constructorCall = SuperReference.implicitSuperConstructorCall(); + } + } else { + cd.constructorCall = SuperReference.implicitSuperConstructorCall(); + } + + if (cd.constructorCall.sourceEnd == 0) { + cd.constructorCall.sourceEnd = cd.sourceEnd; + cd.constructorCall.sourceStart = cd.sourceStart; + } + } + // A P I + + public void parse(Initializer ini, TypeDeclaration type, CompilationUnitDeclaration unit) { + //only parse the method body of md + //fill out method statements + + //convert bugs into parse error + + initialize(); + goForInitializer(); + nestedMethod[nestedType]++; + + referenceContext = type; + compilationUnit = unit; + + scanner.resetTo(ini.sourceStart, ini.sourceEnd); // just on the beginning { + try { + parse(); + } catch (AbortCompilation ex) { + lastAct = ERROR_ACTION; + } finally { + nestedMethod[nestedType]--; + } + + if (lastAct == ERROR_ACTION) { + return; + } + + ini.block = ((Initializer) astStack[astPtr]).block; + + // mark initializer with local type if one was found during parsing + if ((type.bits & AstNode.HasLocalTypeMASK) != 0) { + ini.bits |= AstNode.HasLocalTypeMASK; + } + } + // A P I + + public void parse(MethodDeclaration md, CompilationUnitDeclaration unit) { + //only parse the method body of md + //fill out method statements + + //convert bugs into parse error + + if (md.isAbstract()) + return; + if (md.isNative()) + return; + if ((md.modifiers & AccSemicolonBody) != 0) + return; + + initialize(); + goForMethodBody(); + nestedMethod[nestedType]++; + + referenceContext = md; + compilationUnit = unit; + + scanner.resetTo(md.sourceEnd + 1, md.declarationSourceEnd); + // reset the scanner to parser from { down to } + try { + parse(); + } catch (AbortCompilation ex) { + lastAct = ERROR_ACTION; + } finally { + nestedMethod[nestedType]--; + } + + if (lastAct == ERROR_ACTION) { + return; + } + + //refill statements + md.explicitDeclarations = realBlockStack[realBlockPtr--]; + int length; + if ((length = astLengthStack[astLengthPtr--]) != 0) + System.arraycopy(astStack, (astPtr -= length) + 1, md.statements = new Statement[length], 0, length); + } + // A P I + + public CompilationUnitDeclaration parse(ICompilationUnit sourceUnit, CompilationResult compilationResult) { + // parses a compilation unit and manages error handling (even bugs....) + + CompilationUnitDeclaration unit; + try { + /* automaton initialization */ + initialize(); + goForCompilationUnit(); + + /* scanner initialization */ + scanner.setSource(sourceUnit.getContents()); + + /* unit creation */ + referenceContext = + compilationUnit = new CompilationUnitDeclaration(problemReporter, compilationResult, scanner.source.length); + /* run automaton */ + parse(); + } finally { + unit = compilationUnit; + compilationUnit = null; // reset parser + } + return unit; + } + // A P I + + public CompilationUnitDeclaration parse(ICompilationUnit sourceUnit, CompilationResult compilationResult, int start, int end) { + // parses a compilation unit and manages error handling (even bugs....) + + CompilationUnitDeclaration unit; + try { + /* automaton initialization */ + initialize(); + goForCompilationUnit(); + + /* scanner initialization */ + scanner.setSource(sourceUnit.getContents()); + scanner.resetTo(start, end); + /* unit creation */ + referenceContext = + compilationUnit = new CompilationUnitDeclaration(problemReporter, compilationResult, scanner.source.length); + /* run automaton */ + parse(); + } finally { + unit = compilationUnit; + compilationUnit = null; // reset parser + } + return unit; + } + /** + * Returns this parser's problem reporter initialized with its reference context. + * Also it is assumed that a problem is going to be reported, so initializes + * the compilation result's line positions. + */ + public ProblemReporter problemReporter() { + if (scanner.recordLineSeparator) { + compilationUnit.compilationResult.lineSeparatorPositions = scanner.getLineEnds(); + } + problemReporter.referenceContext = referenceContext; + return problemReporter; + } + protected void pushIdentifier() { + /*push the consumeToken on the identifier stack. + Increase the total number of identifier in the stack. + identifierPtr points on the next top */ + + try { + identifierStack[++identifierPtr] = scanner.getCurrentIdentifierSource(); + identifierPositionStack[identifierPtr] = (((long) scanner.startPosition) << 32) + (scanner.currentPosition - 1); + } catch (IndexOutOfBoundsException e) { + /*---stack reallaocation (identifierPtr is correct)---*/ + int oldStackLength = identifierStack.length; + char[][] oldStack = identifierStack; + identifierStack = new char[oldStackLength + 20][]; + System.arraycopy(oldStack, 0, identifierStack, 0, oldStackLength); + identifierStack[identifierPtr] = scanner.getCurrentTokenSource(); + /*identifier position stack*/ + long[] oldPos = identifierPositionStack; + identifierPositionStack = new long[oldStackLength + 20]; + System.arraycopy(oldPos, 0, identifierPositionStack, 0, oldStackLength); + identifierPositionStack[identifierPtr] = (((long) scanner.startPosition) << 32) + (scanner.currentPosition - 1); + }; + + try { + identifierLengthStack[++identifierLengthPtr] = 1; + } catch (IndexOutOfBoundsException e) { + /*---stack reallocation (identifierLengthPtr is correct)---*/ + int oldStackLength = identifierLengthStack.length; + int oldStack[] = identifierLengthStack; + identifierLengthStack = new int[oldStackLength + 10]; + System.arraycopy(oldStack, 0, identifierLengthStack, 0, oldStackLength); + identifierLengthStack[identifierLengthPtr] = 1; + }; + + } + protected void pushIdentifier(int flag) { + /*push a special flag on the stack : + -zero stands for optional Name + -negative number for direct ref to base types. + identifierLengthPtr points on the top */ + + try { + identifierLengthStack[++identifierLengthPtr] = flag; + } catch (IndexOutOfBoundsException e) { + /*---stack reallaocation (identifierLengthPtr is correct)---*/ + int oldStackLength = identifierLengthStack.length; + int oldStack[] = identifierLengthStack; + identifierLengthStack = new int[oldStackLength + 10]; + System.arraycopy(oldStack, 0, identifierLengthStack, 0, oldStackLength); + identifierLengthStack[identifierLengthPtr] = flag; + }; + + } + protected void pushOnAstLengthStack(int pos) { + try { + astLengthStack[++astLengthPtr] = pos; + } catch (IndexOutOfBoundsException e) { + int oldStackLength = astLengthStack.length; + int[] oldPos = astLengthStack; + astLengthStack = new int[oldStackLength + StackIncrement]; + System.arraycopy(oldPos, 0, astLengthStack, 0, oldStackLength); + astLengthStack[astLengthPtr] = pos; + } + } + protected void pushOnAstStack(AstNode node) { + /*add a new obj on top of the ast stack + astPtr points on the top*/ + + try { + astStack[++astPtr] = node; + } catch (IndexOutOfBoundsException e) { + int oldStackLength = astStack.length; + AstNode[] oldStack = astStack; + astStack = new AstNode[oldStackLength + AstStackIncrement]; + System.arraycopy(oldStack, 0, astStack, 0, oldStackLength); + astPtr = oldStackLength; + astStack[astPtr] = node; + } + + try { + astLengthStack[++astLengthPtr] = 1; + } catch (IndexOutOfBoundsException e) { + int oldStackLength = astLengthStack.length; + int[] oldPos = astLengthStack; + astLengthStack = new int[oldStackLength + AstStackIncrement]; + System.arraycopy(oldPos, 0, astLengthStack, 0, oldStackLength); + astLengthStack[astLengthPtr] = 1; + } + } + protected void pushOnExpressionStack(Expression expr) { + + try { + expressionStack[++expressionPtr] = expr; + } catch (IndexOutOfBoundsException e) { + //expressionPtr is correct + int oldStackLength = expressionStack.length; + Expression[] oldStack = expressionStack; + expressionStack = new Expression[oldStackLength + ExpressionStackIncrement]; + System.arraycopy(oldStack, 0, expressionStack, 0, oldStackLength); + expressionStack[expressionPtr] = expr; + } + + try { + expressionLengthStack[++expressionLengthPtr] = 1; + } catch (IndexOutOfBoundsException e) { + int oldStackLength = expressionLengthStack.length; + int[] oldPos = expressionLengthStack; + expressionLengthStack = new int[oldStackLength + ExpressionStackIncrement]; + System.arraycopy(oldPos, 0, expressionLengthStack, 0, oldStackLength); + expressionLengthStack[expressionLengthPtr] = 1; + } + } + protected void pushOnExpressionStackLengthStack(int pos) { + try { + expressionLengthStack[++expressionLengthPtr] = pos; + } catch (IndexOutOfBoundsException e) { + int oldStackLength = expressionLengthStack.length; + int[] oldPos = expressionLengthStack; + expressionLengthStack = new int[oldStackLength + StackIncrement]; + System.arraycopy(oldPos, 0, expressionLengthStack, 0, oldStackLength); + expressionLengthStack[expressionLengthPtr] = pos; + } + } + protected void pushOnIntStack(int pos) { + + try { + intStack[++intPtr] = pos; + } catch (IndexOutOfBoundsException e) { + //intPtr is correct + int oldStackLength = intStack.length; + int oldStack[] = intStack; + intStack = new int[oldStackLength + StackIncrement]; + System.arraycopy(oldStack, 0, intStack, 0, oldStackLength); + intStack[intPtr] = pos; + } + } + protected static char[] readTable(String filename) throws java.io.IOException { + + //files are located at Parser.class directory + + InputStream stream = new BufferedInputStream(Parser.class.getResourceAsStream(filename)); + if (stream == null) { + throw new java.io.IOException(Util.bind("parser.missingFile", filename)); //$NON-NLS-1$ + } + byte[] bytes = null; + try { + bytes = Util.getInputStreamAsByteArray(stream, -1); + } finally { + try { + stream.close(); + } catch (IOException e) { + } + } + + //minimal integrity check (even size expected) + int length = bytes.length; + if (length % 2 != 0) + throw new java.io.IOException(Util.bind("parser.corruptedFile", filename)); //$NON-NLS-1$ + + // convert bytes into chars + char[] chars = new char[length / 2]; + int i = 0; + int charIndex = 0; + + while (true) { + chars[charIndex++] = (char) (((bytes[i++] & 0xFF) << 8) + (bytes[i++] & 0xFF)); + if (i == length) + break; + } + return chars; + } + /* Token check performed on every token shift once having entered + * recovery mode. + */ + public void recoveryTokenCheck() { + switch (currentToken) { + case TokenNameLBRACE : + { + RecoveredElement newElement = currentElement.updateOnOpeningBrace(scanner.currentPosition - 1); + lastCheckPoint = scanner.currentPosition; + if (newElement != null) { // null means nothing happened + restartRecovery = true; // opening brace detected + currentElement = newElement; + } + break; + } + case TokenNameRBRACE : + { + endPosition = this.flushAnnotationsDefinedPriorTo(scanner.currentPosition - 1); + RecoveredElement newElement = currentElement.updateOnClosingBrace(scanner.startPosition, scanner.currentPosition - 1); + lastCheckPoint = scanner.currentPosition; + if (newElement != currentElement) { + currentElement = newElement; + } + } + } + } + protected void reportSyntaxError(int act, int currentKind, int stateStackTop) { + + /* remember current scanner position */ + int startPos = scanner.startPosition; + int currentPos = scanner.currentPosition; + + String[] expectings; + String tokenName = name[symbol_index[currentKind]]; + + //fetch all "accurate" possible terminals that could recover the error + int start, end = start = asi(stack[stateStackTop]); + while (asr[end] != 0) + end++; + int length = end - start; + expectings = new String[length]; + if (length != 0) { + char[] indexes = new char[length]; + System.arraycopy(asr, start, indexes, 0, length); + for (int i = 0; i < length; i++) { + expectings[i] = name[symbol_index[indexes[i]]]; + } + } + + //if the pb is an EOF, try to tell the user that they are some + if (tokenName.equals(UNEXPECTED_EOF)) { + if (!this.checkAndReportBracketAnomalies(problemReporter())) { + char[] tokenSource; + try { + tokenSource = this.scanner.getCurrentTokenSource(); + } catch (Exception e) { + tokenSource = new char[] { + }; + } + problemReporter().parseError( + this.scanner.startPosition, + this.scanner.currentPosition - 1, + tokenSource, + tokenName, + expectings); + } + } else { //the next test is HEAVILY grammar DEPENDENT. + if ((length == 2) && (tokenName.equals(";")) //$NON-NLS-1$ + && (expectings[0] == "++") //$NON-NLS-1$ + && (expectings[1] == "--") //$NON-NLS-1$ + && (expressionPtr > -1)) { + // the ; is not the expected token ==> it ends a statement when an expression is not ended + problemReporter().invalidExpressionAsStatement(expressionStack[expressionPtr]); + } else { + char[] tokenSource; + try { + tokenSource = this.scanner.getCurrentTokenSource(); + } catch (Exception e) { + tokenSource = new char[] { + }; + } + problemReporter().parseError( + this.scanner.startPosition, + this.scanner.currentPosition - 1, + tokenSource, + tokenName, + expectings); + this.checkAndReportBracketAnomalies(problemReporter()); + } + } + /* reset scanner where it was */ + scanner.startPosition = startPos; + scanner.currentPosition = currentPos; + } + protected void resetModifiers() { + modifiers = AccDefault; + modifiersSourceStart = -1; // <-- see comment into modifiersFlag(int) + scanner.commentPtr = -1; + } + /* + * Reset context so as to resume to regular parse loop + */ + protected void resetStacks() { + + astPtr = -1; + astLengthPtr = -1; + expressionPtr = -1; + expressionLengthPtr = -1; + identifierPtr = -1; + identifierLengthPtr = -1; + intPtr = -1; + nestedMethod[nestedType = 0] = 0; // need to reset for further reuse + variablesCounter[nestedType] = 0; + dimensions = 0; + realBlockStack[realBlockPtr = 0] = 0; + recoveredStaticInitializerStart = 0; + listLength = 0; + } + /* + * Reset context so as to resume to regular parse loop + * If unable to reset for resuming, answers false. + * + * Move checkpoint location, reset internal stacks and + * decide which grammar goal is activated. + */ + protected boolean resumeAfterRecovery() { + + // reset internal stacks + this.resetStacks(); + + /* attempt to move checkpoint location */ + if (!this.moveRecoveryCheckpoint()) + return false; + + // only look for headers + if (referenceContext instanceof CompilationUnitDeclaration) { + goForHeaders(); + diet = true; // passed this point, will not consider method bodies + return true; + } + // does not know how to restart + return false; + } + /* + * Syntax error was detected. Will attempt to perform some recovery action in order + * to resume to the regular parse loop. + */ + protected boolean resumeOnSyntaxError() { + + /* request recovery initialization */ + if (currentElement == null) { + currentElement = this.buildInitialRecoveryState(); // build some recovered elements + } + /* do not investigate deeper in recovery when no recovered element */ + if (currentElement == null) + return false; + + /* manual forced recovery restart - after headers */ + if (restartRecovery) { + restartRecovery = false; + } + /* update recovery state with current error state of the parser */ + this.updateRecoveryState(); + + /* attempt to reset state in order to resume to parse loop */ + return this.resumeAfterRecovery(); + } + protected static int tAction(int state, int sym) { + return action[check(state + sym) == sym ? state + sym : state]; + } + public String toString() { + + String s = "identifierStack : char[][] = {"; //$NON-NLS-1$ + for (int i = 0; i <= identifierPtr; i++) { + s = s + "\"" + String.valueOf(identifierStack[i]) + "\","; //$NON-NLS-1$ //$NON-NLS-2$ + }; + s = s + "}\n"; //$NON-NLS-1$ + + s = s + "identierLengthStack : int[] = {"; //$NON-NLS-1$ + for (int i = 0; i <= identifierLengthPtr; i++) { + s = s + identifierLengthStack[i] + ","; //$NON-NLS-1$ + }; + s = s + "}\n"; //$NON-NLS-1$ + + s = s + "astLengthStack : int[] = {"; //$NON-NLS-1$ + for (int i = 0; i <= astLengthPtr; i++) { + s = s + astLengthStack[i] + ","; //$NON-NLS-1$ + }; + s = s + "}\n"; //$NON-NLS-1$ + s = s + "astPtr : int = " + String.valueOf(astPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ + + s = s + "intStack : int[] = {"; //$NON-NLS-1$ + for (int i = 0; i <= intPtr; i++) { + s = s + intStack[i] + ","; //$NON-NLS-1$ + }; + s = s + "}\n"; //$NON-NLS-1$ + + s = s + "expressionLengthStack : int[] = {"; //$NON-NLS-1$ + for (int i = 0; i <= expressionLengthPtr; i++) { + s = s + expressionLengthStack[i] + ","; //$NON-NLS-1$ + }; + s = s + "}\n"; //$NON-NLS-1$ + + s = s + "expressionPtr : int = " + String.valueOf(expressionPtr) + "\n"; //$NON-NLS-1$ //$NON-NLS-2$ + + s = s + "\n\n\n----------------Scanner--------------\n" + scanner.toString(); //$NON-NLS-1$ + return s; + + } + /* + * Update recovery state based on current parser/scanner state + */ + protected void updateRecoveryState() { + + /* expose parser state to recovery state */ + currentElement.updateFromParserState(); + + /* check and update recovered state based on current token, + this action is also performed when shifting token after recovery + got activated once. + */ + this.recoveryTokenCheck(); + } + protected void updateSourceDeclarationParts(int variableDeclaratorsCounter) { + //fields is a definition of fields that are grouped together like in + //public int[] a, b[], c + //which results into 3 fields. + + FieldDeclaration field; + int endTypeDeclarationPosition = -1 + astStack[astPtr - variableDeclaratorsCounter + 1].sourceStart; + for (int i = 0; i < variableDeclaratorsCounter - 1; i++) { + //last one is special(see below) + field = (FieldDeclaration) astStack[astPtr - i - 1]; + field.endPart1Position = endTypeDeclarationPosition; + field.endPart2Position = -1 + astStack[astPtr - i].sourceStart; + } + //last one + (field = (FieldDeclaration) astStack[astPtr]).endPart1Position = endTypeDeclarationPosition; + field.endPart2Position = field.declarationSourceEnd; + + } + protected void updateSourcePosition(Expression exp) { + //update the source Position of the expression + + //intStack : int int + //--> + //intStack : + + exp.sourceEnd = intStack[intPtr--]; + exp.sourceStart = intStack[intPtr--]; + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java index c685210..8eb108a 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/IPreferenceConstants.java @@ -11,75 +11,92 @@ Contributors: **********************************************************************/ package net.sourceforge.phpeclipse; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - -import net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider; -import org.eclipse.core.resources.IWorkspace; -import org.eclipse.core.resources.ResourcesPlugin; -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.IPluginDescriptor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.MultiStatus; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Status; -//import org.eclipse.jdt.internal.ui.JavaStatusConstants; -//import org.eclipse.jdt.internal.ui.JavaUIMessages; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.plugin.AbstractUIPlugin; - /** * The main plugin class to be used in the desktop. */ public interface IPreferenceConstants { - - public static final String LOCALHOST_PREF = "_localhost"; //$NON-NLS-1$ - public static final String DOCUMENTROOT_PREF = "_documentroot"; //$NON-NLS-1$ - public static final String USE_EXTERNAL_BROWSER_PREF = "_use_external_browser"; //$NON-NLS-1$ - public static final String EXTERNAL_BROWSER_PREF = "_external_browser"; //$NON-NLS-1$ - public static final String MYSQL_PREF = "_my_sql"; //$NON-NLS-1$ - public static final String APACHE_START_PREF = "_apache_start"; //$NON-NLS-1$ - public static final String APACHE_STOP_PREF = "_apache_stop"; //$NON-NLS-1$ - public static final String APACHE_RESTART_PREF = "_apache_restart"; //$NON-NLS-1$ - public static final String SHOW_OUTPUT_IN_CONSOLE = "_sho_output_in_console"; //$NON-NLS-1$ - public static final String EXTERNAL_PARSER_PREF = "_external_parser"; //$NON-NLS-1$ + public static final String LOCALHOST_PREF = "_localhost"; + public static final String DOCUMENTROOT_PREF = "_documentroot"; + public static final String USE_EXTERNAL_BROWSER_PREF = "_use_external_browser"; + public static final String EXTERNAL_BROWSER_PREF = "_external_browser"; + public static final String MYSQL_PREF = "_my_sql"; + public static final String APACHE_START_PREF = "_apache_start"; + public static final String APACHE_STOP_PREF = "_apache_stop"; + public static final String APACHE_RESTART_PREF = "_apache_restart"; + public static final String SHOW_OUTPUT_IN_CONSOLE = "_sho_output_in_console"; + public static final String EXTERNAL_PARSER_PREF = "_external_parser"; + public static final String PHP_PARSER_DEFAULT = "_php_parser_default"; + public static final String PHP_INTERNAL_PARSER = "_php_internal_parser"; + public static final String PHP_EXTERNAL_PARSER = "_php_external_parser"; + public static final String PHP_PARSE_ON_SAVE = "_php_parse_on_save"; + public static final String PHP_MULTILINE_COMMENT = "_php_multilineComment"; + public static final String PHP_MULTILINE_COMMENT_BOLD = "_php_multilineComment_bold"; + public static final String PHP_MULTILINE_COMMENT_ITALIC = "_php_multilineComment_italic"; + public static final String PHP_MULTILINE_COMMENT_UNDERLINE = "_php_multilineComment_underline"; + public static final String PHP_SINGLELINE_COMMENT = "_php_singlelineComment"; + public static final String PHP_SINGLELINE_COMMENT_BOLD = "_php_singlelineComment_bold"; + public static final String PHP_SINGLELINE_COMMENT_ITALIC = "_php_singlelineComment_italic"; + public static final String PHP_SINGLELINE_COMMENT_UNDERLINE = "_php_singlelineComment_underline"; + public static final String PHP_KEYWORD = "_php_keyword"; + public static final String PHP_KEYWORD_BOLD = "_php_keyword_bold"; + public static final String PHP_KEYWORD_ITALIC = "_php_keyword_italic"; + public static final String PHP_KEYWORD_UNDERLINE = "_php_keyword_underline"; + public static final String PHP_VARIABLE = "_php_variable"; + public static final String PHP_VARIABLE_BOLD = "_php_variable_bold"; + public static final String PHP_VARIABLE_ITALIC = "_php_variable_italic"; + public static final String PHP_VARIABLE_UNDERLINE = "_php_variable_underline"; + public static final String PHP_TYPE = "_php_type"; + public static final String PHP_TYPE_BOLD = "_php_type_bold"; + public static final String PHP_TYPE_ITALIC = "_php_type_italic"; + public static final String PHP_TYPE_UNDERLINE = "_php_type_underline"; + public static final String PHP_CONSTANT = "_php_constant"; + public static final String PHP_CONSTANT_BOLD = "_php_constant_bold"; + public static final String PHP_CONSTANT_ITALIC = "_php_constant_italic"; + public static final String PHP_CONSTANT_UNDERLINE = "_php_constant_underline"; + public static final String PHP_FUNCTIONNAME = "_php_functionname"; + public static final String PHP_FUNCTIONNAME_BOLD = "_php_functionname_bold"; + public static final String PHP_FUNCTIONNAME_ITALIC = "_php_functionname_italic"; + public static final String PHP_FUNCTIONNAME_UNDERLINE = "_php_functionname_underline"; + public static final String PHP_STRING = "_php_string"; + public static final String PHP_STRING_BOLD = "_php_string_bold"; + public static final String PHP_STRING_ITALIC = "_php_string_italic"; + public static final String PHP_STRING_UNDERLINE = "_php_string_underline"; + public static final String PHP_DEFAULT = "_php_default"; + public static final String PHP_DEFAULT_BOLD = "_php_default_bold"; + public static final String PHP_DEFAULT_ITALIC = "_php_default_italic"; + public static final String PHP_DEFAULT_UNDERLINE = "_php_default_underline"; + public static final String LINKED_POSITION_COLOR = "_linkedPositionColor"; + public static final String PHP_EDITOR_BACKGROUND = "_php_editor_background"; + public static final String PHP_USERDEF_XMLFILE = "_userdef_xmlfile"; + + /*Language stuff - under dev*/ + public static final String RESOURCE_BUNDLE = "_php_editor_res_bundle"; //$NON-NLS-1$ + public static final String LANGUAGE_DEFAULT = "net.sourceforge.phpeclipse.newPHPPreferencesMessages_en_GB"; + public static final String RESOURCE_BUNDLE_DE = "net.sourceforge.phpeclipse.newPHPPreferencesMessages_DE"; + public static final String RESOURCE_BUNDLE_FR = "net.sourceforge.phpeclipse.newPHPPreferencesMessages_FR"; + public static final String RESOURCE_BUNDLE_EN_GB = "net.sourceforge.phpeclipse.newPHPPreferencesMessages_en_GB"; - public static final String PHP_PARSER_DEFAULT = "_php_parser_default"; //$NON-NLS-1$ - public static final String PHP_INTERNAL_PARSER = "_php_internal_parser"; //$NON-NLS-1$ - public static final String PHP_EXTERNAL_PARSER = "_php_external_parser"; //$NON-NLS-1$ - public static final String PHP_PARSE_ON_SAVE = "_php_parse_on_save"; //$NON-NLS-1$ - - public static final String PHP_MULTILINE_COMMENT = "_php_multilineComment"; //$NON-NLS-1$ - public static final String PHP_SINGLELINE_COMMENT = "_php_singlelineComment"; //$NON-NLS-1$ - public static final String PHP_KEYWORD = "_php_keyword"; //$NON-NLS-1$ - public static final String PHP_VARIABLE = "_php_variable"; //$NON-NLS-1$ - public static final String PHP_FUNCTIONNAME = "_php_functionname"; //$NON-NLS-1$ - public static final String PHP_STRING = "_php_string"; //$NON-NLS-1$ - public static final String PHP_DEFAULT = "_php_default"; //$NON-NLS-1$ - - public static final String LINKED_POSITION_COLOR= "_linkedPositionColor"; //$NON-NLS-1$ - + public static final String FORMATTER_TAB_SIZE = "_formatter_tab_size"; + public static final String SPACES_FOR_TABS = "_formatter_tab_size"; + + public static final String EDITOR_BOLD_SUFFIX = "_editor_bold_suffix"; /** Preference key for showing the line number ruler */ - public final static String LINE_NUMBER_RULER= "_lineNumberRuler"; //$NON-NLS-1$ + public final static String LINE_NUMBER_RULER = "_lineNumberRuler"; //$NON-NLS-1$ /** Preference key for the foreground color of the line numbers */ - public final static String LINE_NUMBER_COLOR= "_lineNumberColor"; //$NON-NLS-1$ - - public final static String FORMATTER_TAB_SIZE= "_formatterTabSize"; //$NON-NLS-1$ - public final static String SPACES_FOR_TABS = "false"; - + public final static String LINE_NUMBER_COLOR = "_lineNumberColor"; //$NON-NLS-1$ + public final static String PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT = "_defaultBackgroundColor"; //$NON-NLS-1$ public final static String PREFERENCE_COLOR_BACKGROUND = "backgroundColor"; //$NON-NLS-1$ - + /** Preference key for content assist proposal color */ - public final static String PROPOSALS_FOREGROUND= "content_assist_proposals_foreground"; //$NON-NLS-1$ + public final static String PROPOSALS_FOREGROUND = "content_assist_proposals_foreground"; //$NON-NLS-1$ /** Preference key for content assist proposal color */ - public final static String PROPOSALS_BACKGROUND= "content_assist_proposals_background"; //$NON-NLS-1$ + public final static String PROPOSALS_BACKGROUND = "content_assist_proposals_background"; //$NON-NLS-1$ + public static final String EDITOR_EVALUTE_TEMPORARY_PROBLEMS = null; + public static final String EDITOR_CORRECTION_INDICATION = null; - public static final String PHP_OUTLINE_CLASS = "_php_outline_class"; //$NON-NLS-1$ - public static final String PHP_OUTLINE_FUNC = "_php_outline_func"; //$NON-NLS-1$ - public static final String PHP_OUTLINE_VAR = "_php_outline_var"; //$NON-NLS-1$ + public static final String PHP_OUTLINE_CLASS = "_php_outline_class"; //$NON-NLS-1$ + public static final String PHP_OUTLINE_FUNC = "_php_outline_func"; //$NON-NLS-1$ + public static final String PHP_OUTLINE_VAR = "_php_outline_var"; //$NON-NLS-1$ } \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPCore.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPCore.java index 81943ac..454c2e8 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPCore.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPCore.java @@ -3,16 +3,14 @@ package net.sourceforge.phpeclipse; import java.util.ArrayList; import java.util.List; +import net.sourceforge.phpeclipse.resourcesview.PHPFile; +import net.sourceforge.phpeclipse.resourcesview.PHPProject; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; -import net.sourceforge.phpeclipse.resourcesview.*; -import net.sourceforge.phpeclipse.resourcesview.PHPFile; -import net.sourceforge.phpeclipse.resourcesview.PHPProject; - public class PHPCore { public static IProject[] getPHPProjects() { @@ -26,7 +24,7 @@ public class PHPCore { } IProject[] phpProjects = new IProject[phpProjectsList.size()]; - return (IProject[]) phpProjectsList.toArray(phpProjects); + return (IProject[]) phpProjectsList.toArray(phpProjects); } public static PHPProject getPHPProject(String name) { @@ -76,7 +74,7 @@ public class PHPCore { System.err.println("Exception occurred in PHPCore#create(IProject): " + e.toString()); } - return null; + return null; } public static void addPHPNature(IProject project, IProgressMonitor monitor) throws CoreException { diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java new file mode 100644 index 0000000..5b9af53 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipseBasePreferencePage.java @@ -0,0 +1,208 @@ +package net.sourceforge.phpeclipse; + +import java.util.ArrayList; + +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.DirectoryFieldEditor; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.jface.preference.RadioGroupFieldEditor; +import org.eclipse.jface.preference.StringFieldEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +import net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages; + +public class PHPEclipseBasePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + + private SelectionListener SelectionListener; + private ModifyListener ModifyListener; + private ModifyListener TextModifyListener; + + private ArrayList CheckBoxes = new ArrayList(); + private ArrayList ComboBoxes = new ArrayList(); + private ArrayList TextBoxes = new ArrayList(); + private ArrayList RadioButtons = new ArrayList(); + + StringFieldEditor localHostSFE; + DirectoryFieldEditor documentRootDFE; + BooleanFieldEditor externalBrowserBFE; + StringFieldEditor externalBrowserSFE; + StringFieldEditor apacheStartSFE; + StringFieldEditor apacheStopSFE; + StringFieldEditor apacheRestartSFE; + StringFieldEditor mySQLCommandSFE; + RadioGroupFieldEditor chooseParser; + BooleanFieldEditor parseOnSave; + + public PHPEclipseBasePreferencePage() { + super(); + setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore()); + setDescription(PHPPreferencesMessages.getString("PHPBasePreferencePage.description")); //$NON-NLS-1$ + } + public void init(IWorkbench workbench) { + } + protected void performDefaults() { + localHostSFE.loadDefault(); + documentRootDFE.loadDefault(); + externalBrowserBFE.loadDefault(); + externalBrowserSFE.loadDefault(); + apacheStartSFE.loadDefault(); + apacheStopSFE.loadDefault(); + apacheRestartSFE.loadDefault(); + mySQLCommandSFE.loadDefault(); + chooseParser.loadDefault(); + parseOnSave.loadDefault(); + super.performDefaults(); + } + + public boolean performOk() { + localHostSFE.store(); + documentRootDFE.store(); + externalBrowserBFE.store(); + externalBrowserSFE.store(); + apacheStartSFE.store(); + apacheStopSFE.store(); + apacheRestartSFE.store(); + mySQLCommandSFE.store(); + chooseParser.store(); + parseOnSave.store(); + return super.performOk(); + } + + protected Control createContents(Composite parent) { + initializeDialogUnits(parent); + final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + Composite composite = new Composite(parent, SWT.LEFT); + composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + composite.setLayout(new GridLayout()); + //Create Websettings + Composite webSettingsComposite = new Composite(composite, SWT.NONE); + webSettingsComposite.setLayout(new GridLayout()); + webSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + Group webSettingsGroup = new Group(webSettingsComposite, SWT.NONE); + webSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup")); + webSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + webSettingsGroup.setLayout(new GridLayout()); + localHostSFE = + new StringFieldEditor( + IPreferenceConstants.LOCALHOST_PREF, + PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.localhost"), + webSettingsGroup); + localHostSFE.setPreferencePage(this); + localHostSFE.setPreferenceStore(getPreferenceStore()); + localHostSFE.load(); + documentRootDFE = + new DirectoryFieldEditor( + IPreferenceConstants.DOCUMENTROOT_PREF, + PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.docroot"), + webSettingsGroup); + documentRootDFE.setPreferencePage(this); + documentRootDFE.setPreferenceStore(getPreferenceStore()); + documentRootDFE.load(); + externalBrowserBFE = + new BooleanFieldEditor( + IPreferenceConstants.USE_EXTERNAL_BROWSER_PREF, + PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.useexternal"), + webSettingsGroup); + externalBrowserBFE.setPreferencePage(this); + externalBrowserBFE.setPreferenceStore(getPreferenceStore()); + externalBrowserBFE.load(); + externalBrowserSFE = + new StringFieldEditor( + IPreferenceConstants.EXTERNAL_BROWSER_PREF, + PHPPreferencesMessages.getString("PHPBasePreferencePage.websettingsGroup.browser"), + webSettingsGroup); + externalBrowserSFE.setPreferencePage(this); + externalBrowserSFE.setPreferenceStore(getPreferenceStore()); + externalBrowserSFE.load(); + + //Create apache + Composite apacheSettingsComposite = new Composite(composite, SWT.NULL); + apacheSettingsComposite.setLayout(new GridLayout()); + apacheSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + Group apacheSettingsGroup = new Group(apacheSettingsComposite, SWT.NONE); + apacheSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup")); + apacheSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + apacheSettingsGroup.setLayout(new GridLayout()); + apacheStartSFE = + new StringFieldEditor( + IPreferenceConstants.APACHE_START_PREF, + PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.start"), + apacheSettingsGroup); + apacheStartSFE.setPreferencePage(this); + apacheStartSFE.setPreferenceStore(getPreferenceStore()); + apacheStartSFE.load(); + apacheStopSFE = + new StringFieldEditor( + IPreferenceConstants.APACHE_STOP_PREF, + PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.stop"), + apacheSettingsGroup); + apacheStopSFE.setPreferencePage(this); + apacheStopSFE.setPreferenceStore(getPreferenceStore()); + apacheStopSFE.load(); + apacheRestartSFE = + new StringFieldEditor( + IPreferenceConstants.APACHE_RESTART_PREF, + PHPPreferencesMessages.getString("PHPBasePreferencePage.apacheGroup.restart"), + apacheSettingsGroup); + apacheRestartSFE.setPreferencePage(this); + apacheRestartSFE.setPreferenceStore(getPreferenceStore()); + apacheRestartSFE.load(); + + //Create mySQL + Composite mySQLSettingsComposite = new Composite(composite, SWT.NULL); + mySQLSettingsComposite.setLayout(new GridLayout()); + mySQLSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + Group mySQLSettingsGroup = new Group(mySQLSettingsComposite, SWT.NONE); + mySQLSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup")); + mySQLSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + mySQLSettingsGroup.setLayout(new GridLayout()); + mySQLCommandSFE = + new StringFieldEditor( + IPreferenceConstants.MYSQL_PREF, + PHPPreferencesMessages.getString("PHPBasePreferencePage.mySQLGroup.command"), + mySQLSettingsGroup); + mySQLCommandSFE.setPreferencePage(this); + mySQLCommandSFE.setPreferenceStore(getPreferenceStore()); + mySQLCommandSFE.load(); + + //Create parser settings composite + Composite parserSettingsComposite = new Composite(composite, SWT.NONE); + parserSettingsComposite.setLayout(new GridLayout()); + parserSettingsComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + Group parserSettingsGroup = new Group(parserSettingsComposite, SWT.NONE); + parserSettingsGroup.setText(PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers")); + parserSettingsGroup.setLayout(new GridLayout()); + parserSettingsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + chooseParser = + new RadioGroupFieldEditor( + IPreferenceConstants.PHP_PARSER_DEFAULT, + PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.choose"), + 1, + new String[][] { + { PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.internal"), IPreferenceConstants.PHP_INTERNAL_PARSER }, + { + PHPPreferencesMessages.getString("PHPBasePreferencePage.parsers.external"), IPreferenceConstants.PHP_EXTERNAL_PARSER } + }, parserSettingsGroup); + chooseParser.setPreferencePage(this); + chooseParser.setPreferenceStore(getPreferenceStore()); + chooseParser.load(); + parseOnSave = new BooleanFieldEditor(PHPeclipsePlugin.PHP_PARSE_ON_SAVE, "&Parse automatically on save", parserSettingsGroup); + parseOnSave.setPreferencePage(this); + parseOnSave.setPreferenceStore(getPreferenceStore()); + parseOnSave.load(); + + return composite; + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipsePreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipsePreferencePage.java deleted file mode 100644 index 8a047f1..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPEclipsePreferencePage.java +++ /dev/null @@ -1,115 +0,0 @@ -/********************************************************************** -Copyright (c) 2000, 2002 IBM Corp. and others. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html - -Contributors: - IBM Corporation - Initial implementation - Klaus Hartlage - www.eclipseproject.de -**********************************************************************/ -package net.sourceforge.phpeclipse; - -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.DirectoryFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.RadioGroupFieldEditor; -import org.eclipse.jface.preference.StringFieldEditor; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -/** - * - * @author khartlage - */ -public class PHPEclipsePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { - - public PHPEclipsePreferencePage() { - super(FieldEditorPreferencePage.GRID); - //Initialize the preference store we wish to use - setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore()); - } - - protected void createFieldEditors() { - final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - - StringFieldEditor localhost = new StringFieldEditor(PHPeclipsePlugin.LOCALHOST_PREF, "&Localhost:", 60, getFieldEditorParent()); - - DirectoryFieldEditor documentRoot = - new DirectoryFieldEditor(PHPeclipsePlugin.DOCUMENTROOT_PREF, "&DocumentRoot:", getFieldEditorParent()); - - BooleanFieldEditor useExternalBrowser = - new BooleanFieldEditor(PHPeclipsePlugin.USE_EXTERNAL_BROWSER_PREF, "&Use External Browser", getFieldEditorParent()); - - StringFieldEditor externalBrowser = - new StringFieldEditor(PHPeclipsePlugin.EXTERNAL_BROWSER_PREF, "&External Browser command:", 60, getFieldEditorParent()); - - StringFieldEditor startMySQL = - new StringFieldEditor(PHPeclipsePlugin.MYSQL_PREF, "&MySQL command:", 60, getFieldEditorParent()); - - StringFieldEditor startApache = - new StringFieldEditor(PHPeclipsePlugin.APACHE_START_PREF, "Start &Apache command:", 60, getFieldEditorParent()); - - StringFieldEditor stopApache = - new StringFieldEditor(PHPeclipsePlugin.APACHE_STOP_PREF, "&Stop Apache command:", 60, getFieldEditorParent()); - - StringFieldEditor restartApache = - new StringFieldEditor(PHPeclipsePlugin.APACHE_RESTART_PREF, "&Restart Apache command:", 60, getFieldEditorParent()); - - StringFieldEditor externalParser = - new StringFieldEditor(PHPeclipsePlugin.EXTERNAL_PARSER_PREF, "&External Parser command:", 60, getFieldEditorParent()); - - - RadioGroupFieldEditor chooseParser = new RadioGroupFieldEditor( - IPreferenceConstants.PHP_PARSER_DEFAULT, - "Choose PHP parser", - 1, - new String[][] { - {"Internal parser", - IPreferenceConstants.PHP_INTERNAL_PARSER - }, - {"External parser", - IPreferenceConstants.PHP_EXTERNAL_PARSER - } - }, - this.getFieldEditorParent()); - - BooleanFieldEditor parseOnSave = - new BooleanFieldEditor(PHPeclipsePlugin.PHP_PARSE_ON_SAVE, "&Parse automatically on save", getFieldEditorParent()); - - BooleanFieldEditor outlineShowClass = - new BooleanFieldEditor(PHPeclipsePlugin.PHP_OUTLINE_CLASS, "Show classes in outline", getFieldEditorParent()); - BooleanFieldEditor outlineShowFunc = - new BooleanFieldEditor(PHPeclipsePlugin.PHP_OUTLINE_FUNC, "Show functions in outline", getFieldEditorParent()); - BooleanFieldEditor outlineShowVar = - new BooleanFieldEditor(PHPeclipsePlugin.PHP_OUTLINE_VAR, "Show variables in outline", getFieldEditorParent()); - - - addField(localhost); - addField(documentRoot); - addField(useExternalBrowser); - addField(externalBrowser); - addField(startMySQL); - addField(startApache); - - addField(stopApache); - addField(restartApache); - - addField(externalParser); - - addField(chooseParser); - addField(parseOnSave); - addField(outlineShowClass) ; - addField(outlineShowFunc); - addField(outlineShowVar); - } - - /** - * @see IWorkbenchPreferencePage#init - */ - public void init(IWorkbench workbench) { - } - -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPLanguagePreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPLanguagePreferencePage.java new file mode 100644 index 0000000..fed2faf --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPLanguagePreferencePage.java @@ -0,0 +1,76 @@ +package net.sourceforge.phpeclipse; + +import java.util.ArrayList; + +import net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +public class PHPLanguagePreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + private ArrayList RadioButtons = new ArrayList(); + + protected Control createContents(Composite parent) { + Composite lingoComposite= new Composite(parent, SWT.NULL); + lingoComposite.setLayout(new GridLayout()); + Group lingoGroup= new Group(lingoComposite, SWT.NONE); + lingoGroup.setText(PHPPreferencesMessages.getString("PHPLanguagePreferencePage.preflingo")); + lingoGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + lingoGroup.setLayout(new GridLayout()); + Label lg = new Label(lingoGroup, SWT.WRAP); + lg.setText(PHPPreferencesMessages.getString("PHPLanguagePreferencePage.choose")); + addRadioButton(lingoGroup, PHPPreferencesMessages.getString("PHPLanguagePreferencePage.english"), IPreferenceConstants.RESOURCE_BUNDLE, IPreferenceConstants.RESOURCE_BUNDLE_EN_GB); //$NON-NLS-1$ + addRadioButton(lingoGroup, PHPPreferencesMessages.getString("PHPLanguagePreferencePage.german"), IPreferenceConstants.RESOURCE_BUNDLE, IPreferenceConstants.RESOURCE_BUNDLE_DE); //$NON-NLS-1$ + addRadioButton(lingoGroup, PHPPreferencesMessages.getString("PHPLanguagePreferencePage.french"), IPreferenceConstants.RESOURCE_BUNDLE, IPreferenceConstants.RESOURCE_BUNDLE_FR); //$NON-NLS-1$ + return lingoComposite; + } + public void init(IWorkbench arg0) { + } + private Button addRadioButton(Composite parent, String label, String key, String value) { + GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); + Button button= new Button(parent, SWT.RADIO); + button.setText(label); + button.setData(new String[] { key, value }); + button.setLayoutData(gd); + button.setSelection(value.equals(PHPeclipsePlugin.getDefault().getPreferenceStore().getString(key))); + RadioButtons.add(button); + return button; + } + + protected void performDefaults() { + IPreferenceStore store= getPreferenceStore(); + for (int i= 0; i < RadioButtons.size(); i++) { + Button button= (Button) RadioButtons.get(i); + String[] info= (String[]) button.getData(); + button.setSelection(info[1].equals(store.getDefaultString(info[0]))); + } + super.performDefaults(); + } + + public boolean performOk() { + IPreferenceStore store= PHPeclipsePlugin.getDefault().getPreferenceStore(); + for (int i= 0; i < RadioButtons.size(); i++) { + Button button= (Button) RadioButtons.get(i); + if (button.getSelection()) { + String[] info= (String[]) button.getData(); + store.setValue(info[0], info[1]); + } + } + PHPeclipsePlugin.getDefault().savePluginPreferences(); + PHPPreferencesMessages.setResourceBundle( + PHPeclipsePlugin.getDefault().getPreferenceStore().getString(IPreferenceConstants.RESOURCE_BUNDLE)); + + return super.performOk(); + } +} + diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPOutlinePreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPOutlinePreferencePage.java new file mode 100644 index 0000000..0366a7c --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPOutlinePreferencePage.java @@ -0,0 +1,56 @@ +/********************************************************************** +Copyright (c) 2000, 2002 IBM Corp. and others. +All rights reserved. This program and the accompanying materials +are made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html + +Contributors: + IBM Corporation - Initial implementation + Klaus Hartlage - www.eclipseproject.de +**********************************************************************/ +package net.sourceforge.phpeclipse; + +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.DirectoryFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.RadioGroupFieldEditor; +import org.eclipse.jface.preference.StringFieldEditor; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +/** + * + * @author khartlage + */ +public class PHPOutlinePreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage { + + public PHPOutlinePreferencePage() { + super(FieldEditorPreferencePage.GRID); + //Initialize the preference store we wish to use + setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore()); + } + + protected void createFieldEditors() { + final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + + BooleanFieldEditor outlineShowClass = + new BooleanFieldEditor(PHPeclipsePlugin.PHP_OUTLINE_CLASS, "Show classes in outline", getFieldEditorParent()); + BooleanFieldEditor outlineShowFunc = + new BooleanFieldEditor(PHPeclipsePlugin.PHP_OUTLINE_FUNC, "Show functions in outline", getFieldEditorParent()); + BooleanFieldEditor outlineShowVar = + new BooleanFieldEditor(PHPeclipsePlugin.PHP_OUTLINE_VAR, "Show variables in outline", getFieldEditorParent()); + + addField(outlineShowClass); + addField(outlineShowFunc); + addField(outlineShowVar); + } + + /** + * @see IWorkbenchPreferencePage#init + */ + public void init(IWorkbench workbench) { + } + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPSyntaxEditorPreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPSyntaxEditorPreferencePage.java new file mode 100644 index 0000000..22b06ff --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPSyntaxEditorPreferencePage.java @@ -0,0 +1,464 @@ +package net.sourceforge.phpeclipse; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.Map; + +import net.sourceforge.phpeclipse.preferences.ColorEditor; +import net.sourceforge.phpeclipse.preferences.OverlayPreferenceStore; +import net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.FileFieldEditor; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceConverter; +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.jface.text.source.ISourceViewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.custom.StyledText; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.List; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +/* + * The preference page for setting the PHP Editor options. + */ +public class PHPSyntaxEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { + + public final OverlayPreferenceStore.OverlayKey[] Keys = + new OverlayPreferenceStore.OverlayKey[] { + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_MULTILINE_COMMENT), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_MULTILINE_COMMENT_BOLD), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_MULTILINE_COMMENT_ITALIC), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_MULTILINE_COMMENT_UNDERLINE), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_SINGLELINE_COMMENT), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_SINGLELINE_COMMENT_BOLD), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_SINGLELINE_COMMENT_ITALIC), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_SINGLELINE_COMMENT_UNDERLINE), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_KEYWORD), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_KEYWORD_BOLD), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_KEYWORD_ITALIC), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_KEYWORD_UNDERLINE), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_VARIABLE), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_VARIABLE_BOLD), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_VARIABLE_ITALIC), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_VARIABLE_UNDERLINE), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_TYPE), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_TYPE_BOLD), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_TYPE_ITALIC), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_TYPE_UNDERLINE), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_CONSTANT), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_CONSTANT_BOLD), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_CONSTANT_ITALIC), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_CONSTANT_UNDERLINE), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_FUNCTIONNAME), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_FUNCTIONNAME_BOLD), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_FUNCTIONNAME_ITALIC), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_FUNCTIONNAME_UNDERLINE), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_STRING), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_STRING_BOLD), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_STRING_ITALIC), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_STRING_UNDERLINE), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_DEFAULT), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_DEFAULT_BOLD), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_DEFAULT_ITALIC), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, IPreferenceConstants.PHP_DEFAULT_UNDERLINE), + new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, IPreferenceConstants.PHP_USERDEF_XMLFILE)}; + + private final String[][] SyntaxColorListModel = + new String[][] { + { + PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.multiLineComment"), + IPreferenceConstants.PHP_MULTILINE_COMMENT }, + { + PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.singleLineComment"), + IPreferenceConstants.PHP_SINGLELINE_COMMENT }, + { + PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.keywords"), IPreferenceConstants.PHP_KEYWORD }, { + PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.variables"), IPreferenceConstants.PHP_VARIABLE }, { + PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.types"), IPreferenceConstants.PHP_TYPE }, { + PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.functions"), IPreferenceConstants.PHP_FUNCTIONNAME }, { + PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.constants"), IPreferenceConstants.PHP_CONSTANT }, { + PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.strings"), IPreferenceConstants.PHP_STRING }, { + PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.others"), IPreferenceConstants.PHP_DEFAULT } + }; + + private OverlayPreferenceStore OverlayStore; + + private Map ColorButtons = new HashMap(); + private SelectionListener ColorButtonListener = new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + } + public void widgetSelected(SelectionEvent e) { + ColorEditor editor = (ColorEditor) e.widget.getData(); + PreferenceConverter.setValue(OverlayStore, (String) ColorButtons.get(editor), editor.getColorValue()); + } + }; + + private Map CheckBoxes = new HashMap(); + private SelectionListener CheckBoxListener = new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + } + public void widgetSelected(SelectionEvent e) { + Button button = (Button) e.widget; + OverlayStore.setValue((String) CheckBoxes.get(button), button.getSelection()); + } + }; + + private List SyntaxColorList; + private ColorEditor SyntaxForegroundColorEditor; + private Button BoldCheckBox; + private Button ItalicCheckBox; + private Button UnderlineCheckBox; + private FileFieldEditor userdefPHPSyntaxFileFFE; + + public PHPSyntaxEditorPreferencePage() { + setDescription(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.description")); //$NON-NLS-1$ + setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore()); + OverlayStore = new OverlayPreferenceStore(getPreferenceStore(), Keys); + } + + public void init(IWorkbench workbench) { + } + + public void createControl(Composite parent) { + super.createControl(parent); + } + + private void handleSyntaxColorListSelection() { + int i = SyntaxColorList.getSelectionIndex(); + String key = SyntaxColorListModel[i][1]; + RGB rgb = PreferenceConverter.getColor(OverlayStore, key); + SyntaxForegroundColorEditor.setColorValue(rgb); + BoldCheckBox.setSelection(OverlayStore.getBoolean(key + "_bold")); + ItalicCheckBox.setSelection(OverlayStore.getBoolean(key + "_italic")); + UnderlineCheckBox.setSelection(OverlayStore.getBoolean(key + "_underline")); + } + + private Control createSyntaxPage(Composite parent) { + + Composite colorComposite = new Composite(parent, SWT.NULL); + colorComposite.setLayout(new GridLayout()); + + Label label = new Label(colorComposite, SWT.LEFT); + label.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.syntax")); //$NON-NLS-1$ + label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + Composite editorComposite = new Composite(colorComposite, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.marginHeight = 0; + layout.marginWidth = 0; + editorComposite.setLayout(layout); + GridData gd = new GridData(GridData.FILL_BOTH); + editorComposite.setLayoutData(gd); + + SyntaxColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); + gd = new GridData(GridData.FILL_BOTH); + gd.heightHint = convertHeightInCharsToPixels(5); + SyntaxColorList.setLayoutData(gd); + + Composite stylesComposite = new Composite(editorComposite, SWT.NONE); + layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + layout.numColumns = 2; + stylesComposite.setLayout(layout); + stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + label = new Label(stylesComposite, SWT.LEFT); + label.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.color")); //$NON-NLS-1$ + gd = new GridData(); + gd.horizontalAlignment = GridData.BEGINNING; + label.setLayoutData(gd); + + SyntaxForegroundColorEditor = new ColorEditor(stylesComposite); + Button foregroundColorButton = SyntaxForegroundColorEditor.getButton(); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalAlignment = GridData.BEGINNING; + foregroundColorButton.setLayoutData(gd); + + BoldCheckBox = new Button(stylesComposite, SWT.CHECK); + BoldCheckBox.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.bold")); //$NON-NLS-1$ + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalAlignment = GridData.BEGINNING; + gd.horizontalSpan = 2; + BoldCheckBox.setLayoutData(gd); + + ItalicCheckBox = new Button(stylesComposite, SWT.CHECK); + ItalicCheckBox.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.italic")); //$NON-NLS-1$ + ItalicCheckBox.setEnabled(false); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalAlignment = GridData.BEGINNING; + gd.horizontalSpan = 2; + ItalicCheckBox.setLayoutData(gd); + + UnderlineCheckBox = new Button(stylesComposite, SWT.CHECK); + UnderlineCheckBox.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.underline")); //$NON-NLS-1$ + UnderlineCheckBox.setEnabled(false); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalAlignment = GridData.BEGINNING; + gd.horizontalSpan = 2; + UnderlineCheckBox.setLayoutData(gd); + + Composite customSyntaxComposite = new Composite(colorComposite, SWT.NONE); + layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + layout.numColumns = 3; + stylesComposite.setLayout(layout); + stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + userdefPHPSyntaxFileFFE = + new FileFieldEditor( + IPreferenceConstants.PHP_USERDEF_XMLFILE, + PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.syntaxdialog"), + colorComposite); + userdefPHPSyntaxFileFFE.setPreferencePage(this); + userdefPHPSyntaxFileFFE.setPreferenceStore(getPreferenceStore()); + userdefPHPSyntaxFileFFE.load(); + + SyntaxColorList.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + // do nothing + } + public void widgetSelected(SelectionEvent e) { + handleSyntaxColorListSelection(); + } + }); + + foregroundColorButton.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + // do nothing + } + public void widgetSelected(SelectionEvent e) { + int i = SyntaxColorList.getSelectionIndex(); + String key = SyntaxColorListModel[i][1]; + + PreferenceConverter.setValue(OverlayStore, key, SyntaxForegroundColorEditor.getColorValue()); + } + }); + BoldCheckBox.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + // do nothing + } + public void widgetSelected(SelectionEvent e) { + int i = SyntaxColorList.getSelectionIndex(); + String key = SyntaxColorListModel[i][1]; + OverlayStore.setValue(key + "_bold", BoldCheckBox.getSelection()); + } + }); + + ItalicCheckBox.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + // do nothing + } + public void widgetSelected(SelectionEvent e) { + int i = SyntaxColorList.getSelectionIndex(); + String key = SyntaxColorListModel[i][1]; + OverlayStore.setValue(key + "_italic", ItalicCheckBox.getSelection()); + } + }); + + UnderlineCheckBox.addSelectionListener(new SelectionListener() { + public void widgetDefaultSelected(SelectionEvent e) { + // do nothing + } + public void widgetSelected(SelectionEvent e) { + int i = SyntaxColorList.getSelectionIndex(); + String key = SyntaxColorListModel[i][1]; + OverlayStore.setValue(key + "_underline", UnderlineCheckBox.getSelection()); + } + }); + return colorComposite; + } + + private void initializeViewerColors(ISourceViewer viewer) { + + IPreferenceStore store = OverlayStore; + if (store != null) { + + StyledText styledText = viewer.getTextWidget(); + } + } + + private Color createColor(IPreferenceStore store, String key, Display display) { + RGB rgb = null; + if (store.contains(key)) { + if (store.isDefault(key)) + rgb = PreferenceConverter.getDefaultColor(store, key); + else + rgb = PreferenceConverter.getColor(store, key); + if (rgb != null) + return new Color(display, rgb); + } + return null; + } + + private static void setEnabled(Control control, boolean enable) { + control.setEnabled(enable); + if (control instanceof Composite) { + Composite composite = (Composite) control; + Control[] children = composite.getChildren(); + for (int i = 0; i < children.length; i++) + setEnabled(children[i], enable); + } + } + + private static void indent(Control control) { + GridData gridData = new GridData(); + gridData.horizontalIndent = 20; + control.setLayoutData(gridData); + } + + private static void createDependency(final Button master, final Control slave) { + indent(slave); + master.addSelectionListener(new SelectionListener() { + public void widgetSelected(SelectionEvent e) { + slave.setEnabled(master.getSelection()); + } + + public void widgetDefaultSelected(SelectionEvent e) { + } + }); + } + + protected Control createContents(Composite parent) { + OverlayStore.load(); + OverlayStore.start(); + //Create overall composite + Composite composite = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + composite.setLayout(layout); + Composite syntaxComposite = new Composite(composite, SWT.NULL); + syntaxComposite.setLayout(new GridLayout()); + layout = new GridLayout(); + layout.numColumns = 3; + Group syntaxGroup = new Group(syntaxComposite, SWT.NONE); + syntaxGroup.setText(PHPPreferencesMessages.getString("PHPEditorSyntaxPreferencePage.foreground")); + syntaxGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + syntaxGroup.setLayout(layout); + createSyntaxPage(syntaxGroup); + + initialize(); + return composite; + } + + private void initialize() { + initializeFields(); + for (int i = 0; i < SyntaxColorListModel.length; i++) + SyntaxColorList.add(SyntaxColorListModel[i][0]); + SyntaxColorList.getDisplay().asyncExec(new Runnable() { + public void run() { + if (SyntaxColorList != null && !SyntaxColorList.isDisposed()) { + SyntaxColorList.select(0); + handleSyntaxColorListSelection(); + } + } + }); + } + + private void initializeFields() { + + Iterator e = ColorButtons.keySet().iterator(); + while (e.hasNext()) { + ColorEditor c = (ColorEditor) e.next(); + String key = (String) ColorButtons.get(c); + RGB rgb = PreferenceConverter.getColor(OverlayStore, key); + c.setColorValue(rgb); + } + + e = CheckBoxes.keySet().iterator(); + while (e.hasNext()) { + Button b = (Button) e.next(); + String key = (String) CheckBoxes.get(b); + b.setSelection(OverlayStore.getBoolean(key)); + } + } + + public boolean performOk() { + OverlayStore.propagate(); + IPreferenceStore store = getPreferenceStore(); + PHPeclipsePlugin.getDefault().savePluginPreferences(); + userdefPHPSyntaxFileFFE.store(); + return true; + } + + protected void performDefaults() { + OverlayStore.loadDefaults(); + initializeFields(); + handleSyntaxColorListSelection(); + userdefPHPSyntaxFileFFE.loadDefault(); + super.performDefaults(); + } + + public void dispose() { + if (OverlayStore != null) { + OverlayStore.stop(); + OverlayStore = null; + } + super.dispose(); + } + + private Control addColorButton(Composite composite, String label, String key, int indentation) { + Label labelControl = new Label(composite, SWT.NONE); + labelControl.setText(label); + GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent = indentation; + labelControl.setLayoutData(gd); + ColorEditor editor = new ColorEditor(composite); + Button button = editor.getButton(); + button.setData(editor); + gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + button.setLayoutData(gd); + button.addSelectionListener(ColorButtonListener); + ColorButtons.put(editor, key); + return composite; + } + + private Button addCheckBox(Composite parent, String label, String key, int indentation) { + Button checkBox = new Button(parent, SWT.CHECK); + checkBox.setText(label); + GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); + gd.horizontalIndent = indentation; + gd.horizontalSpan = 2; + checkBox.setLayoutData(gd); + checkBox.addSelectionListener(CheckBoxListener); + CheckBoxes.put(checkBox, key); + return checkBox; + } + + private void updateStatus(IStatus status) { + } + + /** + * @deprecated Inline to avoid reference to preference page + */ + public static boolean indicateQuixFixableProblems() { + // return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION); + return false; + } + + /** + * @deprecated Inline to avoid reference to preference page + */ + static public boolean synchronizeOutlineOnCursorMove() { + // return PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_SYNC_OUTLINE_ON_CURSOR_MOVE); + return false; + } + +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPSyntaxPreferencePage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPSyntaxPreferencePage.java deleted file mode 100644 index a182244..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPSyntaxPreferencePage.java +++ /dev/null @@ -1,64 +0,0 @@ -/********************************************************************** -Copyright (c) 2000, 2002 IBM Corp. and others. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html - -Contributors: - IBM Corporation - Initial implementation - Klaus Hartlage - www.eclipseproject.de -**********************************************************************/ -package net.sourceforge.phpeclipse; - -import org.eclipse.jface.preference.BooleanFieldEditor; -import org.eclipse.jface.preference.ColorFieldEditor; -import org.eclipse.jface.preference.FieldEditorPreferencePage; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPreferencePage; - -/** - * - * @author khartlage - */ -public class PHPSyntaxPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage, IPreferenceConstants { - - public PHPSyntaxPreferencePage() { - super(FieldEditorPreferencePage.GRID); - //Initialize the preference store we wish to use - setPreferenceStore(PHPeclipsePlugin.getDefault().getPreferenceStore()); - } - - protected void createFieldEditors() { - final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - - BooleanFieldEditor showLineNumbers = - new BooleanFieldEditor(PHPeclipsePlugin.LINE_NUMBER_RULER, "Show line numbers", getFieldEditorParent()); - this.addField(showLineNumbers); - - ColorFieldEditor multilineComment = - new ColorFieldEditor(PHP_MULTILINE_COMMENT, "Multi-line comment:", this.getFieldEditorParent()); - this.addField(multilineComment); - ColorFieldEditor singlelineComment = - new ColorFieldEditor(PHP_SINGLELINE_COMMENT, "Single-line comment:", this.getFieldEditorParent()); - this.addField(singlelineComment); - ColorFieldEditor keyWords = new ColorFieldEditor(PHP_KEYWORD, "Keywords:", this.getFieldEditorParent()); - this.addField(keyWords); - ColorFieldEditor variables = new ColorFieldEditor(PHP_VARIABLE, "Variables:", this.getFieldEditorParent()); - this.addField(variables); - ColorFieldEditor types = new ColorFieldEditor(PHP_FUNCTIONNAME, "Built-in functions:", this.getFieldEditorParent()); - this.addField(types); - ColorFieldEditor strings = new ColorFieldEditor(PHP_STRING, "Strings:", this.getFieldEditorParent()); - this.addField(strings); - ColorFieldEditor others = new ColorFieldEditor(PHP_DEFAULT, "Others:", this.getFieldEditorParent()); - this.addField(others); - } - - /** - * @see IWorkbenchPreferencePage#init - */ - public void init(IWorkbench workbench) { - } - -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java index 41eae55..0cb4ae8 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/PHPeclipsePlugin.java @@ -11,16 +11,13 @@ Contributors: **********************************************************************/ package net.sourceforge.phpeclipse; -import java.util.MissingResourceException; -import java.util.ResourceBundle; - import net.sourceforge.phpdt.internal.ui.preferences.TemplatePreferencePage; import net.sourceforge.phpdt.internal.ui.viewsupport.ImageDescriptorRegistry; import net.sourceforge.phpeclipse.phpeditor.PHPDocumentProvider; -import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider; import net.sourceforge.phpeclipse.resourcesview.PHPElement; import net.sourceforge.phpeclipse.resourcesview.PHPElementAdapterFactory; import net.sourceforge.phpeclipse.resourcesview.ResourceAdapterFactory; + import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; @@ -39,6 +36,9 @@ import org.eclipse.ui.IWorkbenchPage; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.plugin.AbstractUIPlugin; +import net.sourceforge.phpeclipse.phpeditor.PHPSyntaxRdr; +import net.sourceforge.phpeclipse.phpeditor.util.PHPColorProvider; + /** * The main plugin class to be used in the desktop. */ @@ -60,7 +60,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon public static final String PLUGIN_ID = "net.sourceforge.phpeclipse"; //$NON-NLS-1$ public final static String PHP_NATURE_ID = PLUGIN_ID + ".phpnature"; public static final String PHP_RESOURCES_VIEW_ID = PLUGIN_ID + ".resourcesview.ViewPHPResources"; //$NON-NLS-1$ - + //The shared instance. private static PHPeclipsePlugin plugin; //Resource bundle. @@ -100,11 +100,11 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon super(descriptor); plugin = this; setJVM(); -// try { -// resourceBundle = ResourceBundle.getBundle("net.sourceforge.PHPeclipsePluginResources"); -// } catch (MissingResourceException x) { -// resourceBundle = null; -// } + // try { + // resourceBundle = ResourceBundle.getBundle("net.sourceforge.PHPeclipsePluginResources"); + // } catch (MissingResourceException x) { + // resourceBundle = null; + // } } public static ImageDescriptorRegistry getImageDescriptorRegistry() { @@ -113,7 +113,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon private ImageDescriptorRegistry internalGetImageDescriptorRegistry() { if (fImageDescriptorRegistry == null) - fImageDescriptorRegistry= new ImageDescriptorRegistry(); + fImageDescriptorRegistry = new ImageDescriptorRegistry(); return fImageDescriptorRegistry; } // @TODO: refactor this into a better method name ! @@ -174,7 +174,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon } public static IWorkbenchPage getActivePage() { - return getDefault().getActivePage(); + return PHPeclipsePlugin.getActivePage(); } public static IWorkbenchWindow getActiveWorkbenchWindow() { @@ -210,9 +210,10 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon // public static void log(Throwable e) { // log(new Status(IStatus.ERROR, getPluginId(), JavaStatusConstants.INTERNAL_ERROR, JavaUIMessages.getString("JavaPlugin.internal_error"), e)); //$NON-NLS-1$ // } + public static void log(int severity, String message) { - Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message, null) ; - log(status) ; + Status status = new Status(severity, PLUGIN_ID, IStatus.OK, message, null); + log(status); } public static void log(Throwable e) { log(new Status(IStatus.ERROR, PLUGIN_ID, IStatus.ERROR, "PHPeclipsePlugin.internalErrorOccurred", e)); //$NON-NLS-1$ @@ -229,21 +230,21 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon * Returns the string from the plugin's resource bundle, * or 'key' if not found. */ -// public static String getResourceString(String key) { -// ResourceBundle bundle = PHPeclipsePlugin.getDefault().getResourceBundle(); -// try { -// return bundle.getString(key); -// } catch (MissingResourceException e) { -// return key; -// } -// } + // public static String getResourceString(String key) { + // ResourceBundle bundle = PHPeclipsePlugin.getDefault().getResourceBundle(); + // try { + // return bundle.getString(key); + // } catch (MissingResourceException e) { + // return key; + // } + // } /** * Returns the plugin's resource bundle, */ -// public ResourceBundle getResourceBundle() { -// return resourceBundle; -// } + // public ResourceBundle getResourceBundle() { + // return resourceBundle; + // } protected void initializeDefaultPreferences(IPreferenceStore store) { // windows preferences: @@ -258,9 +259,7 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon } else { store.setDefault(EXTERNAL_BROWSER_PREF, "netscape {0}"); } - store.setDefault(DOCUMENTROOT_PREF, getWorkspace().getRoot().getLocation().toString() ); - // store.setDefault(DOCUMENTROOT_PREF, "c:\\eclipse\\workspace"); // WIN_32 - // store.setDefault(DOCUMENTROOT_PREF, "/eclipse/workspace"); // UNIX + store.setDefault(DOCUMENTROOT_PREF, getWorkspace().getRoot().getLocation().toString()); if ((jvm == WINDOWS_9x) || (jvm == WINDOWS_NT)) { store.setDefault(EXTERNAL_PARSER_PREF, "c:\\apache\\php\\php -l -f {0}"); store.setDefault(MYSQL_PREF, "c:\\apache\\mysql\\bin\\mysqld.exe --standalone"); @@ -273,43 +272,55 @@ public class PHPeclipsePlugin extends AbstractUIPlugin implements IPreferenceCon store.setDefault(APACHE_START_PREF, "/apache/apache -c \"DocumentRoot \"{0}\"\""); store.setDefault(APACHE_STOP_PREF, "/apache/apache.exe -k shutdown"); store.setDefault(APACHE_RESTART_PREF, "/apache/apache -k restart"); - + } store.setDefault(PHP_PARSER_DEFAULT, PHP_EXTERNAL_PARSER); store.setDefault(PHP_INTERNAL_PARSER, "false"); store.setDefault(PHP_EXTERNAL_PARSER, "true"); - + store.setDefault(PHP_PARSE_ON_SAVE, "true"); - + // show line numbers: store.setDefault(LINE_NUMBER_RULER, "false"); store.setDefault(FORMATTER_TAB_SIZE, "4"); - + // php syntax highlighting + store.setDefault(PHP_USERDEF_XMLFILE, ""); //assume there is none chooA + PreferenceConverter.setDefault(store, PHP_MULTILINE_COMMENT, PHPColorProvider.MULTI_LINE_COMMENT); PreferenceConverter.setDefault(store, PHP_SINGLELINE_COMMENT, PHPColorProvider.SINGLE_LINE_COMMENT); PreferenceConverter.setDefault(store, PHP_KEYWORD, PHPColorProvider.KEYWORD); PreferenceConverter.setDefault(store, PHP_VARIABLE, PHPColorProvider.VARIABLE); PreferenceConverter.setDefault(store, PHP_FUNCTIONNAME, PHPColorProvider.FUNCTION_NAME); - PreferenceConverter.setDefault(store, PHP_STRING, PHPColorProvider.STRING); + PreferenceConverter.setDefault(store, PHP_CONSTANT, PHPColorProvider.CONSTANT); + PreferenceConverter.setDefault(store, PHP_TYPE, PHPColorProvider.TYPE); + PreferenceConverter.setDefault(store, PHP_STRING, PHPColorProvider.STRING); PreferenceConverter.setDefault(store, PHP_DEFAULT, PHPColorProvider.DEFAULT); + PreferenceConverter.setDefault(store, PHP_EDITOR_BACKGROUND, PHPColorProvider.BACKGROUND); PreferenceConverter.setDefault(store, LINKED_POSITION_COLOR, PHPColorProvider.LINKED_POSITION_COLOR); PreferenceConverter.setDefault(store, LINE_NUMBER_COLOR, PHPColorProvider.LINE_NUMBER_COLOR); - store.setDefault(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, "true"); //$NON-NLS-1$ + store.setDefault(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, "true"); PreferenceConverter.setDefault(store, PREFERENCE_COLOR_BACKGROUND, PHPColorProvider.BACKGROUND_COLOR); + //language stuff + store.setDefault(RESOURCE_BUNDLE, LANGUAGE_DEFAULT); + store.setDefault(RESOURCE_BUNDLE_EN_GB, "true"); + store.setDefault(RESOURCE_BUNDLE_DE, "false"); + store.setDefault(RESOURCE_BUNDLE_FR, "false"); + store.setDefault(PHP_OUTLINE_CLASS, "true"); //$NON-NLS-1$ store.setDefault(PHP_OUTLINE_FUNC, "true"); //$NON-NLS-1$ store.setDefault(PHP_OUTLINE_VAR, "true"); //$NON-NLS-1$ - TemplatePreferencePage.initDefaults(store); + TemplatePreferencePage.initDefaults(store); + new PHPSyntaxRdr(); //this will initialize the static fields in the syntaxrdr class } - - public void startup() throws CoreException { + + public void startup() throws CoreException { super.startup(); - IAdapterManager manager= Platform.getAdapterManager(); + IAdapterManager manager = Platform.getAdapterManager(); manager.registerAdapters(new PHPElementAdapterFactory(), PHPElement.class); manager.registerAdapters(new ResourceAdapterFactory(), IResource.class); } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_DE.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_DE.properties new file mode 100644 index 0000000..c837737 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_DE.properties @@ -0,0 +1,65 @@ +######################################### +# PHPProjectLibraryPage +######################################### + +PHPProjectLibraryPage.elementNotIProject=FEHLER: Element ist kein IProject +PHPProjectLibraryPage.project=Projekt +PHPProjectLibraryPage.tabName=Projekte + + +######################################### +# Property Pages +######################################### + +PHPProjectPropertyPage.phpProjectClosed=Das ausgewählte Projekt ist ein PHP Projekt, aber es ist geschlossen. +PHPProjectPropertyPage.performOkExceptionDialogTitle=Kann nicht sichern +PHPProjectPropertyPage.performOkExceptionDialogMessage=FEHLER: Kann die Projekt Eigenschaften nicht sichern + +######################################### +# Preference Pages +######################################### +PHPBasePreferencePage.description=PHP Voreinstellungen +PHPBasePreferencePage.websettingsGroup=Webserver Einstellungen +PHPBasePreferencePage.websettingsGroup.localhost=Localhost +PHPBasePreferencePage.websettingsGroup.docroot=DocumentRoot +PHPBasePreferencePage.websettingsGroup.browser=Externes Browser Kommando +PHPBasePreferencePage.websettingsGroup.useexternal=Benutze externen Browser +PHPBasePreferencePage.apacheGroup=Apache Einstellungen +PHPBasePreferencePage.apacheGroup.start=Start Apache +PHPBasePreferencePage.apacheGroup.stop=Stop Apache +PHPBasePreferencePage.apacheGroup.restart=Restart Apache +PHPBasePreferencePage.mySQLGroup=MySQL Einstellungen +PHPBasePreferencePage.mySQLGroup.command=MySQL Kommando +PHPBasePreferencePage.parsers=Parser Einstellungen +PHPBasePreferencePage.parsers.pos=Parse beim Sichern +PHPBasePreferencePage.parsers.external=Externer Parser +PHPBasePreferencePage.parsers.internal=Interner Parser +PHPBasePreferencePage.parsers.choose=PHP Parser auswählen + +PHPEditorSyntaxPreferencePage.description:PHP Editor Preferences +PHPEditorSyntaxPreferencePage.foreground:Foreground settings +PHPEditorSyntaxPreferencePage.syntax:Syntax highlighting +PHPEditorSyntaxPreferencePage.color:Colour +PHPEditorSyntaxPreferencePage.bold:Bold +PHPEditorSyntaxPreferencePage.italic:Italic +PHPEditorSyntaxPreferencePage.underline:Underline +PHPEditorSyntaxPreferencePage.multiLineComment=Multi-line comment +PHPEditorSyntaxPreferencePage.singleLineComment=Single-line comment +PHPEditorSyntaxPreferencePage.keywords=Keywords +PHPEditorSyntaxPreferencePage.variables=Variables +PHPEditorSyntaxPreferencePage.types=Types +PHPEditorSyntaxPreferencePage.functions=Functions +PHPEditorSyntaxPreferencePage.constants=Constants +PHPEditorSyntaxPreferencePage.strings=Strings +PHPEditorSyntaxPreferencePage.others=Others +PHPEditorSyntaxPreferencePage.syntaxdialog=Custom PHP Syntax File: +PHPEditorSyntaxPreferencePage.browse=Browse.. +PHPEditorSyntaxPreferencePage.textfont=Text font + +PHPLanguagePreferencePage.description=PHP Editor Language +PHPLanguagePreferencePage.preflingo=PHP Language Preference +PHPLanguagePreferencePage.choose=Choose Language +PHPLanguagePreferencePage.english=Englisch +PHPLanguagePreferencePage.german=Deutsch +PHPLanguagePreferencePage.french=Frensch + diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_FR.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_FR.properties new file mode 100644 index 0000000..2963607 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_FR.properties @@ -0,0 +1,65 @@ +######################################### +# PHPProjectLibraryPage +######################################### + +PHPProjectLibraryPage.elementNotIProject=ERROR: Element not IProject +PHPProjectLibraryPage.project=Project +PHPProjectLibraryPage.tabName=Projects + + +######################################### +# Property Pages +######################################### + +PHPProjectPropertyPage.phpProjectClosed=The project selected is a PHP project, but is closed. +PHPProjectPropertyPage.performOkExceptionDialogTitle=Unable to save +PHPProjectPropertyPage.performOkExceptionDialogMessage=ERROR: Unable to save project properties. + +######################################### +# Preference Pages +######################################### +PHPBasePreferencePage.description=PHP Preferences +PHPBasePreferencePage.websettingsGroup=Webserver Settings +PHPBasePreferencePage.websettingsGroup.localhost=Localhost +PHPBasePreferencePage.websettingsGroup.docroot=DocumentRoot +PHPBasePreferencePage.websettingsGroup.browser=External browser command +PHPBasePreferencePage.websettingsGroup.useexternal=Use external browser +PHPBasePreferencePage.apacheGroup=Apache Settings +PHPBasePreferencePage.apacheGroup.start=Start Apache +PHPBasePreferencePage.apacheGroup.stop=Stop Apache +PHPBasePreferencePage.apacheGroup.restart=Restart Apache +PHPBasePreferencePage.mySQLGroup=MySQL Settings +PHPBasePreferencePage.mySQLGroup.command=MySQL command +PHPBasePreferencePage.parsers=Parsing settings +PHPBasePreferencePage.parsers.pos=Parse on save +PHPBasePreferencePage.parsers.external=External +PHPBasePreferencePage.parsers.internal=Internal +PHPBasePreferencePage.parsers.choose=Choose PHP Parser + +PHPEditorSyntaxPreferencePage.description:PHP Editor Preferences +PHPEditorSyntaxPreferencePage.foreground:Foreground settings +PHPEditorSyntaxPreferencePage.syntax:Syntax highlighting +PHPEditorSyntaxPreferencePage.color:Colour +PHPEditorSyntaxPreferencePage.bold:Bold +PHPEditorSyntaxPreferencePage.italic:Italic +PHPEditorSyntaxPreferencePage.underline:Underline +PHPEditorSyntaxPreferencePage.multiLineComment=Multi-line comment +PHPEditorSyntaxPreferencePage.singleLineComment=Single-line comment +PHPEditorSyntaxPreferencePage.keywords=Keywords +PHPEditorSyntaxPreferencePage.variables=Variables +PHPEditorSyntaxPreferencePage.types=Types +PHPEditorSyntaxPreferencePage.functions=Functions +PHPEditorSyntaxPreferencePage.constants=Constants +PHPEditorSyntaxPreferencePage.strings=Strings +PHPEditorSyntaxPreferencePage.others=Others +PHPEditorSyntaxPreferencePage.syntaxdialog=Custom PHP Syntax File: +PHPEditorSyntaxPreferencePage.browse=Browse.. +PHPEditorSyntaxPreferencePage.textfont=Text font + +PHPLanguagePreferencePage.description=PHP Editor Language +PHPLanguagePreferencePage.preflingo=PHP Language Preference +PHPLanguagePreferencePage.choose=Choose Language +PHPLanguagePreferencePage.english=Anglase +PHPLanguagePreferencePage.german=Deutsch +PHPLanguagePreferencePage.french=Francais + diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_en_GB.properties b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_en_GB.properties new file mode 100644 index 0000000..b007252 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/newPHPPreferencesMessages_en_GB.properties @@ -0,0 +1,64 @@ +######################################### +# PHPProjectLibraryPage +######################################### + +PHPProjectLibraryPage.elementNotIProject=ERROR: Element not IProject +PHPProjectLibraryPage.project=Project +PHPProjectLibraryPage.tabName=Projects + + +######################################### +# Property Pages +######################################### + +PHPProjectPropertyPage.phpProjectClosed=The project selected is a PHP project, but is closed. +PHPProjectPropertyPage.performOkExceptionDialogTitle=Unable to save +PHPProjectPropertyPage.performOkExceptionDialogMessage=ERROR: Unable to save project properties. + +######################################### +# Preference Pages +######################################### +PHPBasePreferencePage.description=PHP Preferences +PHPBasePreferencePage.websettingsGroup=Webserver Settings +PHPBasePreferencePage.websettingsGroup.localhost=Localhost +PHPBasePreferencePage.websettingsGroup.docroot=DocumentRoot +PHPBasePreferencePage.websettingsGroup.browser=External browser command +PHPBasePreferencePage.websettingsGroup.useexternal=Use external browser +PHPBasePreferencePage.apacheGroup=Apache Settings +PHPBasePreferencePage.apacheGroup.start=Start Apache +PHPBasePreferencePage.apacheGroup.stop=Stop Apache +PHPBasePreferencePage.apacheGroup.restart=Restart Apache +PHPBasePreferencePage.mySQLGroup=MySQL Settings +PHPBasePreferencePage.mySQLGroup.command=MySQL command +PHPBasePreferencePage.parsers=Parsing settings +PHPBasePreferencePage.parsers.pos=Parse on save +PHPBasePreferencePage.parsers.external=External +PHPBasePreferencePage.parsers.internal=Internal +PHPBasePreferencePage.parsers.choose=Choose PHP Parser + +PHPEditorSyntaxPreferencePage.description:PHP Editor Preferences +PHPEditorSyntaxPreferencePage.foreground:Foreground settings +PHPEditorSyntaxPreferencePage.syntax:Syntax highlighting +PHPEditorSyntaxPreferencePage.color:Colour +PHPEditorSyntaxPreferencePage.bold:Bold +PHPEditorSyntaxPreferencePage.italic:Italic +PHPEditorSyntaxPreferencePage.underline:Underline +PHPEditorSyntaxPreferencePage.multiLineComment=Multi-line comment +PHPEditorSyntaxPreferencePage.singleLineComment=Single-line comment +PHPEditorSyntaxPreferencePage.keywords=Keywords +PHPEditorSyntaxPreferencePage.variables=Variables +PHPEditorSyntaxPreferencePage.types=Types +PHPEditorSyntaxPreferencePage.functions=Functions +PHPEditorSyntaxPreferencePage.constants=Constants +PHPEditorSyntaxPreferencePage.strings=Strings +PHPEditorSyntaxPreferencePage.others=Others +PHPEditorSyntaxPreferencePage.syntaxdialog=Custom PHP Syntax File: +PHPEditorSyntaxPreferencePage.browse=Browse.. +PHPEditorSyntaxPreferencePage.textfont=Text font + +PHPLanguagePreferencePage.description=PHP Editor Language +PHPLanguagePreferencePage.preflingo=PHP Language Preference +PHPLanguagePreferencePage.choose=Choose Language +PHPLanguagePreferencePage.english=English +PHPLanguagePreferencePage.german=German +PHPLanguagePreferencePage.french=French diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSyntaxRdr.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSyntaxRdr.java new file mode 100644 index 0000000..fc456a4 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPSyntaxRdr.java @@ -0,0 +1,276 @@ +package net.sourceforge.phpeclipse.phpeditor; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.UnsupportedEncodingException; +import java.util.Vector; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.apache.xml.serialize.OutputFormat; +import org.apache.xml.serialize.Serializer; +import org.apache.xml.serialize.SerializerFactory; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.jface.preference.IPreferenceStore; +import org.w3c.dom.Attr; +import org.w3c.dom.Document; +import org.w3c.dom.NamedNodeMap; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +import net.sourceforge.phpeclipse.IPreferenceConstants; +import net.sourceforge.phpeclipse.PHPeclipsePlugin; +import net.sourceforge.phpeclipse.phpeditor.php.PHPConstant; +import net.sourceforge.phpeclipse.phpeditor.php.PHPElement; +import net.sourceforge.phpeclipse.phpeditor.php.PHPFunction; +import net.sourceforge.phpeclipse.phpeditor.php.PHPKeyword; +import net.sourceforge.phpeclipse.phpeditor.php.PHPType; + +/** + * PHPSyntaxRdr reads PHP specifics from an XML file (eg. keywords) + */ + +public class PHPSyntaxRdr { + private static final String PHPDEFAULT_FILE = "default-phpsyntax.xml"; //$NON-NLS-1$ + private static final String PHPSYNTAX_FILE = "phpsyntax.xml"; //$NON-NLS-1$ + private static final String USERSYNTAX_FILE = "usersyntax.xml"; //$NON-NLS-1$ + private static final String USERDEFAULT_FILE = "default-usersyntax.xml"; //$NON-NLS-1$ + private static final String PHPSYNTAX_TAG = "phpsyntax"; + private static final String KEYWORD_ATTR = "keyword"; + private static final String TYPE_ATTR = "type"; + private static final String CONSTANT_ATTR = "constant"; + private static final String FN_ATTR = "function"; + private static final String DESCRIPTION = "description"; + private static final String USAGE_ATTR = "usage"; + private static final String TOKENVAL_ATTR = "tokenval"; + private static IPreferenceStore store; + private static boolean hasXMLFileBeenRead = true; + + //The following variable is used to hold the syntax from + //the suers custom file - if that file should be changed, + //then all entries in this variable should be removed from + //the word list, reread from the file and then reinserted. + private static Vector userdefsyntaxdata; + + private static Vector syntaxdata; + + public PHPSyntaxRdr() { + syntaxdata = new Vector(); + store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + } + + public static void readInSyntax() { + try { + hasXMLFileBeenRead = true; + /*Attempt to read the syntax file from the metadata + * if this does not work, create metadata from default*/ + File syntaxFile = getSyntaxFile(); + if (syntaxFile.exists()) { + readFromFile(syntaxFile); + } else { + readFromStream(PHPSyntaxRdr.class.getResourceAsStream(PHPSYNTAX_FILE)); + saveToFile(syntaxFile); + } + /*Read the user-defined syntax file if it exists*/ + //String buffer = new String(store.getString(PHPeclipsePlugin.PHP_USERDEF_XMLFILE)); + if (store == null) + store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + String buffer = new String(store.getString(IPreferenceConstants.PHP_USERDEF_XMLFILE)); + if (!buffer.equals("") || buffer != null) { + readFromFile(buffer); + } + } catch (CoreException ce) { + ce.printStackTrace(); + } + } + + public static void readFromFile(String filename) { + try { + readFromFile(new File(filename)); + } catch (CoreException e) { + } + } + + public static void readFromFile(File file) throws CoreException { + InputStream stream = null; + try { + stream = new FileInputStream(file); + readFromStream(stream); + } catch (IOException e) { + throwReadException(e); + } finally { + try { + if (stream != null) { + stream.close(); + } + } catch (IOException e) { + } + } + } + public static void readFromStream(InputStream stream) throws CoreException { + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder parser = factory.newDocumentBuilder(); + Document document = parser.parse(new InputSource(stream)); + //Read in the Standard PHPSyntax "stuff" + NodeList elements = document.getElementsByTagName(PHPSYNTAX_TAG); + + int count = elements.getLength(); + for (int i = 0; i != count; i++) { + Node node = elements.item(i); + NamedNodeMap attributes = node.getAttributes(); + + if (attributes == null) + continue; + + String Keyword = getAttributeValue(attributes, KEYWORD_ATTR); + String Type = getAttributeValue(attributes, TYPE_ATTR); + String Function = getAttributeValue(attributes, FN_ATTR); + String Constant = getAttributeValue(attributes, CONSTANT_ATTR); + String Description = getAttributeValue(attributes, DESCRIPTION); + String Usage = getAttributeValue(attributes, USAGE_ATTR); + String Tokenval = getAttributeValue(attributes, TOKENVAL_ATTR); + + if (Keyword == null && Type == null && Function == null && Constant == null) { + //ignore as it is not a valid phpsyntax tag + } else { + if (Keyword != null) { + syntaxdata.addElement(new PHPKeyword(Keyword, Description, Tokenval)); + } else if (Type != null) { + syntaxdata.addElement(new PHPType(Type, Description)); + } else if (Function != null) { + syntaxdata.addElement(new PHPFunction(Function, Description, Usage)); + } else if (Constant != null) { + syntaxdata.addElement(new PHPConstant(Constant, Description)); + } + } + } + } catch (ParserConfigurationException e) { + throwReadException(e); + } catch (IOException e) { + throwReadException(e); + } catch (SAXException e) { + throwReadException(e); + } + } + + public static Vector getsyntaxdata() { + return (Vector) syntaxdata.clone(); + } + + public static void replaceUserDefFile() { + /*Replace the user-defined syntax file if it exists*/ + String buffer = new String(store.getString(IPreferenceConstants.PHP_USERDEF_XMLFILE)); + if (!buffer.equals("") || buffer == null) { + readFromFile(buffer); + } + } + + public static Vector getUserDefinitions() { + return (Vector) userdefsyntaxdata.clone(); + } + + private static File getSyntaxFile() { + IPath path = PHPeclipsePlugin.getDefault().getStateLocation(); + path = path.append(PHPSYNTAX_FILE); + return path.toFile(); + } + + private static String getAttributeValue(NamedNodeMap attributes, String name) { + Node node = attributes.getNamedItem(name); + return node == null ? null : node.getNodeValue(); + } + + public static void saveToFile(File file) throws CoreException { + OutputStream stream = null; + try { + stream = new FileOutputStream(file); + saveToStream(stream); + } catch (IOException e) { + throwWriteException(e); + } finally { + try { + if (stream != null) + stream.close(); + } catch (IOException e) { + } + } + } + + public static void saveToStream(OutputStream stream) throws CoreException { + try { + DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); + DocumentBuilder builder = factory.newDocumentBuilder(); + Document document = builder.newDocument(); + Node root = document.createElement("PHPStandardSyntax"); // $NON-NLS-1$ //$NON-NLS-1$ + document.appendChild(root); + for (int i = 0; i != syntaxdata.size(); i++) { + Object bufferobj = (Object) syntaxdata.get(i); + Attr name = null; + Node node = document.createElement(PHPSYNTAX_TAG); // $NON-NLS-1$ //$NON-NLS-1$ + root.appendChild(node); + NamedNodeMap attributes = node.getAttributes(); + if (bufferobj instanceof PHPType) + name = document.createAttribute(TYPE_ATTR); + if (bufferobj instanceof PHPKeyword) + name = document.createAttribute(KEYWORD_ATTR); + if (bufferobj instanceof PHPFunction) + name = document.createAttribute(FN_ATTR); + if (bufferobj instanceof PHPConstant) + name = document.createAttribute(CONSTANT_ATTR); + name.setValue(((PHPElement) bufferobj).getName()); + attributes.setNamedItem(name); + Attr description = document.createAttribute(DESCRIPTION); + description.setValue(((PHPElement) bufferobj).getDescription()); + attributes.setNamedItem(description); + if (bufferobj instanceof PHPKeyword) { + Attr tokenval = document.createAttribute(TOKENVAL_ATTR); + tokenval.setValue((new Integer(((PHPKeyword) bufferobj).gettokenval())).toString()); + attributes.setNamedItem(tokenval); + } + if (bufferobj instanceof PHPFunction) { + Attr usage = document.createAttribute(USAGE_ATTR); + usage.setValue(((PHPFunction) bufferobj).getUsage()); + attributes.setNamedItem(usage); + } + } + OutputFormat format = new OutputFormat(); + format.setPreserveSpace(true); + try { + Serializer serializer = SerializerFactory.getSerializerFactory("xml").makeSerializer(stream, format); + serializer.asDOMSerializer().serialize(document); + } catch (UnsupportedEncodingException e) { + } catch (IOException e) { + } //$NON-NLS-1$ + // Serializer serializer = SerializerFactory.getSerializer().makeSerializer(stream, format); //$NON-NLS-1$ + } catch (ParserConfigurationException e) { + throwWriteException(e); + // } catch (IOException e) { + // throwWriteException(e); + } + } + + private static void throwReadException(Throwable t) throws CoreException { + PHPeclipsePlugin.log(t); + // IStatus status= new JavaUIStatus(JavaStatusConstants.TEMPLATE_IO_EXCEPTION, + // TemplateMessages.getString("TemplateSet.error.read"), t); //$NON-NLS-1$ + // throw new JavaUIException(status); + } + + private static void throwWriteException(Throwable t) throws CoreException { + PHPeclipsePlugin.log(t); + // IStatus status= new JavaUIStatus(JavaStatusConstants.TEMPLATE_IO_EXCEPTION, + // TemplateMessages.getString("TemplateSet.error.write"), t); //$NON-NLS-1$ + // throw new JavaUIException(status); + } + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java index f4e6582..4851296 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPTextHover.java @@ -12,24 +12,25 @@ Contributors: package net.sourceforge.phpeclipse.phpeditor; import java.util.HashMap; +import java.util.Vector; -import net.sourceforge.phpeclipse.phpeditor.php.PHPFunctionDescription; -import net.sourceforge.phpeclipse.phpeditor.php.PHPFunctionNames; import net.sourceforge.phpeclipse.phpeditor.php.PHPWordExtractor; -import org.eclipse.jface.text.BadLocationException; + import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextHover; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.Region; import org.eclipse.swt.graphics.Point; +import net.sourceforge.phpeclipse.phpeditor.php.PHPElement; + /** * Example implementation for an ITextHover * which hovers over PHP code. */ public class PHPTextHover implements ITextHover { public static HashMap functionDescriptions = null; - + private static PHPWordExtractor phpWordDetector = new PHPWordExtractor(); /* (non-Javadoc) * Method declared on ITextHover @@ -39,15 +40,29 @@ public class PHPTextHover implements ITextHover { try { if (hoverRegion.getLength() > -1) { String word = textViewer.getDocument().get(hoverRegion.getOffset(), hoverRegion.getLength()); - if (functionDescriptions==null) { - functionDescriptions = new HashMap(997); - for (int i=0; i -// for (int i = 0; i < PHPKeywords.PHP_KEYWORS.length; i++) -// wordRule.addWord(PHPKeywords.PHP_KEYWORS[i], keyword); -// -// /*Read in the keywords from the XML file*/ -// PHPSyntaxRdr syntaxRdr = new PHPSyntaxRdr(); -// syntaxRdr.readFromFile( -// "C:\\eclipse\\workspace\\net.sourceforge.phpeclipse\\src\\net\\sourceforge\\phpeclipse\\phpeditor" -// + java.io.File.separator -// + "syntax.xml"); -// { -// Vector Vbuffer = syntaxRdr.getKeywords(); -// String VString = null; -// //Read keywords -// while ((Vbuffer != null) && (!Vbuffer.isEmpty() && ((VString = (String) Vbuffer.remove(0)) != null))) { -// wordRule.addWord(VString, keyword); -// } -// //Read functions - to be tested -// Vbuffer = syntaxRdr.getFunctions(); -// while ((Vbuffer != null) && (!Vbuffer.isEmpty() && ((VString = (String) Vbuffer.remove(0)) != null))) { -// wordRule.addWord(VString, functionName); -// } -// } -// -// //for (int i = 0; i < PHPFunctionNames.FUNCTION_NAMES.length; i++) -// // wordRule.addWord(PHPFunctionNames.FUNCTION_NAMES[i], functionName); -// //<--choochter - for (int i = 0; i < PHPKeywords.PHP_KEYWORS.length; i++) { - wordRule.addWord(PHPKeywords.PHP_KEYWORS[i], keyword); - } - for (int i = 0; i < PHPFunctionNames.FUNCTION_NAMES.length; i++) { - wordRule.addWord(PHPFunctionNames.FUNCTION_NAMES[i], functionName); - } - for (int i = 0; i < fgConstants.length; i++) { - wordRule.addWord(fgConstants[i], keyword); + + PHPSyntaxRdr.readInSyntax(); + Vector buffer = PHPSyntaxRdr.getsyntaxdata(); + String strbuffer = null; + PHPElement elbuffer = null; + while ((buffer != null) && (!buffer.isEmpty() && ((elbuffer = (PHPElement) buffer.remove(0)) != null))) { + if (elbuffer instanceof PHPKeyword) + wordRule.addWord(((PHPKeyword) elbuffer).getName(), keyword); + if (elbuffer instanceof PHPFunction) + wordRule.addWord(((PHPFunction) elbuffer).getName(), functionName); + if (elbuffer instanceof PHPType) + wordRule.addWord(elbuffer.getName(), type); + if (elbuffer instanceof PHPConstant) + wordRule.addWord(elbuffer.getName(), constant); } rules.add(wordRule); - IRule[] result = new IRule[rules.size()]; rules.toArray(result); setRules(result); } - - public void updateToken(PHPColorProvider provider) { - final IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); - - variable.setData(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PHP_VARIABLE)))); - keyword.setData(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PHP_KEYWORD)))); - functionName.setData(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PHP_FUNCTIONNAME)))); - string.setData(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PHP_STRING)))); - comment.setData(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PHP_SINGLELINE_COMMENT)))); - multi_comment.setData(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PHP_MULTILINE_COMMENT)))); - other.setData(new TextAttribute(provider.getColor(PreferenceConverter.getColor(store, PHP_DEFAULT)))); - - } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPConstant.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPConstant.java new file mode 100644 index 0000000..68119e7 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPConstant.java @@ -0,0 +1,16 @@ +package net.sourceforge.phpeclipse.phpeditor.php; + + +/** + * @author Choochter + * + * To change this generated comment edit the template variable "typecomment": + * Window>Preferences>Java>Templates. + * To enable and disable the creation of type comments go to + * Window>Preferences>Java>Code Generation. + */ +public class PHPConstant extends PHPElement{ + public PHPConstant(String Name, String Description){ + super(Name, Description); + } +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPElement.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPElement.java new file mode 100644 index 0000000..be19656 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPElement.java @@ -0,0 +1,33 @@ +package net.sourceforge.phpeclipse.phpeditor.php; + +/** + * @author choochter + */ +public abstract class PHPElement { + + private String ElementName; + private String ElementDescription; + + //Setters + public final void setName(String ElementName) + { this.ElementName = ElementName; } + public final void setDescription(String ElementDescription) + { this.ElementDescription = ElementDescription; } + + //Getters + public final String getName() { return ElementName; } + public final String getDescription() { return ElementDescription; } + + public PHPElement(){} + public PHPElement(String Name, String Description){ + setName(Name); + if ((Description == null) || (Description.equals(""))) + { + setDescription(Name +" - "); + } + else { + setDescription(Description); + } + } + +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPFunction.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPFunction.java new file mode 100644 index 0000000..2e45bdb --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPFunction.java @@ -0,0 +1,20 @@ +package net.sourceforge.phpeclipse.phpeditor.php; + +/** + * @author Choochter + * + * To change this generated comment edit the template variable "typecomment": + * Window>Preferences>Java>Templates. + * To enable and disable the creation of type comments go to + * Window>Preferences>Java>Code Generation. + */ +public class PHPFunction extends PHPElement{ + private String FunctionUsage; + public void setUsage(String Usage) {this.FunctionUsage = Usage;} + public String getUsage() { return this.FunctionUsage; } + + public PHPFunction(String Name, String Description, String Usage){ + super(Name, Description); + setUsage(Usage); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPFunctionDescription.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPFunctionDescription.java deleted file mode 100644 index 360f893..0000000 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPFunctionDescription.java +++ /dev/null @@ -1,2388 +0,0 @@ -/********************************************************************** -Copyright (c) 2000, 2002 IBM Corp. and others. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html - -Contributors: - IBM Corporation - Initial implementation - Klaus Hartlage - www.eclipseproject.de -**********************************************************************/ -package net.sourceforge.phpeclipse.phpeditor.php; - -/** - * PHP function - short description - */ -public class PHPFunctionDescription { - - public static String[] FUNCTION_DESCRIPTION = - { - "mixed COM_invoke(int module, string handler_name [, mixed arg [, mixed ...]])\n"+ - "Invokes a COM module", - - "int com_load(string module_name [, string remote_host [, int codepage [, string typelib]]])\n"+ - "Loads a COM module", - - "int abs(int number)\n"+ - "Return the absolute value of the number", - - "accept_connect - ", - "float acos(float number)\n"+ - "Return the arc cosine of the number in radians", - - "add - ", - "add_iovec - ", - "addaction - ", - "addcolor - ", - "addcslashes - ", - "addentry - ", - "addfill - ", - "addshape - ", - "addslashes - ", - "addstring - ", - "addstring - ", - "align - ", - "apache_child_terminate - ", - "apache_lookup_uri - ", - "apache_lookup_uri - ", - "apache_note - ", - "apache_sub_req - ", - "array_count_values - ", - "array_diff - ", - "array_filter - ", - "array_flip - ", - "array_intersect - ", - "array_keys - ", - "array_map - ", - "array_merge - ", - "array_merge_recursive - ", - "array_multisort - ", - "array_pad - ", - "array_pop - ", - "array_push - ", - "array_rand - ", - "array_reduce - ", - "array_reverse - ", - "array_search - ", - "array_shift - ", - "array_slice - ", - "array_splice - ", - "array_sum - ", - "array_unique - ", - "array_unshift - ", - "array_values - ", - "array_walk - ", - "arsort - ", - "asin - ", - "asort - ", - "aspell_check - ", - "aspell_check_raw - ", - "aspell_new - ", - "aspell_suggest - ", - "assert - ", - "assert_options - ", - "atan - ", - "atan2 - ", - "base64_decode - ", - "base64_encode - ", - "base_convert - ", - "basename - ", - "bcadd - ", - "bccomp - ", - "bcdiv - ", - "bcmod - ", - "bcmul - ", - "bcpow - ", - "bcscale - ", - "bcsqrt - ", - "bcsub - ", - "bin2hex - ", - "bind - ", - "bindec - ", - "bindtextdomain - ", - "build_iovec - ", - "bzclose - ", - "bzcompress - ", - "bzdecompress - ", - "bzerrno - ", - "bzerror - ", - "bzerrstr - ", - "bzflush - ", - "bzopen - ", - "bzread - ", - "bzwrite - ", - "call_user_func - ", - "call_user_func_array - ", - "call_user_method - ", - "call_user_method_array - ", - "ccvs_add - ", - "ccvs_auth - ", - "ccvs_command - ", - "ccvs_count - ", - "ccvs_delete - ", - "ccvs_done - ", - "ccvs_init - ", - "ccvs_lookup - ", - "ccvs_new - ", - "ccvs_report - ", - "ccvs_return - ", - "ccvs_reverse - ", - "ccvs_sale - ", - "ccvs_status - ", - "ccvs_textvalue - ", - "ccvs_void - ", - "ceil - ", - "chdir - ", - "checkdate - ", - "checkdnsrr - ", - "checkdnsrr - ", - "chgrp - ", - "chmod - ", - "chop - ", - "chown - ", - "chr - ", - "chroot - ", - "chroot - ", - "chunk_split - ", - - "bool class_exists(string classname)\n"+ - "Checks if the class exists", - - "clearstatcache - ", - "close - ", - - "void closedir([resource dir_handle])\n"+ - "Close directory connection identified by the dir_handle", - - "closelog - ", - "com_get - ", - "com_propget - ", - "com_propput - ", - "com_propset - ", - "com_set - ", - "compact - ", - "confirm_cybermut_compiled - ", - "confirm_extname_compiled - ", - "connect - ", - "connection_aborted - ", - "connection_status - ", - "constant - ", - "convert_cyr_string - ", - "copy - ", - "cos - ", - "count - ", - "count_chars - ", - "cpdf_add_annotation - ", - "cpdf_add_outline - ", - "cpdf_arc - ", - "cpdf_begin_text - ", - "cpdf_circle - ", - "cpdf_clip - ", - "cpdf_close - ", - "cpdf_closepath - ", - "cpdf_closepath_fill_stroke - ", - "cpdf_closepath_stroke - ", - "cpdf_continue_text - ", - "cpdf_curveto - ", - "cpdf_end_text - ", - "cpdf_fill - ", - "cpdf_fill_stroke - ", - "cpdf_finalize - ", - "cpdf_finalize_page - ", - "cpdf_global_set_document_limits - ", - "cpdf_import_jpeg - ", - "cpdf_lineto - ", - "cpdf_moveto - ", - "cpdf_newpath - ", - "cpdf_open - ", - "cpdf_output_buffer - ", - "cpdf_page_init - ", - "cpdf_place_inline_image - ", - "cpdf_rect - ", - "cpdf_restore - ", - "cpdf_rlineto - ", - "cpdf_rmoveto - ", - "cpdf_rotate - ", - "cpdf_rotate_text - ", - "cpdf_save - ", - "cpdf_save_to_file - ", - "cpdf_scale - ", - "cpdf_set_action_url - ", - "cpdf_set_char_spacing - ", - "cpdf_set_creator - ", - "cpdf_set_current_page - ", - "cpdf_set_font - ", - "cpdf_set_font_directories - ", - "cpdf_set_font_map_file - ", - "cpdf_set_horiz_scaling - ", - "cpdf_set_keywords - ", - "cpdf_set_leading - ", - "cpdf_set_page_animation - ", - "cpdf_set_subject - ", - "cpdf_set_text_matrix - ", - "cpdf_set_text_pos - ", - "cpdf_set_text_rendering - ", - "cpdf_set_text_rise - ", - "cpdf_set_title - ", - "cpdf_set_viewer_preferences - ", - "cpdf_set_word_spacing - ", - "cpdf_setdash - ", - "cpdf_setflat - ", - "cpdf_setgray - ", - "cpdf_setgray_fill - ", - "cpdf_setgray_stroke - ", - "cpdf_setlinecap - ", - "cpdf_setlinejoin - ", - "cpdf_setlinewidth - ", - "cpdf_setmiterlimit - ", - "cpdf_setrgbcolor - ", - "cpdf_setrgbcolor_fill - ", - "cpdf_setrgbcolor_stroke - ", - "cpdf_show - ", - "cpdf_show_xy - ", - "cpdf_stringwidth - ", - "cpdf_stroke - ", - "cpdf_text - ", - "cpdf_translate - ", - "crack_check - ", - "crack_closedict - ", - "crack_getlastmessage - ", - "crack_opendict - ", - "crash - ", - "crc32 - ", - - "string create_function(string args, string code)\n"+ - "Creates an anonymous function, and returns its name (funny, eh?)", - - "crypt - ", - "crypt - ", - "ctype_alnum - ", - "ctype_alpha - ", - "ctype_cntrl - ", - "ctype_digit - ", - "ctype_graph - ", - "ctype_lower - ", - "ctype_print - ", - "ctype_punct - ", - "ctype_space - ", - "ctype_upper - ", - "ctype_xdigit - ", - "curl_close - ", - "curl_errno - ", - "curl_error - ", - "curl_exec - ", - "curl_getinfo - ", - "curl_getinfo - ", - "curl_init - ", - "curl_setopt - ", - "curl_version - ", - "current - ", - "cv_add - ", - "cv_auth - ", - "cv_command - ", - "cv_count - ", - "cv_delete - ", - "cv_done - ", - "cv_init - ", - "cv_lookup - ", - "cv_new - ", - "cv_report - ", - "cv_return - ", - "cv_reverse - ", - "cv_sale - ", - "cv_status - ", - "cv_textvalue - ", - "cv_void - ", - "cybercash_base64_decode - ", - "cybercash_base64_encode - ", - "cybercash_decr - ", - "cybercash_encr - ", - "cybermut_creerformulairecm - ", - "cybermut_creerreponsecm - ", - "cybermut_testmac - ", - "date - ", - "dba_close - ", - "dba_delete - ", - "dba_exists - ", - "dba_fetch - ", - "dba_firstkey - ", - "dba_insert - ", - "dba_nextkey - ", - "dba_open - ", - "dba_optimize - ", - "dba_popen - ", - "dba_replace - ", - "dba_sync - ", - "dbase_add_record - ", - "dbase_close - ", - "dbase_create - ", - "dbase_delete_record - ", - "dbase_get_record - ", - "dbase_get_record_with_names - ", - "dbase_numfields - ", - "dbase_numrecords - ", - "dbase_open - ", - "dbase_pack - ", - "dbase_replace_record - ", - "dblist - ", - "dbmclose - ", - "dbmdelete - ", - "dbmexists - ", - "dbmfetch - ", - "dbmfirstkey - ", - "dbminsert - ", - "dbmnextkey - ", - "dbmopen - ", - "dbmreplace - ", - "dbx_close - ", - "dbx_cmp_asc - ", - "dbx_cmp_desc - ", - "dbx_connect - ", - "dbx_error - ", - "dbx_query - ", - "dbx_sort - ", - "dcgettext - ", - "decbin - ", - "dechex - ", - "decoct - ", - - "bool define(string constant_name, mixed value, case_sensitive=true)\n"+ - "Define a new constant", - - "define_syslog_variables - ", - - "bool defined(string constant_name)\n"+ - "Check whether a constant exists", - - "deg2rad - ", - "delete_iovec - ", - "dgettext - ", - - "class dir(string directory)\n"+ - "Directory class with properties, handle and class and methods read, rewind and close", - - "dirname - ", - "diskfreespace - ", - "display_disabled_function - ", - "dl - ", - "domxml_add_root - ", - "domxml_attributes - ", - "domxml_children - ", - "domxml_dumpmem - ", - "domxml_elem_get_attribute - ", - "domxml_elem_set_attribute - ", - "domxml_get_attribute - ", - "domxml_getattr - ", - "domxml_new_child - ", - "domxml_new_xmldoc - ", - "domxml_node - ", - "domxml_node_attributes - ", - "domxml_node_children - ", - "domxml_node_new_child - ", - "domxml_node_set_content - ", - "domxml_node_unlink_node - ", - "domxml_root - ", - "domxml_set_attribute - ", - "domxml_setattr - ", - "domxml_unlink_node - ", - "domxml_version - ", - "doubleval - ", - "drawarc - ", - "drawcircle - ", - "drawcubic - ", - "drawcubicto - ", - "drawcurve - ", - "drawcurveto - ", - "drawglyph - ", - "drawline - ", - "drawlineto - ", - "each - ", - "easter_date - ", - "easter_days - ", - "end - ", - "ereg - ", - "ereg_replace - ", - "eregi - ", - "eregi_replace - ", - "error_log - ", - "error_reporting - ", - "escapeshellarg - ", - "escapeshellcmd - ", - "exec - ", - "exit - ", - "exp - ", - "explode - ", - "extension_loaded - ", - "extract - ", - "ezmlm_hash - ", - "ezmlm_hash - ", - "fbsql - ", - "fbsql_affected_rows - ", - "fbsql_autocommit - ", - "fbsql_close - ", - "fbsql_commit - ", - "fbsql_connect - ", - "fbsql_create_db - ", - "fbsql_data_seek - ", - "fbsql_database - ", - "fbsql_database_password - ", - "fbsql_db_query - ", - "fbsql_drop_db - ", - "fbsql_errno - ", - "fbsql_error - ", - "fbsql_fetch_array - ", - "fbsql_fetch_assoc - ", - "fbsql_fetch_field - ", - "fbsql_fetch_lengths - ", - "fbsql_fetch_object - ", - "fbsql_fetch_row - ", - "fbsql_field_flags - ", - "fbsql_field_len - ", - "fbsql_field_name - ", - "fbsql_field_seek - ", - "fbsql_field_table - ", - "fbsql_field_type - ", - "fbsql_free_result - ", - "fbsql_hostname - ", - "fbsql_insert_id - ", - "fbsql_list_dbs - ", - "fbsql_list_fields - ", - "fbsql_list_tables - ", - "fbsql_next_result - ", - "fbsql_num_fields - ", - "fbsql_num_rows - ", - "fbsql_password - ", - "fbsql_pconnect - ", - "fbsql_query - ", - "fbsql_result - ", - "fbsql_rollback - ", - "fbsql_select_db - ", - "fbsql_start_db - ", - "fbsql_stop_db - ", - "fbsql_username - ", - "fbsql_warnings - ", - "fclose - ", - "fd_alloc - ", - "fd_clear - ", - "fd_dealloc - ", - "fd_isset - ", - "fd_set - ", - "fd_zero - ", - "fdf_add_template - ", - "fdf_close - ", - "fdf_create - ", - "fdf_get_file - ", - "fdf_get_status - ", - "fdf_get_value - ", - "fdf_next_field_name - ", - "fdf_open - ", - "fdf_save - ", - "fdf_set_ap - ", - "fdf_set_file - ", - "fdf_set_flags - ", - "fdf_set_javascript_action - ", - "fdf_set_opt - ", - "fdf_set_status - ", - "fdf_set_submit_form_action - ", - "fdf_set_value - ", - "feof - ", - "fetch_iovec - ", - "fflush - ", - "fgetc - ", - "fgetcsv - ", - "fgets - ", - "fgetss - ", - "file - ", - "file_exists - ", - "fileatime - ", - "filectime - ", - "filegroup - ", - "fileinode - ", - "filemtime - ", - "fileowner - ", - "fileperms - ", - "filepro - ", - "filepro_fieldcount - ", - "filepro_fieldname - ", - "filepro_fieldtype - ", - "filepro_fieldwidth - ", - "filepro_retrieve - ", - "filepro_rowcount - ", - "filesize - ", - "filetype - ", - "flock - ", - "floor - ", - "flush - ", - "fopen - ", - "fopenstream - ", - "fopenstream - ", - "fpassthru - ", - "fputs - ", - "fread - ", - "free_iovec - ", - "frenchtojd - ", - "fribidi_log2vis - ", - "fscanf - ", - "fseek - ", - "fsockopen - ", - "fstat - ", - "ftell - ", - "ftp_cdup - ", - "ftp_chdir - ", - "ftp_connect - ", - "ftp_delete - ", - "ftp_exec - ", - "ftp_fget - ", - "ftp_fput - ", - "ftp_get - ", - "ftp_login - ", - "ftp_mdtm - ", - "ftp_mkdir - ", - "ftp_nlist - ", - "ftp_pasv - ", - "ftp_put - ", - "ftp_pwd - ", - "ftp_quit - ", - "ftp_rawlist - ", - "ftp_rename - ", - "ftp_rmdir - ", - "ftp_site - ", - "ftp_size - ", - "ftp_systype - ", - "ftruncate - ", - "func_get_arg - ", - "func_get_args - ", - "func_num_args - ", - "function_exists - ", - "fwrite - ", - "get_all_headers - ", - "get_browser - ", - "get_cfg_var - ", - "get_class - ", - "get_class_methods - ", - "get_class_vars - ", - "get_current_user - ", - "get_declared_classes - ", - "get_defined_functions - ", - "get_defined_vars - ", - "get_extension_funcs - ", - "get_html_translation_table - ", - "get_included_files - ", - "get_loaded_extensions - ", - "get_magic_quotes_gpc - ", - "get_magic_quotes_runtime - ", - "get_meta_tags - ", - "get_object_vars - ", - "get_parent_class - ", - "get_required_files - ", - "get_resource_type - ", - "getallheaders - ", - "getallheaders - ", - "getascent - ", - "getascent - ", - "getcwd - ", - "getdate - ", - "getdescent - ", - "getdescent - ", - "getenv - ", - "getheight - ", - "gethostbyaddr - ", - "gethostbyaddr - ", - "gethostbyname - ", - "gethostbyname - ", - "gethostbynamel - ", - "getimagesize - ", - "getlastmod - ", - "getleading - ", - "getleading - ", - "getmxrr - ", - "getmxrr - ", - "getmyinode - ", - "getmypid - ", - "getmyuid - ", - "getpeername - ", - "getprotobyname - ", - "getprotobynumber - ", - "getrandmax - ", - "getrusage - ", - "getrusage - ", - "getservbyname - ", - "getservbyport - ", - "getshape1 - ", - "getshape2 - ", - "getsockname - ", - "getsockopt - ", - "gettext - ", - "gettimeofday - ", - "gettype - ", - "getwidth - ", - "getwidth - ", - "getwidth - ", - "gmdate - ", - "gmmktime - ", - "gmp_abs - ", - "gmp_add - ", - "gmp_and - ", - "gmp_clrbit - ", - "gmp_cmp - ", - "gmp_com - ", - "gmp_div - ", - "gmp_div_q - ", - "gmp_div_qr - ", - "gmp_div_r - ", - "gmp_divexact - ", - "gmp_fact - ", - "gmp_gcd - ", - "gmp_gcdext - ", - "gmp_hamdist - ", - "gmp_init - ", - "gmp_intval - ", - "gmp_invert - ", - "gmp_jacobi - ", - "gmp_legendre - ", - "gmp_mod - ", - "gmp_mul - ", - "gmp_neg - ", - "gmp_or - ", - "gmp_perfect_square - ", - "gmp_popcount - ", - "gmp_pow - ", - "gmp_powm - ", - "gmp_prob_prime - ", - "gmp_random - ", - "gmp_scan0 - ", - "gmp_scan1 - ", - "gmp_setbit - ", - "gmp_sign - ", - "gmp_sqrt - ", - "gmp_sqrtrem - ", - "gmp_strval - ", - "gmp_sub - ", - "gmp_xor - ", - "gmstrftime - ", - "gmstrftime - ", - "gregoriantojd - ", - "gzclose - ", - "gzcompress - ", - "gzdeflate - ", - "gzencode - ", - "gzeof - ", - "gzfile - ", - "gzgetc - ", - "gzgets - ", - "gzgetss - ", - "gzinflate - ", - "gzopen - ", - "gzpassthru - ", - "gzputs - ", - "gzread - ", - "gzrewind - ", - "gzseek - ", - "gztell - ", - "gzuncompress - ", - "gzwrite - ", - "header - ", - "headers_sent - ", - "hebrev - ", - "hebrevc - ", - "hexdec - ", - "highlight_file - ", - "highlight_string - ", - "htmlentities - ", - "htmlspecialchars - ", - "hw_array2objrec - ", - "hw_changeobject - ", - "hw_children - ", - "hw_childrenobj - ", - "hw_close - ", - "hw_connect - ", - "hw_connection_info - ", - "hw_cp - ", - "hw_deleteobject - ", - "hw_docbyanchor - ", - "hw_docbyanchorobj - ", - "hw_document_attributes - ", - "hw_document_bodytag - ", - "hw_document_content - ", - "hw_document_setcontent - ", - "hw_document_size - ", - "hw_dummy - ", - "hw_edittext - ", - "hw_error - ", - "hw_errormsg - ", - "hw_free_document - ", - "hw_getanchors - ", - "hw_getanchorsobj - ", - "hw_getandlock - ", - "hw_getcgi - ", - "hw_getchildcoll - ", - "hw_getchildcollobj - ", - "hw_getchilddoccoll - ", - "hw_getchilddoccollobj - ", - "hw_getobject - ", - "hw_getobjectbyftquery - ", - "hw_getobjectbyftquerycoll - ", - "hw_getobjectbyftquerycollobj - ", - "hw_getobjectbyftqueryobj - ", - "hw_getobjectbyquery - ", - "hw_getobjectbyquerycoll - ", - "hw_getobjectbyquerycollobj - ", - "hw_getobjectbyqueryobj - ", - "hw_getparents - ", - "hw_getparentsobj - ", - "hw_getrellink - ", - "hw_getremote - ", - "hw_getremotechildren - ", - "hw_getsrcbydestobj - ", - "hw_gettext - ", - "hw_getusername - ", - "hw_identify - ", - "hw_incollections - ", - "hw_info - ", - "hw_inscoll - ", - "hw_insdoc - ", - "hw_insertanchors - ", - "hw_insertdocument - ", - "hw_insertobject - ", - "hw_mapid - ", - "hw_modifyobject - ", - "hw_mv - ", - "hw_new_document - ", - "hw_new_document_from_file - ", - "hw_objrec2array - ", - "hw_output_document - ", - "hw_pconnect - ", - "hw_pipecgi - ", - "hw_pipedocument - ", - "hw_root - ", - "hw_setlinkroot - ", - "hw_stat - ", - "hw_unlock - ", - "hw_who - ", - "ibase_blob_add - ", - "ibase_blob_cancel - ", - "ibase_blob_close - ", - "ibase_blob_create - ", - "ibase_blob_echo - ", - "ibase_blob_get - ", - "ibase_blob_import - ", - "ibase_blob_info - ", - "ibase_blob_open - ", - "ibase_close - ", - "ibase_commit - ", - "ibase_connect - ", - "ibase_errmsg - ", - "ibase_execute - ", - "ibase_fetch_object - ", - "ibase_fetch_row - ", - "ibase_field_info - ", - "ibase_free_query - ", - "ibase_free_result - ", - "ibase_num_fields - ", - "ibase_pconnect - ", - "ibase_prepare - ", - "ibase_query - ", - "ibase_rollback - ", - "ibase_timefmt - ", - "ibase_trans - ", - "icap_create_calendar - ", - "icap_delete_calendar - ", - "icap_delete_event - ", - "icap_fetch_event - ", - "icap_list_alarms - ", - "icap_list_events - ", - "icap_open - ", - "icap_popen - ", - "icap_rename_calendar - ", - "icap_reopen - ", - "icap_snooze - ", - "icap_store_event - ", - "iconv - ", - "iconv_get_encoding - ", - "iconv_set_encoding - ", - "ifx_affected_rows - ", - "ifx_blobinfile_mode - ", - "ifx_byteasvarchar - ", - "ifx_close - ", - "ifx_connect - ", - "ifx_copy_blob - ", - "ifx_create_blob - ", - "ifx_create_char - ", - "ifx_do - ", - "ifx_error - ", - "ifx_errormsg - ", - "ifx_fetch_row - ", - "ifx_fieldproperties - ", - "ifx_fieldtypes - ", - "ifx_free_blob - ", - "ifx_free_char - ", - "ifx_free_result - ", - "ifx_get_blob - ", - "ifx_get_char - ", - "ifx_getsqlca - ", - "ifx_htmltbl_result - ", - "ifx_nullformat - ", - "ifx_num_fields - ", - "ifx_num_rows - ", - "ifx_pconnect - ", - "ifx_prepare - ", - "ifx_query - ", - "ifx_textasvarchar - ", - "ifx_update_blob - ", - "ifx_update_char - ", - "ifxus_close_slob - ", - "ifxus_create_slob - ", - "ifxus_free_slob - ", - "ifxus_open_slob - ", - "ifxus_read_slob - ", - "ifxus_seek_slob - ", - "ifxus_tell_slob - ", - "ifxus_write_slob - ", - "ignore_user_abort - ", - "iis_addserver - ", - "iis_getdirsecurity - ", - "iis_getscriptmap - ", - "iis_getserverbycomment - ", - "iis_getserverbypath - ", - "iis_getserverright - ", - "iis_getservicestate - ", - "iis_removeserver - ", - "iis_setappsettings - ", - "iis_setdirsecurity - ", - "iis_setscriptmap - ", - "iis_setserverright - ", - "iis_startserver - ", - "iis_startservice - ", - "iis_stopserver - ", - "iis_stopservice - ", - "image2wbmp - ", - "imagealphablending - ", - "imagearc - ", - "imagechar - ", - "imagecharup - ", - "imagecolorallocate - ", - "imagecolorat - ", - "imagecolorclosest - ", - "imagecolorclosestalpha - ", - "imagecolorclosesthwb - ", - "imagecolordeallocate - ", - "imagecolorexact - ", - "imagecolorexactalpha - ", - "imagecolorresolve - ", - "imagecolorresolvealpha - ", - "imagecolorset - ", - "imagecolorsforindex - ", - "imagecolorstotal - ", - "imagecolortransparent - ", - "imagecopy - ", - "imagecopymerge - ", - "imagecopymergegray - ", - "imagecopyresampled - ", - "imagecopyresized - ", - "imagecreate - ", - "imagecreatefromgif - ", - "imagecreatefromjpeg - ", - "imagecreatefrompng - ", - "imagecreatefromstring - ", - "imagecreatefromwbmp - ", - "imagecreatefromxbm - ", - "imagecreatefromxpm - ", - "imagecreatetruecolor - ", - "imagedashedline - ", - "imagedestroy - ", - "imageellipse - ", - "imagefill - ", - "imagefilledarc - ", - "imagefilledellipse - ", - "imagefilledpolygon - ", - "imagefilledrectangle - ", - "imagefilltoborder - ", - "imagefontheight - ", - "imagefontwidth - ", - "imagegammacorrect - ", - "imagegif - ", - "imageinterlace - ", - "imagejpeg - ", - "imageline - ", - "imageloadfont - ", - "imagepalettecopy - ", - "imagepng - ", - "imagepolygon - ", - "imagepsbbox - ", - "imagepscopyfont - ", - "imagepsencodefont - ", - "imagepsextendfont - ", - "imagepsfreefont - ", - "imagepsloadfont - ", - "imagepsslantfont - ", - "imagepstext - ", - "imagerectangle - ", - "imagesetbrush - ", - "imagesetpixel - ", - "imagesetstyle - ", - "imagesetthickness - ", - "imagesettile - ", - "imagestring - ", - "imagestringup - ", - "imagesx - ", - "imagesy - ", - "imagetruecolortopalette - ", - "imagettfbbox - ", - "imagettftext - ", - "imagetypes - ", - "imagewbmp - ", - "imap_8bit - ", - "imap_alerts - ", - "imap_append - ", - "imap_base64 - ", - "imap_binary - ", - "imap_body - ", - "imap_bodystruct - ", - "imap_check - ", - "imap_clearflag_full - ", - "imap_close - ", - "imap_create - ", - "imap_createmailbox - ", - "imap_delete - ", - "imap_deletemailbox - ", - "imap_errors - ", - "imap_expunge - ", - "imap_fetch_overview - ", - "imap_fetchbody - ", - "imap_fetchheader - ", - "imap_fetchstructure - ", - "imap_fetchtext - ", - "imap_get_quota - ", - "imap_getmailboxes - ", - "imap_getsubscribed - ", - "imap_header - ", - "imap_headerinfo - ", - "imap_headers - ", - "imap_last_error - ", - "imap_list - ", - "imap_listmailbox - ", - "imap_listsubscribed - ", - "imap_lsub - ", - "imap_mail - ", - "imap_mail - ", - "imap_mail_compose - ", - "imap_mail_copy - ", - "imap_mail_move - ", - "imap_mailboxmsginfo - ", - "imap_mime_header_decode - ", - "imap_msgno - ", - "imap_num_msg - ", - "imap_num_recent - ", - "imap_open - ", - "imap_ping - ", - "imap_popen - ", - "imap_qprint - ", - "imap_rename - ", - "imap_renamemailbox - ", - "imap_reopen - ", - "imap_rfc822_parse_adrlist - ", - "imap_rfc822_parse_headers - ", - "imap_rfc822_write_address - ", - "imap_scan - ", - "imap_scanmailbox - ", - "imap_search - ", - "imap_set_quota - ", - "imap_setflag_full - ", - "imap_sort - ", - "imap_status - ", - "imap_subscribe - ", - "imap_uid - ", - "imap_undelete - ", - "imap_unsubscribe - ", - "imap_utf7_decode - ", - "imap_utf7_encode - ", - "imap_utf8 - ", - "implode - ", - "in_array - ", - "ingres_autocommit - ", - "ingres_close - ", - "ingres_commit - ", - "ingres_connect - ", - "ingres_fetch_array - ", - "ingres_fetch_object - ", - "ingres_fetch_row - ", - "ingres_field_length - ", - "ingres_field_name - ", - "ingres_field_nullable - ", - "ingres_field_precision - ", - "ingres_field_scale - ", - "ingres_field_type - ", - "ingres_num_fields - ", - "ingres_num_rows - ", - "ingres_pconnect - ", - "ingres_query - ", - "ingres_rollback - ", - "ini_alter - ", - "ini_get - ", - "ini_restore - ", - "ini_set - ", - "intval - ", - "ip2long - ", - "iptcembed - ", - "iptcparse - ", - "ircg_channel_mode - ", - "ircg_disconnect - ", - "ircg_html_encode - ", - "ircg_ignore_add - ", - "ircg_ignore_del - ", - "ircg_is_conn_alive - ", - "ircg_join - ", - "ircg_kick - ", - "ircg_lookup_format_messages - ", - "ircg_msg - ", - "ircg_nick - ", - "ircg_nickname_escape - ", - "ircg_nickname_unescape - ", - "ircg_notice - ", - "ircg_part - ", - "ircg_pconnect - ", - "ircg_register_format_messages - ", - "ircg_set_current - ", - "ircg_topic - ", - "ircg_whois - ", - "is_array - ", - "is_bool - ", - "is_dir - ", - "is_double - ", - "is_executable - ", - "is_file - ", - "is_float - ", - "is_int - ", - "is_integer - ", - "is_link - ", - "is_long - ", - "is_null - ", - "is_numeric - ", - "is_object - ", - "is_readable - ", - "is_real - ", - "is_resource - ", - "is_scalar - ", - "is_string - ", - "is_subclass_of - ", - "is_uploaded_file - ", - "is_writable - ", - "is_writeable - ", - "java_last_exception_clear - ", - "java_last_exception_get - ", - "jddayofweek - ", - "jdmonthname - ", - "jdtofrench - ", - "jdtogregorian - ", - "jdtojewish - ", - "jdtojulian - ", - "jdtounix - ", - "jewishtojd - ", - "join - ", - "jpeg2wbmp - ", - "juliantojd - ", - "key - ", - "krsort - ", - "ksort - ", - "labelframe - ", - "labelframe - ", - "lcg_value - ", - "ldap_8859_to_t61 - ", - "ldap_add - ", - "ldap_bind - ", - "ldap_close - ", - "ldap_compare - ", - "ldap_connect - ", - "ldap_count_entries - ", - "ldap_delete - ", - "ldap_dn2ufn - ", - "ldap_err2str - ", - "ldap_errno - ", - "ldap_error - ", - "ldap_explode_dn - ", - "ldap_first_attribute - ", - "ldap_first_entry - ", - "ldap_first_reference - ", - "ldap_free_result - ", - "ldap_get_attributes - ", - "ldap_get_dn - ", - "ldap_get_entries - ", - "ldap_get_option - ", - "ldap_get_values - ", - "ldap_get_values_len - ", - "ldap_list - ", - "ldap_mod_add - ", - "ldap_mod_del - ", - "ldap_mod_replace - ", - "ldap_modify - ", - "ldap_next_attribute - ", - "ldap_next_entry - ", - "ldap_next_reference - ", - "ldap_parse_reference - ", - "ldap_parse_result - ", - "ldap_read - ", - "ldap_rename - ", - "ldap_search - ", - "ldap_set_option - ", - "ldap_t61_to_8859 - ", - "ldap_unbind - ", - "leak - ", - "levenshtein - ", - "link - ", - "link - ", - "linkinfo - ", - "linkinfo - ", - "listen - ", - "localeconv - ", - "localtime - ", - "log - ", - "log10 - ", - "long2ip - ", - "lstat - ", - "ltrim - ", - "magic_quotes_runtime - ", - "mail - ", - "mail - ", - "max - ", - "mcal_append_event - ", - "mcal_close - ", - "mcal_create_calendar - ", - "mcal_date_compare - ", - "mcal_date_valid - ", - "mcal_day_of_week - ", - "mcal_day_of_year - ", - "mcal_days_in_month - ", - "mcal_delete_calendar - ", - "mcal_delete_event - ", - "mcal_event_add_attribute - ", - "mcal_event_init - ", - "mcal_event_set_alarm - ", - "mcal_event_set_category - ", - "mcal_event_set_class - ", - "mcal_event_set_description - ", - "mcal_event_set_end - ", - "mcal_event_set_recur_daily - ", - "mcal_event_set_recur_monthly_mday - ", - "mcal_event_set_recur_monthly_wday - ", - "mcal_event_set_recur_none - ", - "mcal_event_set_recur_weekly - ", - "mcal_event_set_recur_yearly - ", - "mcal_event_set_start - ", - "mcal_event_set_title - ", - "mcal_fetch_current_stream_event - ", - "mcal_fetch_event - ", - "mcal_is_leap_year - ", - "mcal_list_alarms - ", - "mcal_list_events - ", - "mcal_next_recurrence - ", - "mcal_open - ", - "mcal_popen - ", - "mcal_rename_calendar - ", - "mcal_reopen - ", - "mcal_snooze - ", - "mcal_store_event - ", - "mcal_time_valid - ", - "mcal_week_of_year - ", - "mcrypt_cbc - ", - "mcrypt_cfb - ", - "mcrypt_create_iv - ", - "mcrypt_decrypt - ", - "mcrypt_ecb - ", - "mcrypt_enc_get_algorithms_name - ", - "mcrypt_enc_get_block_size - ", - "mcrypt_enc_get_iv_size - ", - "mcrypt_enc_get_key_size - ", - "mcrypt_enc_get_modes_name - ", - "mcrypt_enc_get_supported_key_sizes - ", - "mcrypt_enc_is_block_algorithm - ", - "mcrypt_enc_is_block_algorithm_mode - ", - "mcrypt_enc_is_block_mode - ", - "mcrypt_enc_self_test - ", - "mcrypt_encrypt - ", - "mcrypt_generic - ", - "mcrypt_generic_end - ", - "mcrypt_generic_init - ", - "mcrypt_get_block_size - ", - "mcrypt_get_cipher_name - ", - "mcrypt_get_iv_size - ", - "mcrypt_get_key_size - ", - "mcrypt_list_algorithms - ", - "mcrypt_list_modes - ", - "mcrypt_module_close - ", - "mcrypt_module_get_algo_block_size - ", - "mcrypt_module_get_algo_key_size - ", - "mcrypt_module_get_supported_key_sizes - ", - "mcrypt_module_is_block_algorithm - ", - "mcrypt_module_is_block_algorithm_mode - ", - "mcrypt_module_is_block_mode - ", - "mcrypt_module_open - ", - "mcrypt_module_self_test - ", - "mcrypt_ofb - ", - "md5 - ", - "mdecrypt_generic - ", - "metaphone - ", - "method_exists - ", - "mhash - ", - "mhash_count - ", - "mhash_get_block_size - ", - "mhash_get_hash_name - ", - "mhash_keygen_s2k - ", - "microtime - ", - "min - ", - "ming_setcubicthreshold - ", - "ming_setscale - ", - "mkdir - ", - "mktime - ", - "move - ", - "move_uploaded_file - ", - "movepen - ", - "movepento - ", - "moveto - ", - "moveto - ", - "moveto - ", - "msql - ", - "msql_affected_rows - ", - "msql_close - ", - "msql_connect - ", - "msql_create_db - ", - "msql_createdb - ", - "msql_data_seek - ", - "msql_db_query - ", - "msql_dbname - ", - "msql_drop_db - ", - "msql_dropdb - ", - "msql_error - ", - "msql_fetch_array - ", - "msql_fetch_field - ", - "msql_fetch_object - ", - "msql_fetch_row - ", - "msql_field_flags - ", - "msql_field_len - ", - "msql_field_name - ", - "msql_field_seek - ", - "msql_field_table - ", - "msql_field_type - ", - "msql_fieldflags - ", - "msql_fieldlen - ", - "msql_fieldname - ", - "msql_fieldtable - ", - "msql_fieldtype - ", - "msql_free_result - ", - "msql_freeresult - ", - "msql_list_dbs - ", - "msql_list_fields - ", - "msql_list_tables - ", - "msql_listdbs - ", - "msql_listfields - ", - "msql_listtables - ", - "msql_num_fields - ", - "msql_num_rows - ", - "msql_numfields - ", - "msql_numrows - ", - "msql_pconnect - ", - "msql_query - ", - "msql_regcase - ", - "msql_result - ", - "msql_select_db - ", - "msql_selectdb - ", - "msql_tablename - ", - "mssql_affected_rows - ", - "mssql_affected_rows - ", - "mssql_close - ", - "mssql_close - ", - "mssql_close - ", - "mssql_connect - ", - "mssql_connect - ", - "mssql_connect - ", - "mssql_data_seek - ", - "mssql_data_seek - ", - "mssql_data_seek - ", - "mssql_fetch_array - ", - "mssql_fetch_array - ", - "mssql_fetch_array - ", - "mssql_fetch_batch - ", - "mssql_fetch_field - ", - "mssql_fetch_field - ", - "mssql_fetch_field - ", - "mssql_fetch_object - ", - "mssql_fetch_object - ", - "mssql_fetch_object - ", - "mssql_fetch_row - ", - "mssql_fetch_row - ", - "mssql_fetch_row - ", - "mssql_field_length - ", - "mssql_field_name - ", - "mssql_field_seek - ", - "mssql_field_seek - ", - "mssql_field_seek - ", - "mssql_field_type - ", - "mssql_free_result - ", - "mssql_free_result - ", - "mssql_free_result - ", - "mssql_get_last_message - ", - "mssql_get_last_message - ", - "mssql_get_last_message - ", - "mssql_min_client_severity - ", - "mssql_min_error_severity - ", - "mssql_min_error_severity - ", - "mssql_min_message_severity - ", - "mssql_min_message_severity - ", - "mssql_min_server_severity - ", - "mssql_next_result - ", - "mssql_num_fields - ", - "mssql_num_fields - ", - "mssql_num_fields - ", - "mssql_num_rows - ", - "mssql_num_rows - ", - "mssql_num_rows - ", - "mssql_pconnect - ", - "mssql_pconnect - ", - "mssql_pconnect - ", - "mssql_query - ", - "mssql_query - ", - "mssql_query - ", - "mssql_result - ", - "mssql_result - ", - "mssql_result - ", - "mssql_rows_affected - ", - "mssql_select_db - ", - "mssql_select_db - ", - "mssql_select_db - ", - "mt_getrandmax - ", - "mt_rand - ", - "mt_srand - ", - "multcolor - ", - "muscat_close - ", - "muscat_get - ", - "muscat_give - ", - "muscat_setup - ", - "muscat_setup_net - ", - "mysql - ", - "mysql_affected_rows - ", - "mysql_close - ", - "mysql_connect - ", - "mysql_create_db - ", - "mysql_createdb - ", - "mysql_data_seek - ", - "mysql_db_name - ", - "mysql_db_query - ", - "mysql_dbname - ", - "mysql_drop_db - ", - "mysql_dropdb - ", - "mysql_errno - ", - "mysql_error - ", - "mysql_escape_string - ", - "mysql_fetch_array - ", - "mysql_fetch_assoc - ", - "mysql_fetch_field - ", - "mysql_fetch_lengths - ", - "mysql_fetch_object - ", - "mysql_fetch_row - ", - "mysql_field_flags - ", - "mysql_field_len - ", - "mysql_field_name - ", - "mysql_field_seek - ", - "mysql_field_table - ", - "mysql_field_type - ", - "mysql_fieldflags - ", - "mysql_fieldlen - ", - "mysql_fieldname - ", - "mysql_fieldtable - ", - "mysql_fieldtype - ", - "mysql_free_result - ", - "mysql_freeresult - ", - "mysql_get_client_info - ", - "mysql_get_host_info - ", - "mysql_get_proto_info - ", - "mysql_get_server_info - ", - "mysql_insert_id - ", - "mysql_list_dbs - ", - "mysql_list_fields - ", - "mysql_list_tables - ", - "mysql_listdbs - ", - "mysql_listfields - ", - "mysql_listtables - ", - "mysql_num_fields - ", - "mysql_num_rows - ", - "mysql_numfields - ", - "mysql_numrows - ", - "mysql_pconnect - ", - "mysql_query - ", - "mysql_result - ", - "mysql_select_db - ", - "mysql_selectdb - ", - "mysql_tablename - ", - "mysql_unbuffered_query - ", - "natcasesort - ", - "natsort - ", - "new_xmldoc - ", - "next - ", - "nextframe - ", - "nextframe - ", - "nl2br - ", - "notes_body - ", - "notes_copy_db - ", - "notes_create_db - ", - "notes_create_note - ", - "notes_drop_db - ", - "notes_find_note - ", - "notes_header_info - ", - "notes_list_msgs - ", - "notes_mark_read - ", - "notes_mark_unread - ", - "notes_nav_create - ", - "notes_search - ", - "notes_unread - ", - "notes_version - ", - "number_format - ", - "ob_end_clean - ", - "ob_end_flush - ", - "ob_get_contents - ", - "ob_get_length - ", - "ob_gzhandler - ", - "ob_iconv_handler - ", - "ob_implicit_flush - ", - "ob_start - ", - "ocibindbyname - ", - "ocicancel - ", - "ocicollappend - ", - "ocicollassign - ", - "ocicollassignelem - ", - "ocicolldateappendelem - ", - "ocicolldateassignelem - ", - "ocicolldategetelem - ", - "ocicollgetelem - ", - "ocicollmax - ", - "ocicollsize - ", - "ocicolltrim - ", - "ocicolumnisnull - ", - "ocicolumnname - ", - "ocicolumnprecision - ", - "ocicolumnscale - ", - "ocicolumnsize - ", - "ocicolumntype - ", - "ocicolumntyperaw - ", - "ocicommit - ", - "ocidefinebyname - ", - "ocierror - ", - "ociexecute - ", - "ocifetch - ", - "ocifetchinto - ", - "ocifetchstatement - ", - "ocifreecoll - ", - "ocifreecursor - ", - "ocifreedesc - ", - "ocifreestatement - ", - "ociinternaldebug - ", - "ociloadlob - ", - "ocilogoff - ", - "ocilogon - ", - "ocinewcollection - ", - "ocinewcursor - ", - "ocinewdescriptor - ", - "ocinlogon - ", - "ocinumcols - ", - "ociparse - ", - "ociplogon - ", - "ociresult - ", - "ocirollback - ", - "ocirowcount - ", - "ocisavelob - ", - "ocisavelobfile - ", - "ociserverversion - ", - "ocisetprefetch - ", - "ocistatementtype - ", - "ociwritelobtofile - ", - "octdec - ", - "odbc_autocommit - ", - "odbc_binmode - ", - "odbc_close - ", - "odbc_close_all - ", - "odbc_columnprivileges - ", - "odbc_columns - ", - "odbc_commit - ", - "odbc_connect - ", - "odbc_cursor - ", - "odbc_do - ", - "odbc_error - ", - "odbc_errormsg - ", - "odbc_exec - ", - "odbc_execute - ", - "odbc_fetch_array - ", - "odbc_fetch_into - ", - "odbc_fetch_object - ", - "odbc_fetch_row - ", - "odbc_field_len - ", - "odbc_field_name - ", - "odbc_field_num - ", - "odbc_field_precision - ", - "odbc_field_scale - ", - "odbc_field_type - ", - "odbc_foreignkeys - ", - "odbc_free_result - ", - "odbc_gettypeinfo - ", - "odbc_longreadlen - ", - "odbc_next_result - ", - "odbc_num_fields - ", - "odbc_num_rows - ", - "odbc_pconnect - ", - "odbc_prepare - ", - "odbc_primarykeys - ", - "odbc_procedurecolumns - ", - "odbc_procedures - ", - "odbc_result - ", - "odbc_result_all - ", - "odbc_rollback - ", - "odbc_setoption - ", - "odbc_specialcolumns - ", - "odbc_statistics - ", - "odbc_tableprivileges - ", - "odbc_tables - ", - "open_listen_sock - ", - "opendir - ", - "openlog - ", - "openssl_error_string - ", - "openssl_free_key - ", - "openssl_get_privatekey - ", - "openssl_get_publickey - ", - "openssl_open - ", - "openssl_pkcs7_decrypt - ", - "openssl_pkcs7_encrypt - ", - "openssl_pkcs7_sign - ", - "openssl_pkcs7_verify - ", - "openssl_seal - ", - "openssl_sign - ", - "openssl_verify - ", - "openssl_x509_checkpurpose - ", - "openssl_x509_free - ", - "openssl_x509_parse - ", - "openssl_x509_read - ", - "ora_bind - ", - "ora_close - ", - "ora_columnname - ", - "ora_columnsize - ", - "ora_columntype - ", - "ora_commit - ", - "ora_commitoff - ", - "ora_commiton - ", - "ora_do - ", - "ora_error - ", - "ora_errorcode - ", - "ora_exec - ", - "ora_fetch - ", - "ora_fetch_into - ", - "ora_getcolumn - ", - "ora_logoff - ", - "ora_logon - ", - "ora_numcols - ", - "ora_numrows - ", - "ora_open - ", - "ora_parse - ", - "ora_plogon - ", - "ora_rollback - ", - "orbit_caught_exception - ", - "orbit_exception_id - ", - "orbit_exception_value - ", - "orbit_get_repository_id - ", - "orbit_load_idl - ", - "ord - ", - "output - ", - "ovrimos_close - ", - "ovrimos_close_all - ", - "ovrimos_commit - ", - "ovrimos_connect - ", - "ovrimos_cursor - ", - "ovrimos_exec - ", - "ovrimos_execute - ", - "ovrimos_fetch_into - ", - "ovrimos_fetch_row - ", - "ovrimos_field_len - ", - "ovrimos_field_name - ", - "ovrimos_field_num - ", - "ovrimos_field_type - ", - "ovrimos_free_result - ", - "ovrimos_longreadlen - ", - "ovrimos_num_fields - ", - "ovrimos_num_rows - ", - "ovrimos_prepare - ", - "ovrimos_result - ", - "ovrimos_result_all - ", - "ovrimos_rollback - ", - "pack - ", - "parse_ini_file - ", - "parse_str - ", - "parse_url - ", - "passthru - ", - "pathinfo - ", - "pclose - ", - "pdf_add_annotation - ", - "pdf_add_bookmark - ", - "pdf_add_launchlink - ", - "pdf_add_locallink - ", - "pdf_add_note - ", - "pdf_add_outline - ", - "pdf_add_pdflink - ", - "pdf_add_thumbnail - ", - "pdf_add_weblink - ", - "pdf_arc - ", - "pdf_arcn - ", - "pdf_attach_file - ", - "pdf_begin_page - ", - "pdf_begin_pattern - ", - "pdf_begin_template - ", - "pdf_circle - ", - "pdf_clip - ", - "pdf_close - ", - "pdf_close_image - ", - "pdf_close_pdi - ", - "pdf_close_pdi_page - ", - "pdf_closepath - ", - "pdf_closepath_fill_stroke - ", - "pdf_closepath_stroke - ", - "pdf_concat - ", - "pdf_continue_text - ", - "pdf_curveto - ", - "pdf_delete - ", - "pdf_end_page - ", - "pdf_end_pattern - ", - "pdf_end_template - ", - "pdf_endpath - ", - "pdf_fill - ", - "pdf_fill_stroke - ", - "pdf_findfont - ", - "pdf_get_buffer - ", - "pdf_get_font - ", - "pdf_get_fontname - ", - "pdf_get_fontsize - ", - "pdf_get_image_height - ", - "pdf_get_image_width - ", - "pdf_get_parameter - ", - "pdf_get_pdi_parameter - ", - "pdf_get_pdi_value - ", - "pdf_get_value - ", - "pdf_initgraphics - ", - "pdf_lineto - ", - "pdf_makespotcolor - ", - "pdf_moveto - ", - "pdf_new - ", - "pdf_open - ", - "pdf_open_ccitt - ", - "pdf_open_file - ", - "pdf_open_gif - ", - "pdf_open_image - ", - "pdf_open_image_file - ", - "pdf_open_jpeg - ", - "pdf_open_memory_image - ", - "pdf_open_pdi - ", - "pdf_open_pdi_page - ", - "pdf_open_png - ", - "pdf_open_tiff - ", - "pdf_place_image - ", - "pdf_place_pdi_page - ", - "pdf_rect - ", - "pdf_restore - ", - "pdf_rotate - ", - "pdf_save - ", - "pdf_scale - ", - "pdf_set_border_color - ", - "pdf_set_border_dash - ", - "pdf_set_border_style - ", - "pdf_set_char_spacing - ", - "pdf_set_duration - ", - "pdf_set_font - ", - "pdf_set_horiz_scaling - ", - "pdf_set_info - ", - "pdf_set_info_author - ", - "pdf_set_info_creator - ", - "pdf_set_info_keywords - ", - "pdf_set_info_subject - ", - "pdf_set_info_title - ", - "pdf_set_leading - ", - "pdf_set_parameter - ", - "pdf_set_text_pos - ", - "pdf_set_text_rendering - ", - "pdf_set_text_rise - ", - "pdf_set_transition - ", - "pdf_set_value - ", - "pdf_set_word_spacing - ", - "pdf_setcolor - ", - "pdf_setdash - ", - "pdf_setflat - ", - "pdf_setfont - ", - "pdf_setgray - ", - "pdf_setgray_fill - ", - "pdf_setgray_stroke - ", - "pdf_setlinecap - ", - "pdf_setlinejoin - ", - "pdf_setlinewidth - ", - "pdf_setmatrix - ", - "pdf_setmiterlimit - ", - "pdf_setpolydash - ", - "pdf_setrgbcolor - ", - "pdf_setrgbcolor_fill - ", - "pdf_setrgbcolor_stroke - ", - "pdf_show - ", - "pdf_show_boxed - ", - "pdf_show_xy - ", - "pdf_skew - ", - "pdf_stringwidth - ", - "pdf_stroke - ", - "pdf_translate - ", - "pfpro_cleanup - ", - "pfpro_init - ", - "pfpro_process - ", - "pfpro_process_raw - ", - "pfpro_version - ", - "pfsockopen - ", - "pg_client_encoding - ", - "pg_clientencoding - ", - "pg_close - ", - "pg_cmdtuples - ", - "pg_connect - ", - "pg_dbname - ", - "pg_end_copy - ", - "pg_errormessage - ", - "pg_exec - ", - "pg_fetch_array - ", - "pg_fetch_object - ", - "pg_fetch_row - ", - "pg_fieldisnull - ", - "pg_fieldname - ", - "pg_fieldnum - ", - "pg_fieldprtlen - ", - "pg_fieldsize - ", - "pg_fieldtype - ", - "pg_freeresult - ", - "pg_getlastoid - ", - "pg_host - ", - "pg_loclose - ", - "pg_locreate - ", - "pg_loexport - ", - "pg_loimport - ", - "pg_loopen - ", - "pg_loread - ", - "pg_loreadall - ", - "pg_lounlink - ", - "pg_lowrite - ", - "pg_numfields - ", - "pg_numrows - ", - "pg_options - ", - "pg_pconnect - ", - "pg_port - ", - "pg_put_line - ", - "pg_result - ", - "pg_set_client_encoding - ", - "pg_setclientencoding - ", - "pg_trace - ", - "pg_tty - ", - "pg_untrace - ", - "php_logo_guid - ", - "php_sapi_name - ", - "php_uname - ", - "phpcredits - ", - "phpinfo - ", - "phpversion - ", - "pi - ", - "png2wbmp - ", - "popen - ", - "pos - ", - "posix_ctermid - ", - "posix_getcwd - ", - "posix_getegid - ", - "posix_geteuid - ", - "posix_getgid - ", - "posix_getgrgid - ", - "posix_getgrnam - ", - "posix_getgroups - ", - "posix_getlogin - ", - "posix_getpgid - ", - "posix_getpgrp - ", - "posix_getpid - ", - "posix_getppid - ", - "posix_getpwnam - ", - "posix_getpwuid - ", - "posix_getrlimit - ", - "posix_getsid - ", - "posix_getuid - ", - "posix_isatty - ", - "posix_kill - ", - "posix_mkfifo - ", - "posix_setegid - ", - "posix_seteuid - ", - "posix_setgid - ", - "posix_setpgid - ", - "posix_setsid - ", - "posix_setuid - ", - "posix_times - ", - "posix_ttyname - ", - "posix_uname - ", - "pow - ", - "preg_grep - ", - "preg_match - ", - "preg_match_all - ", - "preg_quote - ", - "preg_replace - ", - "preg_replace_callback - ", - "preg_split - ", - "prev - ", - "print_r - ", - "printer_abort - ", - "printer_close - ", - "printer_create_brush - ", - "printer_create_dc - ", - "printer_create_font - ", - "printer_create_pen - ", - "printer_delete_brush - ", - "printer_delete_dc - ", - "printer_delete_font - ", - "printer_delete_pen - ", - "printer_draw_bmp - ", - "printer_draw_chord - ", - "printer_draw_elipse - ", - "printer_draw_line - ", - "printer_draw_pie - ", - "printer_draw_rectangle - ", - "printer_draw_roundrect - ", - "printer_draw_text - ", - "printer_end_doc - ", - "printer_end_page - ", - "printer_get_option - ", - "printer_list - ", - "printer_logical_fontheight - ", - "printer_open - ", - "printer_select_brush - ", - "printer_select_font - ", - "printer_select_pen - ", - "printer_set_option - ", - "printer_start_doc - ", - "printer_start_page - ", - "printer_write - ", - "printf - ", - "pspell_add_to_personal - ", - "pspell_add_to_session - ", - "pspell_check - ", - "pspell_clear_session - ", - "pspell_config_create - ", - "pspell_config_ignore - ", - "pspell_config_mode - ", - "pspell_config_personal - ", - "pspell_config_repl - ", - "pspell_config_runtogether - ", - "pspell_config_save_repl - ", - "pspell_new - ", - "pspell_new_config - ", - "pspell_new_personal - ", - "pspell_save_wordlist - ", - "pspell_store_replacement - ", - "pspell_suggest - ", - "putenv - ", - "putenv - ", - "qdom_error - ", - "qdom_tree - ", - "quoted_printable_decode - ", - "quotemeta - ", - "rad2deg - ", - "rand - ", - "range - ", - "rawurldecode - ", - "rawurlencode - ", - "read - ", - "read_exif_data - ", - "readdir - ", - "readfile - ", - "readgzfile - ", - "readline - ", - "readline_add_history - ", - "readline_clear_history - ", - "readline_completion_function - ", - "readline_info - ", - "readline_list_history - ", - "readline_list_history - ", - "readline_read_history - ", - "readline_write_history - ", - "readlink - ", - "readlink - ", - "readv - ", - "realpath - ", - "realpath - ", - "recode - ", - "recode_file - ", - "recode_string - ", - "recv - ", - "recvfrom - ", - "recvmsg - ", - "register_shutdown_function - ", - "register_tick_function - ", - "remove - ", - "remove - ", - "rename - ", - "reset - ", - "restore_error_handler - ", - "rewind - ", - "rewinddir - ", - "rmdir - ", - "rotate - ", - "rotateto - ", - "rotateto - ", - "round - ", - "rsort - ", - "rtrim - ", - "satellite_caught_exception - ", - "satellite_exception_id - ", - "satellite_exception_value - ", - "satellite_get_repository_id - ", - "satellite_load_idl - ", - "save - ", - "savetofile - ", - "scale - ", - "scaleto - ", - "scaleto - ", - "select - ", - "sem_acquire - ", - "sem_get - ", - "sem_release - ", - "send - ", - "sendmsg - ", - "sendto - ", - "serialize - ", - "session_cache_limiter - ", - "session_decode - ", - "session_destroy - ", - "session_encode - ", - "session_get_cookie_params - ", - "session_id - ", - "session_is_registered - ", - "session_module_name - ", - "session_name - ", - "session_register - ", - "session_save_path - ", - "session_set_cookie_params - ", - "session_set_save_handler - ", - "session_start - ", - "session_unregister - ", - "session_unset - ", - "session_write_close - ", - "set_content - ", - "set_error_handler - ", - "set_file_buffer - ", - "set_iovec - ", - "set_magic_quotes_runtime - ", - "set_nonblock - ", - "set_socket_blocking - ", - "set_time_limit - ", - "setaction - ", - "setbackground - ", - "setbounds - ", - "setcolor - ", - "setcolor - ", - "setcookie - ", - "setdepth - ", - "setdimension - ", - "setdown - ", - "setfont - ", - "setfont - ", - "setframes - ", - "setframes - ", - "setheight - ", - "setheight - ", - "sethit - ", - "setindentation - ", - "setleftfill - ", - "setleftmargin - ", - "setline - ", - "setlinespacing - ", - "setlocale - ", - "setmargins - ", - "setmatrix - ", - "setname - ", - "setname - ", - "setover - ", - "setrate - ", - "setratio - ", - "setrightfill - ", - "setrightmargin - ", - "setsockopt - ", - "setspacing - ", - "settype - ", - "setup - ", - "shell_exec - ", - "shm_attach - ", - "shm_detach - ", - "shm_get_var - ", - "shm_put_var - ", - "shm_remove - ", - "shm_remove_var - ", - "shmop_close - ", - "shmop_delete - ", - "shmop_open - ", - "shmop_read - ", - "shmop_size - ", - "shmop_write - ", - "show_source - ", - "shuffle - ", - "shutdown - ", - "signal - ", - "similar_text - ", - "sin - ", - "sizeof - ", - "skewx - ", - "skewxto - ", - "skewxto - ", - "skewy - ", - "skewyto - ", - "skewyto - ", - "sleep - ", - "snmp_get_quick_print - ", - "snmp_set_quick_print - ", - "snmpget - ", - "snmpget - ", - "snmprealwalk - ", - "snmpset - ", - "snmpwalk - ", - "snmpwalk - ", - "snmpwalkoid - ", - "socket - ", - "socket_get_status - ", - "socket_set_blocking - ", - "socket_set_timeout - ", - "socket_set_timeout - ", - "socketpair - ", - "sort - ", - "soundex - ", - "split - ", - "spliti - ", - "sprintf - ", - "sql_regcase - ", - "sqrt - ", - "srand - ", - "sscanf - ", - "stat - ", - "str_pad - ", - "str_repeat - ", - "str_replace - ", - "strcasecmp - ", - "strchr - ", - "strcmp - ", - "strcoll - ", - "strcoll - ", - "strcspn - ", - "streammp3 - ", - "strerror - ", - "strftime - ", - "strftime - ", - "strip_tags - ", - "stripcslashes - ", - "stripslashes - ", - "stristr - ", - "strlen - ", - "strnatcasecmp - ", - "strnatcmp - ", - "strncasecmp - ", - "strncmp - ", - "strpos - ", - "strrchr - ", - "strrev - ", - "strrpos - ", - "strspn - ", - "strstr - ", - "strtok - ", - "strtolower - ", - "strtotime - ", - "strtoupper - ", - "strtr - ", - "strval - ", - - "string substr(string str, int start [, int length])\n"+ - "Returns part of a string", - - - "substr_count - ", - "substr_replace - ", - "swf_actiongeturl - ", - "swf_actiongotoframe - ", - "swf_actiongotolabel - ", - "swf_actionnextframe - ", - "swf_actionplay - ", - "swf_actionprevframe - ", - "swf_actionsettarget - ", - "swf_actionstop - ", - "swf_actiontogglequality - ", - "swf_actionwaitforframe - ", - "swf_addbuttonrecord - ", - "swf_addcolor - ", - "swf_closefile - ", - "swf_definebitmap - ", - "swf_definefont - ", - "swf_defineline - ", - "swf_definepoly - ", - "swf_definerect - ", - "swf_definetext - ", - "swf_endbutton - ", - "swf_enddoaction - ", - "swf_endshape - ", - "swf_endsymbol - ", - "swf_fontsize - ", - "swf_fontslant - ", - "swf_fonttracking - ", - "swf_getbitmapinfo - ", - "swf_getfontinfo - ", - "swf_getframe - ", - "swf_labelframe - ", - "swf_lookat - ", - "swf_modifyobject - ", - "swf_mulcolor - ", - "swf_nextid - ", - "swf_oncondition - ", - "swf_openfile - ", - "swf_ortho - ", - "swf_ortho2 - ", - "swf_perspective - ", - "swf_placeobject - ", - "swf_polarview - ", - "swf_popmatrix - ", - "swf_posround - ", - "swf_pushmatrix - ", - "swf_removeobject - ", - "swf_rotate - ", - "swf_scale - ", - "swf_setfont - ", - "swf_setframe - ", - "swf_shapearc - ", - "swf_shapecurveto - ", - "swf_shapecurveto3 - ", - "swf_shapefillbitmapclip - ", - "swf_shapefillbitmaptile - ", - "swf_shapefilloff - ", - "swf_shapefillsolid - ", - "swf_shapelinesolid - ", - "swf_shapelineto - ", - "swf_shapemoveto - ", - "swf_showframe - ", - "swf_startbutton - ", - "swf_startdoaction - ", - "swf_startshape - ", - "swf_startsymbol - ", - "swf_textwidth - ", - "swf_translate - ", - "swf_viewport - ", - "swfaction - ", - "swfbitmap - ", - "swfbutton - ", - "swfbutton_keypress - ", - "swffill - ", - "swffont - ", - "swfgradient - ", - "swfmorph - ", - "swfmovie - ", - "swfshape - ", - "swfsprite - ", - "swftext - ", - "swftextfield - ", - "sybase_affected_rows - ", - "sybase_affected_rows - ", - "sybase_close - ", - "sybase_close - ", - "sybase_connect - ", - "sybase_connect - ", - "sybase_data_seek - ", - "sybase_data_seek - ", - "sybase_fetch_array - ", - "sybase_fetch_array - ", - "sybase_fetch_field - ", - "sybase_fetch_field - ", - "sybase_fetch_object - ", - "sybase_fetch_object - ", - "sybase_fetch_row - ", - "sybase_fetch_row - ", - "sybase_field_seek - ", - "sybase_field_seek - ", - "sybase_free_result - ", - "sybase_free_result - ", - "sybase_get_last_message - ", - "sybase_get_last_message - ", - "sybase_min_client_severity - ", - "sybase_min_error_severity - ", - "sybase_min_message_severity - ", - "sybase_min_server_severity - ", - "sybase_num_fields - ", - "sybase_num_fields - ", - "sybase_num_rows - ", - "sybase_num_rows - ", - "sybase_pconnect - ", - "sybase_pconnect - ", - "sybase_query - ", - "sybase_query - ", - "sybase_result - ", - "sybase_result - ", - "sybase_select_db - ", - "sybase_select_db - ", - "symlink - ", - "symlink - ", - "syslog - ", - "system - ", - "tan - ", - "tempnam - ", - "textdomain - ", - "time - ", - "tmpfile - ", - "touch - ", - "trigger_error - ", - "trim - ", - "uasort - ", - "ucfirst - ", - "ucwords - ", - "udm_add_search_limit - ", - "udm_alloc_agent - ", - "udm_api_version - ", - "udm_clear_search_limits - ", - "udm_errno - ", - "udm_error - ", - "udm_find - ", - "udm_free_agent - ", - "udm_free_ispell_data - ", - "udm_free_res - ", - "udm_get_doc_count - ", - "udm_get_res_field - ", - "udm_get_res_param - ", - "udm_load_ispell_data - ", - "udm_set_agent_param - ", - "uksort - ", - "umask - ", - "uniqid - ", - "unixtojd - ", - "unlink - ", - "unpack - ", - "unregister_tick_function - ", - "unserialize - ", - "urldecode - ", - "urlencode - ", - "user_error - ", - "usleep - ", - "usort - ", - "utf8_decode - ", - "utf8_encode - ", - "var_dump - ", - "velocis_autocommit - ", - "velocis_close - ", - "velocis_commit - ", - "velocis_connect - ", - "velocis_exec - ", - "velocis_fetch - ", - "velocis_fieldname - ", - "velocis_fieldnum - ", - "velocis_freeresult - ", - "velocis_off_autocommit - ", - "velocis_result - ", - "velocis_rollback - ", - "virtual - ", - "vpopmail_add_alias_domain - ", - "vpopmail_add_alias_domain_ex - ", - "vpopmail_add_domain - ", - "vpopmail_add_domain_ex - ", - "vpopmail_add_user - ", - "vpopmail_auth_user - ", - "vpopmail_del_domain - ", - "vpopmail_del_domain_ex - ", - "vpopmail_del_user - ", - "vpopmail_error - ", - "vpopmail_passwd - ", - "vpopmail_set_user_quota - ", - "wddx_add_vars - ", - "wddx_deserialize - ", - "wddx_packet_end - ", - "wddx_packet_start - ", - "wddx_serialize_value - ", - "wddx_serialize_vars - ", - "wordwrap - ", - "write - ", - "writev - ", - "xml_error_string - ", - "xml_get_current_byte_index - ", - "xml_get_current_column_number - ", - "xml_get_current_line_number - ", - "xml_get_error_code - ", - "xml_parse - ", - "xml_parse_into_struct - ", - "xml_parser_create - ", - "xml_parser_create_ns - ", - "xml_parser_free - ", - "xml_parser_get_option - ", - "xml_parser_set_option - ", - "xml_set_character_data_handler - ", - "xml_set_default_handler - ", - "xml_set_element_handler - ", - "xml_set_end_namespace_decl_handler - ", - "xml_set_external_entity_ref_handler - ", - "xml_set_notation_decl_handler - ", - "xml_set_object - ", - "xml_set_processing_instruction_handler - ", - "xml_set_start_namespace_decl_handler - ", - "xml_set_unparsed_entity_decl_handler - ", - "xmldoc - ", - "xmldocfile - ", - "xmltree - ", - "xpath_eval - ", - "xpath_eval_expression - ", - "xptr_eval - ", - "xslt_closelog - ", - "xslt_create - ", - "xslt_errno - ", - "xslt_error - ", - "xslt_fetch_result - ", - "xslt_free - ", - "xslt_openlog - ", - "xslt_output_begintransform - ", - "xslt_output_endtransform - ", - "xslt_process - ", - "xslt_run - ", - "xslt_set_base - ", - "xslt_set_encoding - ", - "xslt_set_error_handler - ", - "xslt_set_sax_handler - ", - "xslt_set_scheme_handler - ", - "xslt_transform - ", - "yaz_addinfo - ", - "yaz_ccl_conf - ", - "yaz_ccl_parse - ", - "yaz_close - ", - "yaz_connect - ", - "yaz_database - ", - "yaz_element - ", - "yaz_errno - ", - "yaz_error - ", - "yaz_hits - ", - "yaz_itemorder - ", - "yaz_present - ", - "yaz_range - ", - "yaz_record - ", - "yaz_scan - ", - "yaz_scan_result - ", - "yaz_search - ", - "yaz_syntax - ", - "yaz_wait - ", - "yp_all - ", - "yp_cat - ", - "yp_err_string - ", - "yp_errno - ", - "yp_first - ", - "yp_get_default_domain - ", - "yp_master - ", - "yp_match - ", - "yp_next - ", - "yp_order - ", - "zend_logo_guid - ", - "zend_test_func - ", - "zend_version - ", - "zzip_close - ", - "zzip_closedir - ", - "zzip_entry_compressedsize - ", - "zzip_entry_compressionmethod - ", - "zzip_entry_filesize - ", - "zzip_entry_name - ", - "zzip_open - ", - "zzip_opendir - ", - "zzip_read - ", - "zzip_readdir - " }; - -} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPKeyword.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPKeyword.java new file mode 100644 index 0000000..a478a01 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPKeyword.java @@ -0,0 +1,29 @@ +package net.sourceforge.phpeclipse.phpeditor.php; + +/** + * @author Choochter + * + * To change this generated comment edit the template variable "typecomment": + * Window>Preferences>Java>Templates. + * To enable and disable the creation of type comments go to + * Window>Preferences>Java>Code Generation. + */ +public class PHPKeyword extends PHPElement{ + private int tokenval; + public void settokenval(String tokenval) { this.tokenval = Integer.parseInt(tokenval);} + public void settokenval(int tokenval) { this.tokenval = tokenval;} + public int gettokenval() { return this.tokenval; } + + public PHPKeyword(String Name, String Description, String tokenval){ + super(Name, Description); + if ((tokenval == null) || (tokenval.equals(""))) + { + //if there is not a tokenval, then not implemented. + settokenval(-1); + } + else { + settokenval(tokenval); + } + //settokenval(tokenval); + } +} diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPType.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPType.java new file mode 100644 index 0000000..c4fb644 --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/php/PHPType.java @@ -0,0 +1,15 @@ +package net.sourceforge.phpeclipse.phpeditor.php; + +/** + * @author Choochter + * + * To change this generated comment edit the template variable "typecomment": + * Window>Preferences>Java>Templates. + * To enable and disable the creation of type comments go to + * Window>Preferences>Java>Code Generation. + */ +public class PHPType extends PHPElement{ + public PHPType(String Name, String Description){ + super(Name, Description); + } +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpsyntax.xml b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpsyntax.xml new file mode 100644 index 0000000..51ee93c --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/phpsyntax.xml @@ -0,0 +1,2416 @@ + + + +=================================================== +*Below this are the various PHP-specific functions * +=================================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +================================================== +*Below this are the various PHP-specific keywords * +================================================== + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +========================================================= +*Below this are the various PHP-specific variable types * +========================================================= + + + + + + + + + + +=================================================== +*Below this are the various PHP-specific constants * +=================================================== + + + + + + + + + diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/HTMLColorProvider.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/HTMLColorProvider.java index f8fa9b0..5bb0a3f 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/HTMLColorProvider.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/HTMLColorProvider.java @@ -28,7 +28,7 @@ public class HTMLColorProvider { public static final RGB KEYWORD= new RGB(127, 0, 85); public static final RGB VARIABLE= new RGB(127, 159, 191); public static final RGB TYPE= new RGB(0, 0, 128); - public static final RGB STRING= new RGB(0, 128, 0); + public static final RGB STRING= new RGB(42, 0, 255); public static final RGB DEFAULT= new RGB(0, 0, 0); public static final RGB HTML_DEFAULT= new RGB(0, 128, 128); diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/PHPColorProvider.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/PHPColorProvider.java index 8e65c5f..38d0238 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/PHPColorProvider.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/util/PHPColorProvider.java @@ -14,47 +14,50 @@ package net.sourceforge.phpeclipse.phpeditor.util; import java.util.HashMap; import java.util.Iterator; import java.util.Map; + import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Display; - /** * Manager for colors used in the Java editor */ public class PHPColorProvider { - public static final RGB MULTI_LINE_COMMENT= new RGB(63, 127, 95); - public static final RGB SINGLE_LINE_COMMENT= new RGB(63, 127, 95); - public static final RGB KEYWORD= new RGB(127, 0, 85); - public static final RGB VARIABLE= new RGB(127, 159, 191); - public static final RGB FUNCTION_NAME= new RGB(127, 127, 159); - public static final RGB STRING= new RGB(42, 0, 255); - public static final RGB DEFAULT= new RGB(0, 0, 0); - - public static final RGB LINKED_POSITION_COLOR= new RGB(0, 0, 0); - public static final RGB LINE_NUMBER_COLOR= new RGB(0, 0, 0); - public static final RGB BACKGROUND_COLOR= new RGB(255, 255, 255); - - protected Map fColorTable= new HashMap(10); - - /** - * Release all of the color resources held onto by the receiver. - */ - public void dispose() { - Iterator e= fColorTable.values().iterator(); - while (e.hasNext()) - ((Color) e.next()).dispose(); - } - - /** - * Return the Color that is stored in the Color table as rgb. - */ - public Color getColor(RGB rgb) { - Color color= (Color) fColorTable.get(rgb); - if (color == null) { - color= new Color(Display.getCurrent(), rgb); - fColorTable.put(rgb, color); - } - return color; - } + public static final RGB MULTI_LINE_COMMENT = new RGB(63, 127, 95); + public static final RGB SINGLE_LINE_COMMENT = new RGB(63, 127, 95); + public static final RGB KEYWORD = new RGB(127, 0, 85); + public static final RGB VARIABLE = new RGB(127, 159, 191); + public static final RGB FUNCTION_NAME = new RGB(127, 127, 159); + public static final RGB STRING = new RGB(42, 0, 255); + public static final RGB DEFAULT = new RGB(0, 0, 0); + public static final RGB TYPE = new RGB(127, 0, 85); + public static final RGB CONSTANT = new RGB(127, 0, 85); + public static final RGB BACKGROUND = new RGB(255, 255, 255); + + public static final RGB LINKED_POSITION_COLOR = new RGB(0, 0, 0); + + public static final RGB LINE_NUMBER_COLOR = new RGB(0, 0, 0); + public static final RGB BACKGROUND_COLOR = new RGB(255, 255, 255); + protected Map fColorTable = new HashMap(10); + + /** + * Release all of the color resources held onto by the receiver. + */ + public void dispose() { + Iterator e = fColorTable.values().iterator(); + while (e.hasNext()) + ((Color) e.next()).dispose(); + } + + /** + * Return the Color that is stored in the Color table as rgb. + */ + public Color getColor(RGB rgb) { + Color color = (Color) fColorTable.get(rgb); + if (color == null) { + color = new Color(Display.getCurrent(), rgb); + fColorTable.put(rgb, color); + } + return color; + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/ColorEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/ColorEditor.java new file mode 100644 index 0000000..af121ae --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/ColorEditor.java @@ -0,0 +1,116 @@ +/* + * (c) Copyright IBM Corp. 2000, 2001. + * All Rights Reserved. + */ +package net.sourceforge.phpeclipse.preferences; + +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.DisposeEvent; +import org.eclipse.swt.events.DisposeListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Color; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.GC; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.graphics.Point; +import org.eclipse.swt.graphics.RGB; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.ColorDialog; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Display; + +import org.eclipse.jface.resource.JFaceResources; + +/** + * A "button" of a certain color determined by the color picker. + */ +public class ColorEditor { + + private Point fExtent; + private Image fImage; + private RGB fColorValue; + private Color fColor; + private Button fButton; + + public ColorEditor(Composite parent) { + + fButton= new Button(parent, SWT.PUSH); + fExtent= computeImageSize(parent); + fImage= new Image(parent.getDisplay(), fExtent.x, fExtent.y); + + GC gc= new GC(fImage); + gc.setBackground(fButton.getBackground()); + gc.fillRectangle(0, 0, fExtent.x, fExtent.y); + gc.dispose(); + + fButton.setImage(fImage); + fButton.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent event) { + ColorDialog colorDialog= new ColorDialog(fButton.getShell()); + colorDialog.setRGB(fColorValue); + RGB newColor = colorDialog.open(); + if (newColor != null) { + fColorValue= newColor; + updateColorImage(); + } + } + }); + + fButton.addDisposeListener(new DisposeListener() { + public void widgetDisposed(DisposeEvent event) { + if (fImage != null) { + fImage.dispose(); + fImage= null; + } + if (fColor != null) { + fColor.dispose(); + fColor= null; + } + } + }); + } + + public RGB getColorValue() { + return fColorValue; + } + + public void setColorValue(RGB rgb) { + fColorValue= rgb; + updateColorImage(); + } + + public Button getButton() { + return fButton; + } + + protected void updateColorImage() { + + Display display= fButton.getDisplay(); + + GC gc= new GC(fImage); + gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK)); + gc.drawRectangle(0, 2, fExtent.x - 1, fExtent.y - 4); + + if (fColor != null) + fColor.dispose(); + + fColor= new Color(display, fColorValue); + gc.setBackground(fColor); + gc.fillRectangle(1, 3, fExtent.x - 2, fExtent.y - 5); + gc.dispose(); + + fButton.setImage(fImage); + } + + protected Point computeImageSize(Control window) { + GC gc= new GC(window); + Font f= JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT); + gc.setFont(f); + int height= gc.getFontMetrics().getHeight(); + gc.dispose(); + Point p= new Point(height * 3 - 6, height); + return p; + } +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/OverlayPreferenceStore.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/OverlayPreferenceStore.java new file mode 100644 index 0000000..11032cf --- /dev/null +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/OverlayPreferenceStore.java @@ -0,0 +1,443 @@ +/* + * (c) Copyright IBM Corp. 2000, 2001. + * All Rights Reserved. + */ + +package net.sourceforge.phpeclipse.preferences; + +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceStore; +import org.eclipse.jface.util.IPropertyChangeListener; +import org.eclipse.jface.util.PropertyChangeEvent; + +/** + * An overlaying preference store. + */ +public class OverlayPreferenceStore implements IPreferenceStore { + + public static final class TypeDescriptor { + private TypeDescriptor() { + } + }; + + public static final TypeDescriptor BOOLEAN = new TypeDescriptor(); + public static final TypeDescriptor DOUBLE = new TypeDescriptor(); + public static final TypeDescriptor FLOAT = new TypeDescriptor(); + public static final TypeDescriptor INT = new TypeDescriptor(); + public static final TypeDescriptor LONG = new TypeDescriptor(); + public static final TypeDescriptor STRING = new TypeDescriptor(); + + public static class OverlayKey { + + TypeDescriptor fDescriptor; + String fKey; + + public OverlayKey(TypeDescriptor descriptor, String key) { + fDescriptor = descriptor; + fKey = key; + } + }; + + private class PropertyListener implements IPropertyChangeListener { + + /* + * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) + */ + public void propertyChange(PropertyChangeEvent event) { + OverlayKey key = findOverlayKey(event.getProperty()); + if (key != null) + propagateProperty(fParent, key, fStore); + } + }; + + private IPreferenceStore fParent; + private IPreferenceStore fStore; + private OverlayKey[] fOverlayKeys; + + private PropertyListener fPropertyListener; + + public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) { + fParent = parent; + fOverlayKeys = overlayKeys; + fStore = new PreferenceStore(); + } + + private OverlayKey findOverlayKey(String key) { + for (int i = 0; i < fOverlayKeys.length; i++) { + if (fOverlayKeys[i].fKey.equals(key)) + return fOverlayKeys[i]; + } + return null; + } + + private boolean covers(String key) { + return (findOverlayKey(key) != null); + } + + private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) { + + if (orgin.isDefault(key.fKey)) { + if (!target.isDefault(key.fKey)) + target.setToDefault(key.fKey); + return; + } + + TypeDescriptor d = key.fDescriptor; + if (BOOLEAN == d) { + + boolean originValue = orgin.getBoolean(key.fKey); + boolean targetValue = target.getBoolean(key.fKey); + if (targetValue != originValue) + target.setValue(key.fKey, originValue); + + } else if (DOUBLE == d) { + + double originValue = orgin.getDouble(key.fKey); + double targetValue = target.getDouble(key.fKey); + if (targetValue != originValue) + target.setValue(key.fKey, originValue); + + } else if (FLOAT == d) { + + float originValue = orgin.getFloat(key.fKey); + float targetValue = target.getFloat(key.fKey); + if (targetValue != originValue) + target.setValue(key.fKey, originValue); + + } else if (INT == d) { + + int originValue = orgin.getInt(key.fKey); + int targetValue = target.getInt(key.fKey); + if (targetValue != originValue) + target.setValue(key.fKey, originValue); + + } else if (LONG == d) { + + long originValue = orgin.getLong(key.fKey); + long targetValue = target.getLong(key.fKey); + if (targetValue != originValue) + target.setValue(key.fKey, originValue); + + } else if (STRING == d) { + + String originValue = orgin.getString(key.fKey); + String targetValue = target.getString(key.fKey); + if (targetValue != null && originValue != null && !targetValue.equals(originValue)) + target.setValue(key.fKey, originValue); + + } + } + + public void propagate() { + for (int i = 0; i < fOverlayKeys.length; i++) + propagateProperty(fStore, fOverlayKeys[i], fParent); + } + + private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) { + TypeDescriptor d = key.fDescriptor; + if (BOOLEAN == d) { + + if (forceInitialization) + target.setValue(key.fKey, true); + target.setValue(key.fKey, orgin.getBoolean(key.fKey)); + target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey)); + + } else if (DOUBLE == d) { + + if (forceInitialization) + target.setValue(key.fKey, 1.0D); + target.setValue(key.fKey, orgin.getDouble(key.fKey)); + target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey)); + + } else if (FLOAT == d) { + + if (forceInitialization) + target.setValue(key.fKey, 1.0F); + target.setValue(key.fKey, orgin.getFloat(key.fKey)); + target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey)); + + } else if (INT == d) { + + if (forceInitialization) + target.setValue(key.fKey, 1); + target.setValue(key.fKey, orgin.getInt(key.fKey)); + target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey)); + + } else if (LONG == d) { + + if (forceInitialization) + target.setValue(key.fKey, 1L); + target.setValue(key.fKey, orgin.getLong(key.fKey)); + target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey)); + + } else if (STRING == d) { + + if (forceInitialization) + target.setValue(key.fKey, "1"); //$NON-NLS-1$ + target.setValue(key.fKey, orgin.getString(key.fKey)); + target.setDefault(key.fKey, orgin.getDefaultString(key.fKey)); + + } + } + + public void load() { + for (int i = 0; i < fOverlayKeys.length; i++) + loadProperty(fParent, fOverlayKeys[i], fStore, true); + } + + public void loadDefaults() { + for (int i = 0; i < fOverlayKeys.length; i++) + setToDefault(fOverlayKeys[i].fKey); + } + + public void start() { + if (fPropertyListener == null) { + fPropertyListener = new PropertyListener(); + fParent.addPropertyChangeListener(fPropertyListener); + } + } + + public void stop() { + if (fPropertyListener != null) { + fParent.removePropertyChangeListener(fPropertyListener); + fPropertyListener = null; + } + } + + /* + * @see IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener) + */ + public void addPropertyChangeListener(IPropertyChangeListener listener) { + fStore.addPropertyChangeListener(listener); + } + + /* + * @see IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener) + */ + public void removePropertyChangeListener(IPropertyChangeListener listener) { + fStore.removePropertyChangeListener(listener); + } + + /* + * @see IPreferenceStore#firePropertyChangeEvent(String, Object, Object) + */ + public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) { + fStore.firePropertyChangeEvent(name, oldValue, newValue); + } + + /* + * @see IPreferenceStore#contains(String) + */ + public boolean contains(String name) { + return fStore.contains(name); + } + + /* + * @see IPreferenceStore#getBoolean(String) + */ + public boolean getBoolean(String name) { + return fStore.getBoolean(name); + } + + /* + * @see IPreferenceStore#getDefaultBoolean(String) + */ + public boolean getDefaultBoolean(String name) { + return fStore.getDefaultBoolean(name); + } + + /* + * @see IPreferenceStore#getDefaultDouble(String) + */ + public double getDefaultDouble(String name) { + return fStore.getDefaultDouble(name); + } + + /* + * @see IPreferenceStore#getDefaultFloat(String) + */ + public float getDefaultFloat(String name) { + return fStore.getDefaultFloat(name); + } + + /* + * @see IPreferenceStore#getDefaultInt(String) + */ + public int getDefaultInt(String name) { + return fStore.getDefaultInt(name); + } + + /* + * @see IPreferenceStore#getDefaultLong(String) + */ + public long getDefaultLong(String name) { + return fStore.getDefaultLong(name); + } + + /* + * @see IPreferenceStore#getDefaultString(String) + */ + public String getDefaultString(String name) { + return fStore.getDefaultString(name); + } + + /* + * @see IPreferenceStore#getDouble(String) + */ + public double getDouble(String name) { + return fStore.getDouble(name); + } + + /* + * @see IPreferenceStore#getFloat(String) + */ + public float getFloat(String name) { + return fStore.getFloat(name); + } + + /* + * @see IPreferenceStore#getInt(String) + */ + public int getInt(String name) { + return fStore.getInt(name); + } + + /* + * @see IPreferenceStore#getLong(String) + */ + public long getLong(String name) { + return fStore.getLong(name); + } + + /* + * @see IPreferenceStore#getString(String) + */ + public String getString(String name) { + return fStore.getString(name); + } + + /* + * @see IPreferenceStore#isDefault(String) + */ + public boolean isDefault(String name) { + return fStore.isDefault(name); + } + + /* + * @see IPreferenceStore#needsSaving() + */ + public boolean needsSaving() { + return fStore.needsSaving(); + } + + /* + * @see IPreferenceStore#putValue(String, String) + */ + public void putValue(String name, String value) { + if (covers(name)) + fStore.putValue(name, value); + } + + /* + * @see IPreferenceStore#setDefault(String, double) + */ + public void setDefault(String name, double value) { + if (covers(name)) + fStore.setDefault(name, value); + } + + /* + * @see IPreferenceStore#setDefault(String, float) + */ + public void setDefault(String name, float value) { + if (covers(name)) + fStore.setDefault(name, value); + } + + /* + * @see IPreferenceStore#setDefault(String, int) + */ + public void setDefault(String name, int value) { + if (covers(name)) + fStore.setDefault(name, value); + } + + /* + * @see IPreferenceStore#setDefault(String, long) + */ + public void setDefault(String name, long value) { + if (covers(name)) + fStore.setDefault(name, value); + } + + /* + * @see IPreferenceStore#setDefault(String, String) + */ + public void setDefault(String name, String value) { + if (covers(name)) + fStore.setDefault(name, value); + } + + /* + * @see IPreferenceStore#setDefault(String, boolean) + */ + public void setDefault(String name, boolean value) { + if (covers(name)) + fStore.setDefault(name, value); + } + + /* + * @see IPreferenceStore#setToDefault(String) + */ + public void setToDefault(String name) { + fStore.setToDefault(name); + } + + /* + * @see IPreferenceStore#setValue(String, double) + */ + public void setValue(String name, double value) { + if (covers(name)) + fStore.setValue(name, value); + } + + /* + * @see IPreferenceStore#setValue(String, float) + */ + public void setValue(String name, float value) { + if (covers(name)) + fStore.setValue(name, value); + } + + /* + * @see IPreferenceStore#setValue(String, int) + */ + public void setValue(String name, int value) { + if (covers(name)) + fStore.setValue(name, value); + } + + /* + * @see IPreferenceStore#setValue(String, long) + */ + public void setValue(String name, long value) { + if (covers(name)) + fStore.setValue(name, value); + } + + /* + * @see IPreferenceStore#setValue(String, String) + */ + public void setValue(String name, String value) { + if (covers(name)) + fStore.setValue(name, value); + } + + /* + * @see IPreferenceStore#setValue(String, boolean) + */ + public void setValue(String name, boolean value) { + if (covers(name)) + fStore.setValue(name, value); + } +} \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.java index dfda1e6..6088388 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPPreferencesMessages.java @@ -4,33 +4,43 @@ import java.text.MessageFormat; import java.util.MissingResourceException; import java.util.ResourceBundle; +import org.eclipse.jface.preference.IPreferenceStore; + +import net.sourceforge.phpeclipse.IPreferenceConstants; +import net.sourceforge.phpeclipse.PHPeclipsePlugin; + public class PHPPreferencesMessages { + static IPreferenceStore store = PHPeclipsePlugin.getDefault().getPreferenceStore(); + static String resourceBundleName; + static { + resourceBundleName = store.getString(IPreferenceConstants.RESOURCE_BUNDLE); + } + private static ResourceBundle resourceBundle = ResourceBundle.getBundle(resourceBundleName); + + private PHPPreferencesMessages() { + } + + public static String getString(String key) { + try { + return resourceBundle.getString(key); + } catch (MissingResourceException e) { + return '!' + key + '!'; + } + } + public static void setResourceBundle(String newResourceBundle) { + resourceBundle = ResourceBundle.getBundle(newResourceBundle); + } + + public static String getFormattedString(String key, String arg) { + return getFormattedString(key, new String[] { arg }); + } + + public static String getFormattedString(String key, String[] args) { + return MessageFormat.format(getString(key), args); + } - private static final String RESOURCE_BUNDLE= "net.sourceforge.phpeclipse.preferences.PHPPreferencesMessages";//$NON-NLS-1$ - - private static ResourceBundle resourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE); - - private PHPPreferencesMessages() { - } - - public static String getString(String key) { - try { - return resourceBundle.getString(key); - } catch (MissingResourceException e) { - return '!' + key + '!'; - } - } - - public static String getFormattedString(String key, String arg) { - return getFormattedString(key, new String[] { arg }); - } - - public static String getFormattedString(String key, String[] args) { - return MessageFormat.format(getString(key), args); - } - - public static ResourceBundle getResourceBundle() { - return resourceBundle; - } + public static ResourceBundle getResourceBundle() { + return resourceBundle; + } } diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPProjectLibraryPage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPProjectLibraryPage.java index 98d1cff..618e810 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPProjectLibraryPage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPProjectLibraryPage.java @@ -24,124 +24,129 @@ import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbench; import net.sourceforge.phpeclipse.PHPeclipsePlugin; -import net.sourceforge.phpeclipse.resourcesview.PHPProject; +import net.sourceforge.phpeclipse.resourcesview.PHPProject; public class PHPProjectLibraryPage { - protected PHPProject workingProject; + protected PHPProject workingProject; - protected PHPProjectLibraryPage(PHPProject theWorkingProject) { - super(); - workingProject = theWorkingProject; - } - - protected Control getControl(Composite parent) { - Composite composite = new Composite(parent, SWT.NONE); - composite.setLayout(new FillLayout()); - - Table projectsTable = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); - projectsTable.setHeaderVisible(false); - projectsTable.setLinesVisible(false); - projectsTable.computeSize(SWT.DEFAULT, SWT.DEFAULT); - - TableColumn tableColumn = new TableColumn(projectsTable, SWT.NONE); - tableColumn.setWidth(200); - tableColumn.setText(PHPPreferencesMessages.getString("PHPProjectLibraryPage.project")); //$NON-NLS-1$ - - CheckboxTableViewer projectsTableViewer = new CheckboxTableViewer(projectsTable); - projectsTableViewer.addCheckStateListener(new ICheckStateListener() { - public void checkStateChanged(CheckStateChangedEvent event) { - projectCheckedUnchecked(event); - } - }); - - projectsTableViewer.setContentProvider(getContentProvider()); - projectsTableViewer.setLabelProvider(getLabelProvider()); - - projectsTableViewer.setInput(getWorkspaceProjects()); - projectsTableViewer.setCheckedElements(workingProject.getReferencedProjects().toArray()); - - return composite; - } - - protected void projectCheckedUnchecked(CheckStateChangedEvent event) { - IProject checkEventProject = (IProject) event.getElement(); - if (event.getChecked()) - getWorkingProject().addLoadPathEntry(checkEventProject); - else - getWorkingProject().removeLoadPathEntry(checkEventProject); - } - - protected PHPProject getWorkingProject() { - return workingProject; - } - - protected List getWorkspaceProjects() { - IWorkspaceRoot root = PHPeclipsePlugin.getWorkspace().getRoot(); - return Arrays.asList(root.getProjects()); - } - - protected ITableLabelProvider getLabelProvider() { - ITableLabelProvider labelProvider = new ITableLabelProvider() { - public Image getColumnImage(Object element, int columnIndex) { - IWorkbench workbench= PHPeclipsePlugin.getDefault().getWorkbench(); - return workbench.getSharedImages().getImage(ISharedImages.IMG_OBJ_PROJECT); - } - - public String getColumnText(Object element, int columnIndex) { - if (element instanceof IProject) - return ((IProject) element).getName(); - - return PHPPreferencesMessages.getString("PHPProjectLibraryPage.elementNotIProject"); //$NON-NLS-1$ - } - - public void addListener(ILabelProviderListener listener) {} - - public void dispose() {} - - public boolean isLabelProperty(Object element, String property) { - return false; - } - - public void removeListener(ILabelProviderListener listener) {} - }; - - return labelProvider; - } - - protected IContentProvider getContentProvider() { - IStructuredContentProvider contentProvider = new IStructuredContentProvider() { - protected List phpProjects; - - public Object[] getElements(Object inputElement) { - return phpProjects.toArray(); - } - - public void dispose() {} - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { - phpProjects = new ArrayList(); - - if (!(newInput instanceof List)) - return; - - Iterator workspaceProjectsIterator = ((List) newInput).iterator(); - while (workspaceProjectsIterator.hasNext()) { - Object anObject = workspaceProjectsIterator.next(); - if (anObject instanceof IProject) { - IProject project = (IProject) anObject; - if (project.getName() != workingProject.getProject().getName()) { - try { - if (project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) - phpProjects.add(project); - } catch (CoreException e) {} - } - } - } - } - }; - - return contentProvider; - } + protected PHPProjectLibraryPage(PHPProject theWorkingProject) { + super(); + workingProject = theWorkingProject; + } + + protected Control getControl(Composite parent) { + Composite composite = new Composite(parent, SWT.NONE); + composite.setLayout(new FillLayout()); + + Table projectsTable = new Table(composite, SWT.CHECK | SWT.BORDER | SWT.MULTI | SWT.FULL_SELECTION); + projectsTable.setHeaderVisible(false); + projectsTable.setLinesVisible(false); + projectsTable.computeSize(SWT.DEFAULT, SWT.DEFAULT); + + TableColumn tableColumn = new TableColumn(projectsTable, SWT.NONE); + tableColumn.setWidth(200); + tableColumn.setText(PHPPreferencesMessages.getString("PHPProjectLibraryPage.project")); //$NON-NLS-1$ + + CheckboxTableViewer projectsTableViewer = new CheckboxTableViewer(projectsTable); + projectsTableViewer.addCheckStateListener(new ICheckStateListener() { + public void checkStateChanged(CheckStateChangedEvent event) { + projectCheckedUnchecked(event); + } + }); + + projectsTableViewer.setContentProvider(getContentProvider()); + projectsTableViewer.setLabelProvider(getLabelProvider()); + + projectsTableViewer.setInput(getWorkspaceProjects()); + projectsTableViewer.setCheckedElements(workingProject.getReferencedProjects().toArray()); + + return composite; + } + + protected void projectCheckedUnchecked(CheckStateChangedEvent event) { + IProject checkEventProject = (IProject) event.getElement(); + if (event.getChecked()) + getWorkingProject().addLoadPathEntry(checkEventProject); + else + getWorkingProject().removeLoadPathEntry(checkEventProject); + } + + protected PHPProject getWorkingProject() { + return workingProject; + } + + protected List getWorkspaceProjects() { + IWorkspaceRoot root = PHPeclipsePlugin.getWorkspace().getRoot(); + return Arrays.asList(root.getProjects()); + } + + protected ITableLabelProvider getLabelProvider() { + ITableLabelProvider labelProvider = new ITableLabelProvider() { + public Image getColumnImage(Object element, int columnIndex) { + IWorkbench workbench = PHPeclipsePlugin.getDefault().getWorkbench(); + return workbench.getSharedImages().getImage(ISharedImages.IMG_OBJ_PROJECT); + } + + public String getColumnText(Object element, int columnIndex) { + if (element instanceof IProject) + return ((IProject) element).getName(); + + return PHPPreferencesMessages.getString("PHPProjectLibraryPage.elementNotIProject"); //$NON-NLS-1$ + } + + public void addListener(ILabelProviderListener listener) { + } + + public void dispose() { + } + + public boolean isLabelProperty(Object element, String property) { + return false; + } + + public void removeListener(ILabelProviderListener listener) { + } + }; + + return labelProvider; + } + + protected IContentProvider getContentProvider() { + IStructuredContentProvider contentProvider = new IStructuredContentProvider() { + protected List phpProjects; + + public Object[] getElements(Object inputElement) { + return phpProjects.toArray(); + } + + public void dispose() { + } + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + phpProjects = new ArrayList(); + + if (!(newInput instanceof List)) + return; + + Iterator workspaceProjectsIterator = ((List) newInput).iterator(); + while (workspaceProjectsIterator.hasNext()) { + Object anObject = workspaceProjectsIterator.next(); + if (anObject instanceof IProject) { + IProject project = (IProject) anObject; + if (project.getName() != workingProject.getProject().getName()) { + try { + if (project.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) + phpProjects.add(project); + } catch (CoreException e) { + } + } + } + } + } + }; + + return contentProvider; + } } \ No newline at end of file diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPProjectPropertyPage.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPProjectPropertyPage.java index fa07e17..55e6f90 100644 --- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPProjectPropertyPage.java +++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/preferences/PHPProjectPropertyPage.java @@ -20,78 +20,78 @@ import org.eclipse.ui.IWorkbenchPropertyPage; import org.eclipse.ui.dialogs.PropertyPage; public class PHPProjectPropertyPage extends PropertyPage implements IWorkbenchPropertyPage { - protected PHPProjectLibraryPage projectsPage; - protected PHPProject workingProject; - - public PHPProjectPropertyPage() { - } - - protected Control createContents(Composite parent) { - noDefaultAndApplyButton(); - - workingProject = getPHPProject(); - if (workingProject == null || !workingProject.getProject().isOpen()) - return createClosedProjectPageContents(parent); - - return createProjectPageContents(parent); - } - - protected PHPProject getPHPProject() { - IAdaptable selectedElement = getElement(); - if (selectedElement == null) - return null; - - if (selectedElement instanceof PHPProject) - return (PHPProject) selectedElement; - - if (selectedElement instanceof IProject) { - IProject simpleProject = (IProject) selectedElement; - try { - if (simpleProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) { - PHPProject phpProject = new PHPProject(); - phpProject.setProject(simpleProject); - return phpProject; - } - } catch(CoreException e) { - PHPeclipsePlugin.log(e); - } - } - - return null; - } - - protected Control createClosedProjectPageContents(Composite parent) { - Label label = new Label(parent, SWT.NONE); - label.setText(PHPPreferencesMessages.getString("PHPProjectPropertyPage.phpProjectClosed")); //$NON-NLS-1$ - - return label; - } - - protected Control createProjectPageContents(Composite parent) { - TabFolder tabFolder = new TabFolder(parent, SWT.NONE); - tabFolder.setLayout(new GridLayout()); - tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH)); - tabFolder.addSelectionListener(new SelectionAdapter() { - public void widgetSelected(SelectionEvent e) { - //tabChanged(e.item); - } - }); - - projectsPage = new PHPProjectLibraryPage(workingProject); - TabItem tabItem = new TabItem(tabFolder, SWT.NONE); - tabItem.setText(PHPPreferencesMessages.getString("PHPProjectLibraryPage.tabName")); //$NON-NLS-1$ -// tabItem.setData(projectsPage); - tabItem.setControl(projectsPage.getControl(tabFolder)); - - return tabFolder; - } - public boolean performOk() { - try { - projectsPage.getWorkingProject().save(); - } catch (CoreException e) { + protected PHPProjectLibraryPage projectsPage; + protected PHPProject workingProject; + + public PHPProjectPropertyPage() { + } + + protected Control createContents(Composite parent) { + noDefaultAndApplyButton(); + + workingProject = getPHPProject(); + if (workingProject == null || !workingProject.getProject().isOpen()) + return createClosedProjectPageContents(parent); + + return createProjectPageContents(parent); + } + + protected PHPProject getPHPProject() { + IAdaptable selectedElement = getElement(); + if (selectedElement == null) + return null; + + if (selectedElement instanceof PHPProject) + return (PHPProject) selectedElement; + + if (selectedElement instanceof IProject) { + IProject simpleProject = (IProject) selectedElement; + try { + if (simpleProject.hasNature(PHPeclipsePlugin.PHP_NATURE_ID)) { + PHPProject phpProject = new PHPProject(); + phpProject.setProject(simpleProject); + return phpProject; + } + } catch (CoreException e) { + PHPeclipsePlugin.log(e); + } + } + + return null; + } + + protected Control createClosedProjectPageContents(Composite parent) { + Label label = new Label(parent, SWT.NONE); + label.setText(PHPPreferencesMessages.getString("PHPProjectPropertyPage.phpProjectClosed")); //$NON-NLS-1$ + + return label; + } + + protected Control createProjectPageContents(Composite parent) { + TabFolder tabFolder = new TabFolder(parent, SWT.NONE); + tabFolder.setLayout(new GridLayout()); + tabFolder.setLayoutData(new GridData(GridData.FILL_BOTH)); + tabFolder.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + //tabChanged(e.item); + } + }); + + projectsPage = new PHPProjectLibraryPage(workingProject); + TabItem tabItem = new TabItem(tabFolder, SWT.NONE); + tabItem.setText(PHPPreferencesMessages.getString("PHPProjectLibraryPage.tabName")); //$NON-NLS-1$ + // tabItem.setData(projectsPage); + tabItem.setControl(projectsPage.getControl(tabFolder)); + + return tabFolder; + } + public boolean performOk() { + try { + projectsPage.getWorkingProject().save(); + } catch (CoreException e) { PHPeclipsePlugin.log(e); - } - return super.performOk(); - } + } + return super.performOk(); + } } -- 1.7.1