use of org.eclipse.jdt.internal.compiler.problem.AbortType in project bazel-jdt-java-toolchain by salesforce.
the class ModuleDeclaration method generateCode.
public void generateCode() {
if ((this.bits & ASTNode.HasBeenGenerated) != 0)
return;
this.bits |= ASTNode.HasBeenGenerated;
if (this.ignoreFurtherInvestigation) {
return;
}
try {
// create the result for a compiled type
LookupEnvironment env = this.scope.environment();
ClassFile classFile = env.classFilePool.acquireForModule(this.binding, env.globalOptions);
classFile.initializeForModule(this.binding);
// finalize the compiled type result
classFile.addModuleAttributes(this.binding, this.annotations, this.scope.referenceCompilationUnit());
this.scope.referenceCompilationUnit().compilationResult.record(this.binding.moduleName, classFile);
} catch (AbortType e) {
if (this.binding == null)
return;
}
}
use of org.eclipse.jdt.internal.compiler.problem.AbortType in project bazel-jdt-java-toolchain by salesforce.
the class ClassFile method addSpecialMethods.
/**
* INTERNAL USE-ONLY
* Generate the byte for all the special method infos.
* They are:
* - synthetic access methods
* - default abstract methods
* - lambda methods.
*/
public void addSpecialMethods(TypeDeclaration typeDecl) {
// add all methods (default abstract methods and synthetic)
// default abstract methods
generateMissingAbstractMethods(this.referenceBinding.scope.referenceType().missingAbstractMethods, this.referenceBinding.scope.referenceCompilationUnit().compilationResult);
MethodBinding[] defaultAbstractMethods = this.referenceBinding.getDefaultAbstractMethods();
for (int i = 0, max = defaultAbstractMethods.length; i < max; i++) {
MethodBinding methodBinding = defaultAbstractMethods[i];
generateMethodInfoHeader(methodBinding);
int methodAttributeOffset = this.contentsOffset;
int attributeNumber = generateMethodInfoAttributes(methodBinding);
completeMethodInfo(methodBinding, methodAttributeOffset, attributeNumber);
}
// add synthetic methods infos
int emittedSyntheticsCount = 0;
SyntheticMethodBinding deserializeLambdaMethod = null;
boolean continueScanningSynthetics = true;
while (continueScanningSynthetics) {
continueScanningSynthetics = false;
SyntheticMethodBinding[] syntheticMethods = this.referenceBinding.syntheticMethods();
int currentSyntheticsCount = syntheticMethods == null ? 0 : syntheticMethods.length;
if (emittedSyntheticsCount != currentSyntheticsCount) {
for (int i = emittedSyntheticsCount, max = currentSyntheticsCount; i < max; i++) {
SyntheticMethodBinding syntheticMethod = syntheticMethods[i];
switch(syntheticMethod.purpose) {
case SyntheticMethodBinding.FieldReadAccess:
case SyntheticMethodBinding.SuperFieldReadAccess:
// generate a method info to emulate an reading access to
// a non-accessible field
addSyntheticFieldReadAccessMethod(syntheticMethod);
break;
case SyntheticMethodBinding.FieldWriteAccess:
case SyntheticMethodBinding.SuperFieldWriteAccess:
// generate a method info to emulate an writing access to
// a non-accessible field
addSyntheticFieldWriteAccessMethod(syntheticMethod);
break;
case SyntheticMethodBinding.MethodAccess:
case SyntheticMethodBinding.SuperMethodAccess:
case SyntheticMethodBinding.BridgeMethod:
// generate a method info to emulate an access to a non-accessible method / super-method or bridge method
addSyntheticMethodAccessMethod(syntheticMethod);
break;
case SyntheticMethodBinding.ConstructorAccess:
// generate a method info to emulate an access to a non-accessible constructor
addSyntheticConstructorAccessMethod(syntheticMethod);
break;
case SyntheticMethodBinding.EnumValues:
// generate a method info to define <enum>#values()
addSyntheticEnumValuesMethod(syntheticMethod);
break;
case SyntheticMethodBinding.EnumValueOf:
// generate a method info to define <enum>#valueOf(String)
addSyntheticEnumValueOfMethod(syntheticMethod);
break;
case SyntheticMethodBinding.SwitchTable:
// generate a method info to define the switch table synthetic method
addSyntheticSwitchTable(syntheticMethod);
break;
case SyntheticMethodBinding.TooManyEnumsConstants:
addSyntheticEnumInitializationMethod(syntheticMethod);
break;
case SyntheticMethodBinding.LambdaMethod:
syntheticMethod.lambda.generateCode(this.referenceBinding.scope, this);
// lambda code generation could schedule additional nested lambdas for code generation.
continueScanningSynthetics = true;
break;
case SyntheticMethodBinding.ArrayConstructor:
addSyntheticArrayConstructor(syntheticMethod);
break;
case SyntheticMethodBinding.ArrayClone:
addSyntheticArrayClone(syntheticMethod);
break;
case SyntheticMethodBinding.FactoryMethod:
addSyntheticFactoryMethod(syntheticMethod);
break;
case SyntheticMethodBinding.DeserializeLambda:
// delay processing
deserializeLambdaMethod = syntheticMethod;
break;
case SyntheticMethodBinding.SerializableMethodReference:
// Nothing to be done
break;
case SyntheticMethodBinding.RecordCanonicalConstructor:
addSyntheticRecordCanonicalConstructor(typeDecl, syntheticMethod);
break;
case SyntheticMethodBinding.RecordOverrideEquals:
case SyntheticMethodBinding.RecordOverrideHashCode:
case SyntheticMethodBinding.RecordOverrideToString:
addSyntheticRecordOverrideMethods(typeDecl, syntheticMethod, syntheticMethod.purpose);
break;
}
}
emittedSyntheticsCount = currentSyntheticsCount;
}
}
if (deserializeLambdaMethod != null) {
int problemResetPC = 0;
this.codeStream.wideMode = false;
boolean restart = false;
do {
try {
problemResetPC = this.contentsOffset;
addSyntheticDeserializeLambda(deserializeLambdaMethod, this.referenceBinding.syntheticMethods());
restart = false;
} catch (AbortMethod e) {
// Restart code generation if possible ...
if (e.compilationResult == CodeStream.RESTART_IN_WIDE_MODE) {
// a branch target required a goto_w, restart code generation in wide mode.
this.contentsOffset = problemResetPC;
this.methodCount--;
// request wide mode
this.codeStream.resetInWideMode();
restart = true;
} else {
throw new AbortType(this.referenceBinding.scope.referenceContext.compilationResult, e.problem);
}
}
} while (restart);
}
}
Aggregations