List of usage examples for org.eclipse.jdt.internal.compiler.lookup Scope compilerOptions
public final CompilerOptions compilerOptions()
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.ast.MethodSpec.java
License:Open Source License
void checkDecapsulation(ReferenceBinding baseClass, Scope scope) { if (!this.resolvedMethod.canBeSeenBy(baseClass, this, scope)) { WeavingScheme weavingScheme = scope.compilerOptions().weavingScheme; this.implementationStrategy = weavingScheme == WeavingScheme.OTDRE ? ImplementationStrategy.DYN_ACCESS : ImplementationStrategy.DECAPS_WRAPPER; this.accessId = createAccessAttribute(scope.enclosingSourceType().roleModel); scope.problemReporter().decapsulation(this, baseClass, scope); } else {/* ww w. j a va2 s .com*/ this.implementationStrategy = ImplementationStrategy.DIRECT; } }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lifting.Lifting.java
License:Open Source License
/** * @param baseClassBinding/*from w w w . ja v a2 s . com*/ * @param liftToConstructorDeclaration * @param gen */ public static Statement[] genRoleRegistrationStatements(Scope scope, RoleModel boundRootRoleModel, ReferenceBinding baseClassBinding, ConstructorDeclaration liftToConstructorDeclaration, AstGenerator gen) { Statement[] statements = new Statement[2]; // _OT$cache_OT$RootRole.put(<baseArgName>, this); Expression _this = gen.thisReference(); if (scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { _this = gen.castExpression(_this, gen.typeReference(boundRootRoleModel.getBinding()), CastExpression.DO_WRAP); } statements[0] = gen.messageSend( gen.singleNameReference(LiftingEnvironment.getCacheName(boundRootRoleModel)), PUT, new Expression[] { gen.baseNameReference(_OT_BASE), _this }); // ((IBoundBase)_OT$base).addRole(this); // prevent premature garbage collection Expression roleExpression = gen.thisReference(); if (TypeAnalyzer.isConfined(boundRootRoleModel.getBinding())) { // pretend this were compatible to Object: roleExpression.resolvedType = scope.getJavaLangObject(); roleExpression.constant = Constant.NotAConstant; } else { // here an (unnecessary) cast to j.l.Object prevents a warning re OTJLD 2.2(f): roleExpression = gen.castExpression(roleExpression, gen.qualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT), CastExpression.RAW); } statements[1] = // OTDYN: Slightly different methods depending on the weaving strategy: boundRootRoleModel.getWeavingScheme() == WeavingScheme.OTDRE ? gen.messageSend(gen.castExpression(gen.singleNameReference(_OT_BASE), gen.qualifiedTypeReference(ORG_OBJECTTEAMS_IBOUNDBASE2), CastExpression.RAW), ADD_REMOVE_ROLE, new Expression[] { roleExpression, gen.booleanLiteral(true) }) // isAdding : gen.messageSend( gen.castExpression(gen.singleNameReference(_OT_BASE), gen.qualifiedTypeReference(ORG_OBJECTTEAMS_IBOUNDBASE), CastExpression.RAW), ADD_ROLE, new Expression[] { roleExpression }); return statements; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.lookup.AnchorMapping.java
License:Open Source License
private AnchorMapping(Expression receiver, Statement[] arguments, Scope scope) { this._arguments = arguments; this._receiver = receiver; if (this._receiver instanceof ArrayReference) this._receiver = ((ArrayReference) this._receiver).receiver; this._scope = scope; this._methodSignatureEnhancer = MethodSignatureEnhancer.variants[scope.compilerOptions().weavingScheme .ordinal()];// w w w. j a v a2 s .com }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.MethodSignatureEnhancer.java
License:Open Source License
/** Get Typebindings for all enhancing arguments. */ private static TypeBinding[] getEnhancingArgTypes(Scope scope) { //{OTDyn: configurable: if (scope.compilerOptions().weavingScheme == WeavingScheme.OTDRE) return new TypeBinding[] { scope.getType(IOTConstants.ORG_OBJECTTEAMS_IBOUNDBASE2, 3), // _OT$baseArg scope.createArrayType(scope.getOrgObjectteamsITeam(), 1), // _OT$teams TypeBinding.INT, // _OT$index scope.createArrayType(TypeBinding.INT, 1), // _OT$callinIds TypeBinding.INT, // _OT$boundMethodId scope.createArrayType(scope.getJavaLangObject(), 1), // _OT$args };//from w w w . j av a 2 s .co m // SH} // {OT/JamVM support: else if (JAMVM_ASPECTBI) return new TypeBinding[] { scope.getJavaLangObject(), // _OT$teamIterator TypeBinding.INT, // _OT$bindIdx TypeBinding.INT, // _OT$baseMethodTag scope.createArrayType(scope.getJavaLangObject(), 1), // _OT$unusedArgs }; // CH} return new TypeBinding[] { scope.createArrayType(scope.getOrgObjectteamsITeam(), 1), // _OT$teams scope.createArrayType(TypeBinding.INT, 1), // _OT$teamIDs TypeBinding.INT, // _OT$idx TypeBinding.INT, // _OT$bindIdx TypeBinding.INT, // _OT$baseMethodTag scope.createArrayType(scope.getJavaLangObject(), 1), // _OT$unusedArgs }; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.MethodSignatureEnhancer.java
License:Open Source License
/** Enhance a type list with the enhancing argument's types. * * @param scope needed for lookup of types * @param parameters source parameters/*from w w w .j a va 2 s . c o m*/ * @return new array */ public static TypeBinding[] enhanceParameters(Scope scope, TypeBinding[] parameters) { return variants[scope.compilerOptions().weavingScheme.ordinal()].internalEnhanceParameters(scope, parameters); }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.RoleMigrationImplementor.java
License:Open Source License
static void genMigrateToBaseInstructions(CodeStream codeStream, SourceTypeBinding roleBinding, Scope scope, char[] cacheName) { FieldBinding baseField = roleBinding.getField(IOTConstants._OT_BASE, true); // accessing the cache (using remove() and put()): ReferenceBinding cacheTypeBinding = (ReferenceBinding) scope.getType(IOTConstants.WEAK_HASH_MAP, 3); MethodBinding remove = getMethod(cacheTypeBinding, "remove".toCharArray(), 1); //$NON-NLS-1$ MethodBinding put = cacheTypeBinding.getMethod(scope, "put".toCharArray()); //$NON-NLS-1$ // accessing the base object (using _OT$removeRole() and _OT$addRole()): WeavingScheme weavingScheme = scope.compilerOptions().weavingScheme; ReferenceBinding iboundBase = (ReferenceBinding) scope .getType(weavingScheme == WeavingScheme.OTDRE ? IOTConstants.ORG_OBJECTTEAMS_IBOUNDBASE2 : IOTConstants.ORG_OBJECTTEAMS_IBOUNDBASE, 3); // remove old from cache codeStream.aload_0(); // this codeStream.fieldAccess(Opcodes.OPC_getfield, enclosingInstanceField(roleBinding), // this.this$n roleBinding);//from ww w .j a v a 2 s. co m codeStream.fieldAccess(Opcodes.OPC_getfield, roleBinding.enclosingType().getField(cacheName, true), // this.this$n._OT$cache$R roleBinding.enclosingType()); codeStream.dup(); // for use in put() below codeStream.aload_0(); // this codeStream.fieldAccess(Opcodes.OPC_getfield, baseField, // this._OT$base roleBinding); codeStream.dup(); // share for nested method call // this._OT$base // remove role from this (old) base genAddOrRemoveRole(codeStream, scope, iboundBase, false);// -> void // -> base._OT$removeRole(this) codeStream.invoke(Opcodes.OPC_invokevirtual, remove, // -> cache.remove(base) cacheTypeBinding); codeStream.pop(); // discard result // this._OT$base = (MyBase)otherBase codeStream.aload_0(); // this codeStream.aload_1(); // otherBase codeStream.checkcast(roleBinding.baseclass()); codeStream.fieldAccess(Opcodes.OPC_putfield, baseField, roleBinding); // add new to cache (cache is still on the stack) codeStream.aload_1(); // otherBase codeStream.aload_0(); // this (role) codeStream.invoke(Opcodes.OPC_invokevirtual, put, cacheTypeBinding); // add to new base: codeStream.aload_1(); // otherBase genAddOrRemoveRole(codeStream, scope, iboundBase, true); // -> void // -> base._OT$addRemoveRole(this, false) codeStream.return_(); }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.statemachine.transformer.RoleMigrationImplementor.java
License:Open Source License
static void genAddOrRemoveRole(CodeStream codeStream, Scope scope, ReferenceBinding iboundBase, boolean isAdding) { codeStream.aload_0(); // this // OTDYN: Slightly different methods depending on the weaving strategy: switch (scope.compilerOptions().weavingScheme) { case OTDRE://from w w w. ja v a2 s . c o m // _OT$addOrRemoveRole(role, isAdding) if (isAdding) codeStream.iconst_1(); // isAdding=true else codeStream.iconst_0(); // isAdding=false codeStream.invoke(Opcodes.OPC_invokeinterface, iboundBase.getMethod(scope, IOTConstants.ADD_REMOVE_ROLE), iboundBase); break; case OTRE: // _OT$addRole(role) or _OT$removeRole(role): codeStream.invoke(Opcodes.OPC_invokeinterface, isAdding ? iboundBase.getMethod(scope, IOTConstants.ADD_ROLE) : iboundBase.getMethod(scope, IOTConstants.REMOVE_ROLE), iboundBase); } }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.util.AstGenerator.java
License:Open Source License
/** * A type reference for the cache of a given bound root role. * If source level >= 1.5 use a generic type for the cache! * Generic type respects different status for base/role types: * - base is resolved via base import scope and supports decapsulation. */// w ww. j ava 2s .c o m public QualifiedTypeReference getCacheTypeReference(Scope scope, RoleModel boundRootRole) { if ((scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5)) { ReferenceBinding baseTypeBinding = boundRootRole.getBaseTypeBinding(); if (baseTypeBinding == null) baseTypeBinding = scope.getJavaLangObject(); ReferenceBinding rootRoleBinding = boundRootRole.getInterfacePartBinding(); ParameterizedQualifiedTypeReference fieldTypeRef; TypeReference[] typeArguments = new TypeReference[] { baseclassReference(baseTypeBinding, true/*erase*/), singleTypeReference(rootRoleBinding.sourceName()) }; fieldTypeRef = (ParameterizedQualifiedTypeReference) parameterizedQualifiedTypeReference(WEAK_HASH_MAP, typeArguments); return fieldTypeRef; } else { return new QualifiedTypeReference(WEAK_HASH_MAP, new long[] { this.pos, this.pos, this.pos }); } }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.util.RoleTypeCreator.java
License:Open Source License
/** * This method assumes that the enclosing type of scope can be used for * tthis anchors, i.e., types are used unqualified. * * @param scope determines tthis (NON-NULL). * @param typeToWrap/*from w w w .j av a2 s . c o m*/ * @param typedNode * @return valid type, null (possibly after reporting error), or (unreported) problem */ public static TypeBinding maybeWrapUnqualifiedRoleType(Scope scope, TypeBinding typeToWrap, ASTNode typedNode) { /* external invocations (via maybeWrapUnqualifiedRoleType(TypeBinding, Scope, AstNode)?): * AllocationExpression.resolveType() new R R * ArrayAllocationExpression.resolveType() new R[] R * Assignment.resolveType() lhs = r type(r) * CastExpression.resolveType() (R)expr R * LocalDeclaration.resolve() R l = r R, type(r) * PotentialLiftExpression.resolveType() liftToR(b) R * RoleTypeReference.resolveType() this.R R * SingleNameReference.resolveType() n type(n) * ThisReference.resolveType() this type(this) * QualifiedThisReference.resolveType() Mid.this type(this) * other invocations: * MethodVerifier.areTypesEqual() * CopyInheritance.copyCastToMethods() * AbstractMethodMappingDeclaration.resolveMethodSpecs() * other internal invocation: * wrapTypesInMethodBindingSignature() * wrapTypesInMethodDeclSignature() * (via maybeWrapUnqualifiedRoleType(TypeBinding, Scope, AstNode)) * */ ReferenceBinding site = scope.enclosingSourceType(); MethodScope methodScope = scope.methodScope(); if (methodScope != null && methodScope.referenceMethod() != null && methodScope.referenceMethod().isMappingWrapper._callin() //{OTDyn && scope.compilerOptions().weavingScheme == WeavingScheme.OTRE) // this heuristic doesn't work for dyn weaving, FIXME(SH): check if still needed! // SH} { // in a callin wrapper, for visibility reasons, pretend we are in the // scope of the role (which is, where the declaration actually occurs): char[] selector = methodScope.referenceMethod().selector; int secondDollar = CharOperation.indexOf('$', selector, 4); // skip _OT$ char[] roleName = CharOperation.subarray(selector, 4, secondDollar); site = site.getMemberType(roleName); } return maybeWrapUnqualifiedRoleType(scope, site, typeToWrap, typedNode, scope.problemReporter()); }