cb8a551701b5a58af17c08207967a895809d717a
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / Reference.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v0.5 
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v05.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
12
13 import net.sourceforge.phpdt.internal.compiler.codegen.CodeStream;
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.BlockScope;
17 import net.sourceforge.phpdt.internal.compiler.lookup.FieldBinding;
18 import net.sourceforge.phpdt.internal.compiler.lookup.MethodBinding;
19 import net.sourceforge.phpdt.internal.compiler.problem.ShouldNotImplement;
20 import net.sourceforge.phpdt.internal.compiler.util.Util;
21
22 public abstract class Reference extends Expression  {
23 /**
24  * BaseLevelReference constructor comment.
25  */
26 public Reference() {
27         super();
28 }
29 public FlowInfo analyseAssignment(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo, Assignment assignment, boolean isCompound) {
30         throw new ShouldNotImplement(Util.bind("ast.variableShouldProvide")); //$NON-NLS-1$
31 }
32 public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
33         return flowInfo;
34 }
35 public FieldBinding fieldBinding() {
36         //this method should be sent one FIELD-tagged references
37         //  (ref.bits & BindingIds.FIELD != 0)()
38         return null ;
39 }
40 public void fieldStore(CodeStream codeStream, FieldBinding fieldBinding, MethodBinding syntheticWriteAccessor, boolean valueRequired) {
41
42         if (fieldBinding.isStatic()) {
43                 if (valueRequired) {
44                         if ((fieldBinding.type == LongBinding) || (fieldBinding.type == DoubleBinding)) {
45                                 codeStream.dup2();
46                         } else {
47                                 codeStream.dup();
48                         }
49                 }
50                 if (syntheticWriteAccessor == null) {
51                         codeStream.putstatic(fieldBinding);
52                 } else {
53                         codeStream.invokestatic(syntheticWriteAccessor);
54                 }
55         } else { // Stack:  [owner][new field value]  ---> [new field value][owner][new field value]
56                 if (valueRequired) {
57                         if ((fieldBinding.type == LongBinding) || (fieldBinding.type == DoubleBinding)) {
58                                 codeStream.dup2_x1();
59                         } else {
60                                 codeStream.dup_x1();
61                         }
62                 }
63                 if (syntheticWriteAccessor == null) {
64                         codeStream.putfield(fieldBinding);
65                 } else {
66                         codeStream.invokestatic(syntheticWriteAccessor);
67                 }
68         }
69 }
70 public void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired) {
71         throw new ShouldNotImplement(Util.bind("ast.compoundPreShouldProvide")); //$NON-NLS-1$
72 }
73 public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) {
74         throw new ShouldNotImplement(Util.bind("ast.compoundVariableShouldProvide")); //$NON-NLS-1$
75 }
76 public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) {
77         throw new ShouldNotImplement(Util.bind("ast.postIncrShouldProvide")); //$NON-NLS-1$
78 }
79 }