harpoon.Backend.Runtime1
Class ObjectBuilder

java.lang.Object
  extended by harpoon.Backend.Generic.Runtime.ObjectBuilder
      extended by harpoon.Backend.Runtime1.ObjectBuilder
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
ObjectBuilder

public class ObjectBuilder
extends Runtime.ObjectBuilder

ObjectBuilder is an implementation of harpoon.Backend.Generic.Runtime.ObjectBuilder for the Runtime1 runtime.

To accomodate transformations which add fields to java.lang.Object, this Runtime.ObjectBuilder initializes all fields of Object with null, rather than attempting to consult the given Info for them. If other behavior is eventually needed, it is a custom RootOracle be defined and provided to the constructor which will be consulted on the value of every field *before* any Info. This provides for extensibility without direct code modifications to the various parts of Runtime1 which use this ObjectBuilder.

Version:
$Id: ObjectBuilder.java,v 1.10 2004/07/02 01:05:01 cananian Exp $
Author:
C. Scott Ananian <cananian@alumni.princeton.edu>
See Also:
Serialized Form

Nested Class Summary
static class ObjectBuilder.RootOracle
          A RootOracle allows a transformation to add fields to java.lang.Object (or any other class, really) and provide the initial values for that field in the various runtime constant objects without having to directly extend every ObjectInfo used in this Generic.Runtime implementation.
 
Nested classes/interfaces inherited from class harpoon.Backend.Generic.Runtime.ObjectBuilder
Runtime.ObjectBuilder.ArrayInfo, Runtime.ObjectBuilder.Info, Runtime.ObjectBuilder.ObjectInfo
 
Field Summary
protected  HClass HCobject
           
protected  boolean pointersAreLong
           
protected  Random rnd
           
protected  ObjectBuilder.RootOracle ro
           
protected  Runtime runtime
           
 
Constructor Summary
ObjectBuilder(Runtime runtime)
          Creates a ObjectBuilder with a RootOracle which supplies null values to any field of java.lang.Object (which there usually aren't any of).
ObjectBuilder(Runtime runtime, ObjectBuilder.RootOracle ro)
          Creates a ObjectBuilder.
 
Method Summary
 Stm buildArray(TreeFactory tf, Runtime.ObjectBuilder.ArrayInfo info, boolean exported)
          Build an array.
 Stm buildObject(TreeFactory tf, Runtime.ObjectBuilder.ObjectInfo info, boolean exported)
          Build an object.
protected  int headerFinalOffset(Runtime.ObjectBuilder.Info info)
           
protected  Stm makeFields(TreeFactory tf, Runtime.ObjectBuilder.Info info, List<HField> fields, int startOffset, int endOffset)
           
protected  Stm makeHeader(TreeFactory tf, Runtime.ObjectBuilder.Info info, boolean exported)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

runtime

protected final Runtime runtime

pointersAreLong

protected final boolean pointersAreLong

ro

protected final ObjectBuilder.RootOracle ro

rnd

protected final Random rnd

HCobject

protected final HClass HCobject
Constructor Detail

ObjectBuilder

public ObjectBuilder(Runtime runtime)
Creates a ObjectBuilder with a RootOracle which supplies null values to any field of java.lang.Object (which there usually aren't any of).


ObjectBuilder

public ObjectBuilder(Runtime runtime,
                     ObjectBuilder.RootOracle ro)
Creates a ObjectBuilder.

Method Detail

buildObject

public Stm buildObject(TreeFactory tf,
                       Runtime.ObjectBuilder.ObjectInfo info,
                       boolean exported)
Description copied from class: Runtime.ObjectBuilder
Build an object.

Specified by:
buildObject in class Runtime.ObjectBuilder
info - Information about the type and contents of the object to build.
exported - true if this object's label is to be exported outside its module.

buildArray

public Stm buildArray(TreeFactory tf,
                      Runtime.ObjectBuilder.ArrayInfo info,
                      boolean exported)
Description copied from class: Runtime.ObjectBuilder
Build an array.

Specified by:
buildArray in class Runtime.ObjectBuilder
info - Information about the type, length and contents of the array to build.
exported - true if this object's label is to be exported outside its module.

makeHeader

protected Stm makeHeader(TreeFactory tf,
                         Runtime.ObjectBuilder.Info info,
                         boolean exported)

headerFinalOffset

protected int headerFinalOffset(Runtime.ObjectBuilder.Info info)

makeFields

protected Stm makeFields(TreeFactory tf,
                         Runtime.ObjectBuilder.Info info,
                         List<HField> fields,
                         int startOffset,
                         int endOffset)