Skip to main content
summaryrefslogtreecommitdiffstats
blob: 7588b62946a693f0a7f346b1c6de31af6ae5dfa8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*******************************************************************************
 * Copyright (c) 2005 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
 *******************************************************************************/
/*


 */
package org.eclipse.jem.internal.proxy.initParser.tree;
 

/**
 * This represents a Variable Reference value. A variable reference value can be on the left
 * side of an assignment (e.g. field or array access) or on any side
 * of any expression. When on the left side of an assignment, then the
 * value can assigned to. Such as <code>x[3] = 4</code>. Or it is value
 * that can be used in expressions, such as <code>x[3] + 2</code>.
 * <p>
 * When dereferenced, the value is given (see {@link VariableReference#dereference()}) as
 * the result or it is set with a value and then deferenced (see {@link VariableReference#set(Object, Class)}).
 * <p>
 * The type of the reference is the type stored in the corresponding expressionTypeStack entry. This is the type
 * for assignment, and the type for dereferenced.
 * @since 1.1.0
 */
public abstract class VariableReference {

	/**
	 * Dereference the value. 
	 * @return the dereferenced value. Such as the result of <code>x[3]</code>. The type of the reference 
	 * is the type stored in the corresponding expressionTypeStack entry for this reference.
	 * @throws IllegalAccessException
	 * @throws IllegalArgumentException
	 * 
	 * @since 1.1.0
	 */
	public abstract Object dereference();
	
	/**
	 * Set the value into the variable and dereference it. Once it is set it is
	 * no longer a reference and must be dereferenced.
	 * @param value value to set to.
	 * @param type type of the value being set. It may be of use to the reference or maybe not.
	 * @return the dereferenced value after being set. The type of the dereferenced value 
	 * is the type stored in the corresponding expressionTypeStack entry for this reference.
	 * @throws IllegalAccessException
	 * @throws IllegalArgumentException
	 * 
	 * @since 1.1.0
	 */
	public abstract Object set(Object value, Class type) throws IllegalArgumentException, IllegalAccessException;
}

Back to the top