JET

edu.utep.cs.et.rat.val
Class MethodCall

java.lang.Object
  extended by edu.utep.cs.et.rat.val.CompositeValue
      extended by edu.utep.cs.et.rat.val.MethodCall
All Implemented Interfaces:
Denotable

public class MethodCall
extends CompositeValue

A class to represent a method call. A method call is represented as a tuple of a method (Method), a receiver (Denotable), and actual arguments (an array of Denotables). The current implementation assumes that the return type of the called method is a reference type.

Version:
$Revision: 1.11 $
Author:
Yoonsik Cheon

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.utep.cs.et.rat.val.CompositeValue
CompositeValue.SimpleVarGenerator
 
Field Summary
private  Method method
          The constructor to be called.
private  Denotable receiver
          The receiver of the call.
 
Constructor Summary
MethodCall(Class type, Method meth, Denotable receiver, Denotable[] args)
          Creates a new instance with the given constructor and arguments.
 
Method Summary
 String code()
          Returns a textual representation of the object denoted by this method call.
 String[] code(VarGenerator varGen)
          Returns Java source code that, if evaluated, constructs the object represented by this method call.
 Class getReturnType()
          Returns the return type of this method call.
 boolean isEquivalentTo(Denotable other)
          Returns true if the represented value is equivalent to the argument's represented value.
private  boolean isStatic()
          Returns true if this is a static method call.
 String toString()
          Returns the string representation of this method call.
 Object value()
          Evaluates this method call and returns the result.
 
Methods inherited from class edu.utep.cs.et.rat.val.CompositeValue
elems, getTypeName, hasEquals, isNull, type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

method

private final Method method
The constructor to be called.


receiver

private final Denotable receiver
The receiver of the call.

Constructor Detail

MethodCall

public MethodCall(Class type,
                  Method meth,
                  Denotable receiver,
                  Denotable[] args)
Creates a new instance with the given constructor and arguments.

Method Detail

getReturnType

public Class getReturnType()
Returns the return type of this method call.


value

public Object value()
Evaluates this method call and returns the result.


toString

public String toString()
Returns the string representation of this method call.

Specified by:
toString in interface Denotable
Overrides:
toString in class Object

code

public String code()
Returns a textual representation of the object denoted by this method call. The returned string has the following general form:
  x where:
  Tn xn = new Tn();
  xn.m();
  ...
  T1 x1 = new T1();
  x1.m(..., xi, ...);
 

See Also:
code(VarGenerator)

code

public String[] code(VarGenerator varGen)
Returns Java source code that, if evaluated, constructs the object represented by this method call. The given argument is used to generate unique temporary variables to store intermediate values and the constructed object. The first element of the returned array contains Java source code of the following general form:
  Tn xn = new Tn();
  xn.m();
  ...
  T1 x1 = new T1();
  x1.m(..., xi, ...);
 
The second element gives the name of the variable (e.g., x1) that contains the constructed object.

Specified by:
code in class CompositeValue
See Also:
code(VarGenerator)

isEquivalentTo

public boolean isEquivalentTo(Denotable other)
Returns true if the represented value is equivalent to the argument's represented value.

Specified by:
isEquivalentTo in interface Denotable
Overrides:
isEquivalentTo in class CompositeValue

isStatic

private boolean isStatic()
Returns true if this is a static method call.


JET

JET is Copyright (C) 2005-2007 by The University of Texas at El Paso and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.