Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (c) 2000, 2013 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at http://www.eclipse.org/legal/epl-v10.html Contributors: IBM Corporation - initial API and implementation Jesper S Moller <jesper@selskabet.org> - Contributions for bug 378674 - "The method can be declared as static" is wrong /
 
 package org.eclipse.jdt.internal.compiler.ast;
 
 
 public class QualifiedThisReference extends ThisReference {
 
 
 	public QualifiedThisReference(TypeReference nameint sourceStartint sourceEnd) {
 		super(sourceStartsourceEnd);
 		this. = name;
 		name.bits |= // no need to worry about raw type usage
 		this. = name.sourceStart;
 	}
 
 	public FlowInfo analyseCode(
 		BlockScope currentScope,
 		FlowContext flowContext,
 		FlowInfo flowInfo) {
 
 		return flowInfo;
 	}
 
 	public FlowInfo analyseCode(
 		BlockScope currentScope,
 		FlowContext flowContext,
 		FlowInfo flowInfo,
 		boolean valueRequired) {
 
 		return flowInfo;
 	}

Code generation for QualifiedThisReference

Parameters:
currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
valueRequired boolean
 
 	public void generateCode(
 		BlockScope currentScope,
 		CodeStream codeStream,
 		boolean valueRequired) {
 
 		int pc = codeStream.position;
 		if (valueRequired) {
 			if ((this. & ) != 0) {
 				Object[] emulationPath =
 					currentScope.getEmulationPath(this.true /*only exact match*/false/*consider enclosing arg*/);
 				codeStream.generateOuterAccess(emulationPaththisthis.currentScope);
 			} else {
 				// nothing particular after all
 				codeStream.aload_0();
 			}
 		}
 		codeStream.recordPositionsFrom(pcthis.);
 	}
 
 	public TypeBinding resolveType(BlockScope scope) {
 
 		// X.this is not a param/raw type as denoting enclosing instance
 		TypeBinding type = this..resolveType(scopetrue /* check bounds*/);
 		if (type == null || !type.isValidBinding()) return null;
 		// X.this is not a param/raw type as denoting enclosing instance
 		type = type.erasure();
 
 		// resolvedType needs to be converted to parameterized
 		if (type instanceof ReferenceBinding) {
 		} else {
 			// error case
 			this. = type;
 		}
 
 		// the qualification MUST exactly match some enclosing type name
 		// It is possible to qualify 'this' by the name of the current class
 		int depth = 0;
 		while (this. != null && this. != type) {
 			depth++;
		}
		this. &= ~// flush previous depth if any
		this. |= (depth & 0xFF) << // encoded depth into 8 bits
		if (this. == null) {
			scope.problemReporter().noSuchEnclosingInstance(typethisfalse);
			return this.;
else {
			// Mark all methods between here and the declared type as not static
		}
		// Ensure one cannot write code like: B() { super(B.this); }
		if (depth == 0) {
// if depth>0, path emulation will diagnose bad scenarii
		return this.;
	}
	public StringBuffer printExpression(int indentStringBuffer output) {
		return this..print(0, output).append(".this"); //$NON-NLS-1$
	}
	public void traverse(
		ASTVisitor visitor,
		BlockScope blockScope) {
		if (visitor.visit(thisblockScope)) {
			this..traverse(visitorblockScope);
		}
		visitor.endVisit(thisblockScope);
	}
	public void traverse(
			ASTVisitor visitor,
			ClassScope blockScope) {
		if (visitor.visit(thisblockScope)) {
			this..traverse(visitorblockScope);
		}
		visitor.endVisit(thisblockScope);
	}
New to GrepCode? Check out our FAQ X