01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.compiler.ast;
11:
12: import org.eclipse.jdt.internal.compiler.codegen.*;
13: import org.eclipse.jdt.internal.compiler.flow.*;
14: import org.eclipse.jdt.internal.compiler.lookup.*;
15:
16: public abstract class Reference extends Expression {
17: /**
18: * BaseLevelReference constructor comment.
19: */
20: public Reference() {
21: super ();
22: }
23:
24: public abstract FlowInfo analyseAssignment(BlockScope currentScope,
25: FlowContext flowContext, FlowInfo flowInfo,
26: Assignment assignment, boolean isCompound);
27:
28: public FlowInfo analyseCode(BlockScope currentScope,
29: FlowContext flowContext, FlowInfo flowInfo) {
30: return flowInfo;
31: }
32:
33: public FieldBinding fieldBinding() {
34: //this method should be sent one FIELD-tagged references
35: // (ref.bits & BindingIds.FIELD != 0)()
36: return null;
37: }
38:
39: public void fieldStore(CodeStream codeStream,
40: FieldBinding fieldBinding,
41: MethodBinding syntheticWriteAccessor, boolean valueRequired) {
42: int pc = codeStream.position;
43: if (fieldBinding.isStatic()) {
44: if (valueRequired) {
45: if ((fieldBinding.type == TypeBinding.LONG)
46: || (fieldBinding.type == TypeBinding.DOUBLE)) {
47: codeStream.dup2();
48: } else {
49: codeStream.dup();
50: }
51: }
52: if (syntheticWriteAccessor == null) {
53: codeStream.putstatic(fieldBinding);
54: } else {
55: codeStream.invokestatic(syntheticWriteAccessor);
56: }
57: } else { // Stack: [owner][new field value] ---> [new field value][owner][new field value]
58: if (valueRequired) {
59: if ((fieldBinding.type == TypeBinding.LONG)
60: || (fieldBinding.type == TypeBinding.DOUBLE)) {
61: codeStream.dup2_x1();
62: } else {
63: codeStream.dup_x1();
64: }
65: }
66: if (syntheticWriteAccessor == null) {
67: codeStream.putfield(fieldBinding);
68: } else {
69: codeStream.invokestatic(syntheticWriteAccessor);
70: }
71: }
72: codeStream.recordPositionsFrom(pc, this .sourceStart);
73: }
74:
75: public abstract void generateAssignment(BlockScope currentScope,
76: CodeStream codeStream, Assignment assignment,
77: boolean valueRequired);
78:
79: public abstract void generateCompoundAssignment(
80: BlockScope currentScope, CodeStream codeStream,
81: Expression expression, int operator,
82: int assignmentImplicitConversion, boolean valueRequired);
83:
84: public abstract void generatePostIncrement(BlockScope currentScope,
85: CodeStream codeStream, CompoundAssignment postIncrement,
86: boolean valueRequired);
87: }
|