JET

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

java.lang.Object
  extended by edu.utep.cs.jet.rat.val.CompositeValue
      extended by edu.utep.cs.jet.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.16 $
Author:
Yoonsik Cheon

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.utep.cs.jet.rat.val.CompositeValue
CompositeValue.SimpleVarGenerator
 
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.
 Object[] getArguments()
          Returns the arguments used to call the method
 Method getMethod()
          Returns the method wrapped by this Denotable
 Denotable getReceiver()
          Returns the receiver object of the 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.
 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.jet.rat.val.CompositeValue
elems, hasEquals, isNull, type
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

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

getMethod

public Method getMethod()
Returns the method wrapped by this Denotable


getArguments

public Object[] getArguments()
Returns the arguments used to call the method


getReceiver

public Denotable getReceiver()
Returns the receiver object of the method call


JET

JET is Copyright (C) 2005-2008 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.