1 /*******************************************************************************
2 * Copyright (c) 2000, 2003 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpeclipse.internal.compiler.ast;
13 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.flow.FlowContext;
15 import net.sourceforge.phpdt.internal.compiler.flow.FlowInfo;
16 import net.sourceforge.phpdt.internal.compiler.lookup.ArrayBinding;
17 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
18 import net.sourceforge.phpdt.internal.compiler.lookup.FieldBinding;
19 import net.sourceforge.phpdt.internal.compiler.lookup.SourceTypeBinding;
20 import net.sourceforge.phpdt.internal.compiler.lookup.TypeBinding;
22 public class ClassLiteralAccess extends Expression {
24 public TypeReference type;
25 public TypeBinding targetType;
26 FieldBinding syntheticField;
28 public ClassLiteralAccess(int sourceEnd, TypeReference t) {
30 this.sourceStart = t.sourceStart;
31 this.sourceEnd = sourceEnd;
34 public FlowInfo analyseCode(
35 BlockScope currentScope,
36 FlowContext flowContext,
39 // if reachable, request the addition of a synthetic field for caching the class descriptor
40 SourceTypeBinding sourceType =
41 currentScope.outerMostMethodScope().enclosingSourceType();
42 if (!(sourceType.isInterface()
43 // no field generated in interface case (would'nt verify) see 1FHHEZL
44 || sourceType.isBaseType())) {
45 syntheticField = sourceType.addSyntheticField(targetType, currentScope);
51 * MessageSendDotClass code generation
53 * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
54 * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
55 * @param valueRequired boolean
57 // public void generateCode(
58 // BlockScope currentScope,
59 // CodeStream codeStream,
60 // boolean valueRequired) {
61 // int pc = codeStream.position;
63 // // in interface case, no caching occurs, since cannot make a cache field for interface
65 // codeStream.generateClassLiteralAccessForType(type.resolvedType, syntheticField);
66 // codeStream.recordPositionsFrom(pc, this.sourceStart);
69 public TypeBinding resolveType(BlockScope scope) {
71 constant = NotAConstant;
72 if ((targetType = type.resolveType(scope)) == null)
75 if (targetType.isArrayType()
76 && ((ArrayBinding) targetType).leafComponentType == VoidBinding) {
77 scope.problemReporter().cannotAllocateVoidArray(this);
81 return this.resolvedType = scope.getJavaLangClass();
84 public String toStringExpression() {
86 String s = ""; //$NON-NLS-1$
87 s = s + type.toString(0) + ".class"; //$NON-NLS-1$
92 IAbstractSyntaxTreeVisitor visitor,
93 BlockScope blockScope) {
95 if (visitor.visit(this, blockScope)) {
96 type.traverse(visitor, blockScope);
98 visitor.endVisit(this, blockScope);