Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSasikanth Bharadwaj2015-12-04 10:04:21 +0000
committerSasikanth Bharadwaj2015-12-04 11:57:14 +0000
commit2a0cf5d02f91a6763e9479538246eb1dfa0e7ff5 (patch)
tree8be4f18225808f99432dd347b73223a15f3ae61b
parent8301a45d9100d5793829493652e9e27cc4e261a1 (diff)
downloadeclipse.jdt.core-sasikanth/betaJ9New.tar.gz
eclipse.jdt.core-sasikanth/betaJ9New.tar.xz
eclipse.jdt.core-sasikanth/betaJ9New.zip
WIP - code gen support for module-infosasikanth/betaJ9New
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java6
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java26
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java4
-rw-r--r--org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java10
4 files changed, 31 insertions, 15 deletions
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
index 816369ee70..5c4eb66136 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/CompilationUnitDeclaration.java
@@ -202,10 +202,10 @@ public void createPackageInfoType() {
this.types[0] = declaration; // Assumes the first slot is meant for this type
}
-public void createModuleInfoType() {
- TypeDeclaration declaration = new TypeDeclaration(this.compilationResult);
+public void createModuleInfoType(ModuleDeclaration declaration) {
+ //TypeDeclaration declaration = new TypeDeclaration(this.compilationResult);
declaration.name = TypeConstants.MODULE_INFO_NAME;
- declaration.modifiers = ClassFileConstants.AccDefault | ClassFileConstants.AccInterface;
+ declaration.modifiers = ClassFileConstants.AccModule;
declaration.javadoc = this.javadoc;
this.types[0] = declaration; // Assumes the first slot is meant for this type
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java
index 073e05b4c6..5151cfbeb0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ModuleDeclaration.java
@@ -1,12 +1,14 @@
package org.eclipse.jdt.internal.compiler.ast;
+import org.eclipse.jdt.core.compiler.CharOperation;
import org.eclipse.jdt.internal.compiler.CompilationResult;
import org.eclipse.jdt.internal.compiler.codegen.CodeStream;
import org.eclipse.jdt.internal.compiler.flow.FlowContext;
import org.eclipse.jdt.internal.compiler.flow.FlowInfo;
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
-public class ModuleDeclaration extends Statement {
+public class ModuleDeclaration extends TypeDeclaration {
public ExportReference[] exports;
public ModuleReference[] requires;
@@ -21,13 +23,14 @@ public class ModuleDeclaration extends Statement {
public char[][] moduleName;
public long[] sourcePositions;
- public int declarationSourceStart;
- public int declarationSourceEnd;
- public int bodyStart;
- public int bodyEnd; // doesn't include the trailing comment if any.
- public CompilationResult compilationResult;
+// public int declarationSourceStart;
+// public int declarationSourceEnd;
+// public int bodyStart;
+// public int bodyEnd; // doesn't include the trailing comment if any.
+// public CompilationResult compilationResult;
public ModuleDeclaration(CompilationResult compilationResult, char[][] tokens, long[] positions) {
+ super(compilationResult);
this.compilationResult = compilationResult;
this.exportsCount = 0;
this.requiresCount = 0;
@@ -49,8 +52,8 @@ public class ModuleDeclaration extends Statement {
@Override
public void generateCode(BlockScope currentScope, CodeStream codeStream) {
- // TODO Auto-generated method stub
-
+ //
+ super.generateCode(currentScope, codeStream);
}
@Override
@@ -60,8 +63,9 @@ public class ModuleDeclaration extends Statement {
}
@Override
- public void resolve(BlockScope scope) {
- // TODO Auto-generated method stub
-
+ public void resolve(CompilationUnitScope upperScope) {
+ //
+ super.resolve(upperScope);
+ this.binding.compoundName = CharOperation.arrayConcat(this.moduleName, this.name);
}
}
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
index 46455ee27b..557277aed0 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/lookup/ClassScope.java
@@ -640,6 +640,10 @@ public class ClassScope extends Scope {
}
}
} else {
+ if (sourceType.sourceName == TypeConstants.MODULE_INFO_NAME) {
+ // TBD - allowed only at source level 1.9 or above
+ modifiers = ClassFileConstants.AccModule;
+ } else
// detect abnormal cases for classes
if (isMemberType) { // includes member types defined inside local types
final int UNEXPECTED_MODIFIERS = ~(ClassFileConstants.AccPublic | ClassFileConstants.AccPrivate | ClassFileConstants.AccProtected | ClassFileConstants.AccStatic | ClassFileConstants.AccAbstract | ClassFileConstants.AccFinal | ClassFileConstants.AccStrictfp);
diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
index aeead8d5e2..cee71ab0fd 100644
--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/parser/Parser.java
@@ -5,6 +5,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
+ * This is an implementation of an early-draft specification developed under the Java
+ * Community Process (JCP) and is made available for testing and evaluation purposes
+ * only. The code is not compatible with any specification of the JCP.
+ *
* Contributors:
* IBM Corporation - initial API and implementation
* Tom Tromey - patch for readTable(String) as described in http://bugs.eclipse.org/bugs/show_bug.cgi?id=32196
@@ -5597,6 +5601,10 @@ protected void consumePackageComment() {
}
protected void consumeInternalCompilationUnitWithModuleDeclaration() {
this.compilationUnit.moduleDeclaration = (ModuleDeclaration)this.astStack[this.astPtr--];
+ if (this.compilationUnit.isModuleInfo()) {
+ this.compilationUnit.types = new TypeDeclaration[1];
+ this.compilationUnit.createModuleInfoType(this.compilationUnit.moduleDeclaration);
+ }
this.astLengthStack[this.astLengthPtr--] = 0;
}
protected void consumeRequiresStatement() {
@@ -5642,8 +5650,8 @@ protected void consumeSingleRequiresModuleName() {
impt.declarationEnd = impt.declarationSourceEnd;
//this.endPosition is just before the ;
impt.declarationSourceStart = this.intStack[this.intPtr--];
- impt.modifiersSourceStart = this.intStack[this.intPtr--];
impt.modifiers = this.intStack[this.intPtr--];
+ impt.modifiersSourceStart = this.intStack[this.intPtr--];
if (impt.modifiersSourceStart >= 0) {
impt.declarationSourceStart = impt.modifiersSourceStart;
}

Back to the top