edu.cmu.cs.crystal.tac
Interface NewObjectInstruction

All Superinterfaces:
AssignmentInstruction, InvocationInstruction, TACInstruction, TACInvocation

public interface NewObjectInstruction
extends InvocationInstruction

x = new C(z1, ..., zn), including for anonymous inner classes. Notice that the code for anonymous inner classes does not become part of the three-address code representation of the surrounding method.

Author:
Kevin Bierhoff
See Also:
ClassInstanceCreation

Method Summary
 ASTNode getNode()
          Returns the node this instruction is for.
 Variable getOuterObjectSpecifierOperand()
          Returns the outer object specifier, if any.
 boolean hasOuterObjectSpecifier()
          Indicates whether there is an outer object specifier that is permitted by the Java language syntax.
 boolean isAnonClassType()
          Indicates whether this instruction instantiates an anonymous class.
 ITypeBinding resolveInstantiatedType()
          Resolves the instantiated type, which will usually be a class.
 
Methods inherited from interface edu.cmu.cs.crystal.tac.AssignmentInstruction
getTarget
 
Methods inherited from interface edu.cmu.cs.crystal.tac.TACInvocation
getArgOperands, resolveBinding
 
Methods inherited from interface edu.cmu.cs.crystal.tac.TACInstruction
transfer, transfer
 

Method Detail

getNode

ASTNode getNode()
Returns the node this instruction is for. Should be of type ClassInstanceCreation. Usually, one instruction exists per AST node, but can be more when AST nodes are desugared, such as for post-increment.

Specified by:
getNode in interface InvocationInstruction
Specified by:
getNode in interface TACInstruction
Returns:
the node this instruction is for.
See Also:
TACInstruction.getNode()

isAnonClassType

boolean isAnonClassType()
Indicates whether this instruction instantiates an anonymous class.

Returns:
true if this instruction instantiates an anonymous class, false otherwise.

resolveInstantiatedType

ITypeBinding resolveInstantiatedType()
Resolves the instantiated type, which will usually be a class. This works even for anonymous inner classes: the resolved type will be the anonymous class type, not the implicitly extended base type.

Returns:
the instantiated type.
Since:
Crystal 3.3.8

hasOuterObjectSpecifier

boolean hasOuterObjectSpecifier()
Indicates whether there is an outer object specifier that is permitted by the Java language syntax. If this method returns true then getOuterObjectSpecifierOperand() will return a non-null variable. This method returns true even if the outer object is implicit in the original Java source. It turns out that local and anonymous inner classes cannot legally have an explicit outer object specifier, even though they capture the surrounding receiver, and so this method returns false for those classes.

Returns:
true if there is an outer object specifier, false otherwise.

getOuterObjectSpecifierOperand

Variable getOuterObjectSpecifierOperand()
Returns the outer object specifier, if any. A non-null specifier is returned even if it is implicit in the original Java program (but see hasOuterObjectSpecifier() for discussion of local and anonymous inner classes).

Returns:
the outer object specifier, or null if there is none.
See Also:
hasOuterObjectSpecifier()