harpoon.Main
Class CompilerState

java.lang.Object
  extended by harpoon.Main.CompilerState
All Implemented Interfaces:
Serializable, Cloneable

public class CompilerState
extends Object
implements Cloneable, Serializable

CompilerState is an immutable tuple that encapsulates the date required while compiling a program. Ideally, each stage of the compiler receives a CompilerState, does some transformations and returns a new CompilerState object.

Because this tuple has many fields, and their number is likely to vary, the portable way of generating a new CompilerState is by using one of the "change*" methods. This is also supposed to be very convenient: most of the compiler stages will modify only a small part of the compiler state (most usually, only a new code factory). Also, CompilerState.EMPTY_STATE contains the initial, empty compiler state (initial meaning "at the beginning of the compiler")

Version:
$Id: CompilerState.java,v 1.7 2004/02/08 01:58:13 cananian Exp $
Author:
Alexandru Salcianu <salcianu@MIT.edu>
See Also:
Serialized Form

Field Summary
static CompilerState EMPTY_STATE
           
 
Method Summary
 CompilerState changeAttributes(PersistentMap<String,Object> attribs)
           
 CompilerState changeClassHierarchy(ClassHierarchy classHierarchy)
           
 CompilerState changeCodeFactory(HCodeFactory hcf)
           
 CompilerState changeFrame(Frame frame)
           
 CompilerState changeLinker(Linker linker)
           
 CompilerState changeMain(HMethod main)
           
 CompilerState changeRoots(Set roots)
           
 PersistentMap<String,Object> getAttributes()
           
 ClassHierarchy getClassHierarchy()
           
 HCodeFactory getCodeFactory()
           
 Frame getFrame()
           
 Linker getLinker()
           
 HMethod getMain()
           
 Set getRoots()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_STATE

public static CompilerState EMPTY_STATE
Method Detail

getMain

public HMethod getMain()
Returns:
main method of the compiled program

getRoots

public Set getRoots()
Returns:
set of roots for the compiled program

getLinker

public Linker getLinker()
Returns:
linker that loads the classes of the compiled program

getCodeFactory

public HCodeFactory getCodeFactory()
Returns:
code factory that provides the code of the methods from the compiled program.

getClassHierarchy

public ClassHierarchy getClassHierarchy()
Returns:
class hierarchy for the compiled program;

getFrame

public Frame getFrame()
Returns:
backend specific details for the compiled program

getAttributes

public PersistentMap<String,Object> getAttributes()
Returns:
(persistent) map from attribute names to attribute values

changeMain

public CompilerState changeMain(HMethod main)
Returns:
identical copy of this compiler state, with the exception of the main method, which is now set to main

changeRoots

public CompilerState changeRoots(Set roots)
Returns:
identical copy of this compiler state, with the exception of the set of roots, which is now set to roots

changeLinker

public CompilerState changeLinker(Linker linker)
Returns:
identical copy of this compiler state, with the exception of the linker, which is now set to linker

changeCodeFactory

public CompilerState changeCodeFactory(HCodeFactory hcf)
Returns:
identical copy of this compiler state, with the exception of the code factory, which is now set to hcf

changeClassHierarchy

public CompilerState changeClassHierarchy(ClassHierarchy classHierarchy)
Returns:
identical copy of this compiler state, with the exception of the class hierarchy, which is now set to classHierarchy

changeFrame

public CompilerState changeFrame(Frame frame)
Returns:
identical copy of this compiler state, with the exception of the frame, which is now set to frame

changeAttributes

public CompilerState changeAttributes(PersistentMap<String,Object> attribs)
Returns:
identical copy of this compiler state, with the exception of the attribute map, which is now set to attribs