exe
Class GAIGSMemoryManager

java.lang.Object
  extended by exe.GAIGSbase
      extended by exe.GAIGSMemoryManager
All Implemented Interfaces:
GAIGSdatastr

public class GAIGSMemoryManager
extends GAIGSbase

GAIGSMemoryManager provides the ability to implement a linked list and alsocreate GAIGS visualizations of its state. Use the various constructorsto specify the general parameters for the list visualization, and use the toXML method to actually generate the array XML for snapshots.

Many, but not all, of the methods specified by the List interface areprovided by this class.

Methods are also provided to set and get the presentation color of a list cell.A default list cell color can be set by using the appropriate constructor.

Version:
6/27/07
Author:
David Furcy

Field Summary
static exe.GAIGSMemoryManager.Index NULL
           
 
Fields inherited from interface exe.GAIGSdatastr
DEFAULT_COLOR, DEFAULT_FONT_SIZE, DEFAULT_NAME, DEFAULT_X1, DEFAULT_X2, DEFAULT_Y1, DEFAULT_Y2
 
Constructor Summary
GAIGSMemoryManager(int numRows, int numCols, int startRow, int startCol, double horizSpacing, ShowFile show, java.lang.String pseudofile)
          Class constructor specifying values for all the parameters of the memory manager.
GAIGSMemoryManager(ShowFile show, java.lang.String pseudofile)
          Class constructor
 
Method Summary
 void allocateAndSet(java.lang.String p, java.lang.String info, java.lang.String next)
          Implements the following intruction: p = new( info, next), where pointer p was previously declared.
 exe.GAIGSMemoryManager.Index allocateNode(java.lang.String info, java.lang.String pointer, int length, int drow, int dcol)
           
 void assign(exe.GAIGSMemoryManager.Index address, exe.GAIGSMemoryManager.Index value, int start, int end)
          Assignment operator between pointer variables/expressions
 boolean compare(exe.memorymanager.DataExpression exp1, exe.memorymanager.DataExpression exp2, java.lang.String comparator, int lineNumber, int start, int end)
          Comparison of DataExpressions
 boolean compare(exe.memorymanager.PointerExpression exp1, exe.memorymanager.PointerExpression exp2, java.lang.String comparator, int lineNumber, int start, int end)
           
 void createLinkedList(java.lang.String head, java.lang.String[] elements, java.lang.String tail)
           
 void dataAssign(exe.memorymanager.PointerExpression LHS, exe.memorymanager.PointerExpression RHS, int lineNumber)
           
 void dataAssign(exe.memorymanager.PointerExpression LHS, java.lang.String RHS, int lineNumber)
           
 void declare(java.lang.String p, int row, int col, java.lang.String ref)
          Implements the following intruction: Node *p; together with a full specification of the pointer variable's address.
 void declare(java.lang.String p, java.lang.String position, int drow, int dcol, java.lang.String dref)
          Implements the following intruction: Node *p; together with a full specification of requested the pointer variable's address
 void declareAllocateAndAssign(java.lang.String p, java.lang.String info, exe.memorymanager.PointerExpression next, int row, int col, java.lang.String ref)
          Implements the following intruction: Node *p = new( info, next).
 void declareAllocateAndAssign(java.lang.String p, java.lang.String info, exe.memorymanager.PointerExpression next, java.lang.String position, int drow, int dcol, java.lang.String dref)
          Implements the following intruction: Node *p = new( info, next).
 void declareAndAssign(java.lang.String p, exe.memorymanager.PointerExpression RHS, int drow, int dcol, java.lang.String dref, java.lang.String position)
           
 void delete(exe.GAIGSMemoryManager.Index address)
          Evaluate the following expreeion: new( info, next)
 void doBold(exe.GAIGSMemoryManager.Index address)
           
 void doNothing(int lineNumber)
           
 boolean eval(exe.memorymanager.BooleanExpression b, int lineNumber)
           
 exe.GAIGSMemoryManager.Index getAddress(exe.memorymanager.PointerExpression p)
           
 exe.GAIGSMemoryManager.Index getAddress(java.lang.String name)
          Returns the address of a pointer, if it is declared; throws a MemoryManagerException, otherwise.
 exe.GAIGSMemoryManager.Box getDataBox(exe.memorymanager.PointerExpression exp)
           
 java.lang.String getInfo(exe.memorymanager.PointerExpression exp)
           
 exe.GAIGSMemoryManager.Index getNext(exe.GAIGSMemoryManager.Index address, int length)
          Follows a chain of next pointers of a given length.
 exe.GAIGSMemoryManager.Index getValue(exe.GAIGSMemoryManager.Index address)
          Returns the value of a pointer variable, if it is declared and initialised; throws a MemoryManagerException, otherwise.
 exe.GAIGSMemoryManager.Index getValue(exe.memorymanager.PointerExpression exp)
           
 exe.GAIGSMemoryManager.Index getValue(java.lang.String name)
          Returns the value of a pointer variable, if it is declared and initialised; throws a MemoryManagerException, otherwise.
 boolean isNull(exe.GAIGSMemoryManager.Index address)
          Returns true if the pointer's value is NULL; false otherwise.
 boolean isNull(java.lang.String name)
          Returns true if ...
 void redrawLinkedList(exe.GAIGSMemoryManager.Index head)
          Straightens out the linked list by redrawing its nodes one after the other in a row (or a column, depending on the current layout manager).
 void setDebugMode(boolean flag)
           
 void setInfo(exe.GAIGSMemoryManager.Index address, java.lang.String info)
          Assigns a value to the info data member of a node.
 void setLineNumber(int n)
           
 java.lang.String toXML()
          Creates and returns GAIGS XML code for the current state of the grid
 void undoBold(exe.GAIGSMemoryManager.Index address)
           
 
Methods inherited from class exe.GAIGSbase
getName, setName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NULL

public static exe.GAIGSMemoryManager.Index NULL
Constructor Detail

GAIGSMemoryManager

public GAIGSMemoryManager(ShowFile show,
                          java.lang.String pseudofile)
Class constructor


GAIGSMemoryManager

public GAIGSMemoryManager(int numRows,
                          int numCols,
                          int startRow,
                          int startCol,
                          double horizSpacing,
                          ShowFile show,
                          java.lang.String pseudofile)
Class constructor specifying values for all the parameters of the memory manager.

Parameters:
name - Display name of this structure.
color - Color for items unless locally overridden.
x1 - Left display bound.
y1 - Bottom display bound.
x2 - Top display bound.
y2 - Right display bound.
fontSize - Font size for display.
Method Detail

setLineNumber

public void setLineNumber(int n)

setDebugMode

public void setDebugMode(boolean flag)

declareAllocateAndAssign

public void declareAllocateAndAssign(java.lang.String p,
                                     java.lang.String info,
                                     exe.memorymanager.PointerExpression next,
                                     int row,
                                     int col,
                                     java.lang.String ref)
                              throws java.io.IOException
Implements the following intruction: Node *p = new( info, next). By default, the label is positioned above the box.

Parameters:
p - Name of the pointer variable being declared.
info - Data to be stored in the new node being allocated.
next - Pointer expression whose value is to be stored in the next field of the node.
Throws:
java.io.IOException

doNothing

public void doNothing(int lineNumber)
               throws java.io.IOException
Throws:
java.io.IOException

declareAllocateAndAssign

public void declareAllocateAndAssign(java.lang.String p,
                                     java.lang.String info,
                                     exe.memorymanager.PointerExpression next,
                                     java.lang.String position,
                                     int drow,
                                     int dcol,
                                     java.lang.String dref)
                              throws java.io.IOException
Implements the following intruction: Node *p = new( info, next). The label is positioned according to the fourth argument.

Parameters:
p - Name of the pointer variable being declared.
info - Data to be stored in the new node being allocated.
next - Pointer expression whose value is to be stored in the next field of the node.
position - Position of the reference label.
Throws:
java.io.IOException

declareAndAssign

public void declareAndAssign(java.lang.String p,
                             exe.memorymanager.PointerExpression RHS,
                             int drow,
                             int dcol,
                             java.lang.String dref,
                             java.lang.String position)
                      throws java.io.IOException
Throws:
java.io.IOException

declare

public void declare(java.lang.String p,
                    int row,
                    int col,
                    java.lang.String ref)
             throws java.io.IOException
Implements the following intruction: Node *p; together with a full specification of the pointer variable's address. The label is positioned by default.

Parameters:
p - Name of the pointer variable being declared.
row - Row of the requested address.
col - Column of the requested address.
ref - Reference location of the requested address.
Throws:
java.io.IOException

declare

public void declare(java.lang.String p,
                    java.lang.String position,
                    int drow,
                    int dcol,
                    java.lang.String dref)
             throws java.io.IOException
Implements the following intruction: Node *p; together with a full specification of requested the pointer variable's address

Parameters:
p - Name of the pointer variable being declared.
position - Position of the reference label.
row - Row of the requested address.
col - Column of the requested address.
ref - Reference location of the requested address.
Throws:
java.io.IOException

allocateAndSet

public void allocateAndSet(java.lang.String p,
                           java.lang.String info,
                           java.lang.String next)
                    throws java.io.IOException
Implements the following intruction: p = new( info, next), where pointer p was previously declared.

Parameters:
p - Name of the pointer variable being assigned.
info - Data to be stored in the new node being allocated.
next - Pointer expression whose value is to be stored in the next field of the node.
Throws:
java.io.IOException

delete

public void delete(exe.GAIGSMemoryManager.Index address)
            throws java.io.IOException
Evaluate the following expreeion: new( info, next)

Parameters:
info - Data to be stored in the new node being allocated.
next - Pointer expression whose value is to be stored in the next field of the node.
Throws:
java.io.IOException

assign

public void assign(exe.GAIGSMemoryManager.Index address,
                   exe.GAIGSMemoryManager.Index value,
                   int start,
                   int end)
            throws java.io.IOException
Assignment operator between pointer variables/expressions

Parameters:
address - The address (index) of the left-hand side.
value - The value (index) of the right-hand side.
Throws:
java.io.IOException

getAddress

public exe.GAIGSMemoryManager.Index getAddress(java.lang.String name)
Returns the address of a pointer, if it is declared; throws a MemoryManagerException, otherwise.

Parameters:
name - The name of a pointer.
Returns:
The address (or index) of the pointer.

getAddress

public exe.GAIGSMemoryManager.Index getAddress(exe.memorymanager.PointerExpression p)

getValue

public exe.GAIGSMemoryManager.Index getValue(java.lang.String name)
Returns the value of a pointer variable, if it is declared and initialised; throws a MemoryManagerException, otherwise.

Parameters:
name - The name of a pointer.
Returns:
The value (i.e., an address) of the pointer.

getValue

public exe.GAIGSMemoryManager.Index getValue(exe.GAIGSMemoryManager.Index address)
Returns the value of a pointer variable, if it is declared and initialised; throws a MemoryManagerException, otherwise.

Parameters:
address - The address (i.e., index) of a pointer.
Returns:
The value (i.e., an address) of the pointer.

getNext

public exe.GAIGSMemoryManager.Index getNext(exe.GAIGSMemoryManager.Index address,
                                            int length)
Follows a chain of next pointers of a given length.

Parameters:
address - Index of the first node in the chain.
length - Number (> 0) of next pointers to dereference.
Returns:
The index of the last pointer in the chain.

allocateNode

public exe.GAIGSMemoryManager.Index allocateNode(java.lang.String info,
                                                 java.lang.String pointer,
                                                 int length,
                                                 int drow,
                                                 int dcol)
                                          throws exe.memorymanager.MemoryManagerException
Throws:
exe.memorymanager.MemoryManagerException

setInfo

public void setInfo(exe.GAIGSMemoryManager.Index address,
                    java.lang.String info)
Assigns a value to the info data member of a node.

Parameters:
address - Index of the node.
info - One-letter String to be assigned.

isNull

public boolean isNull(exe.GAIGSMemoryManager.Index address)
Returns true if the pointer's value is NULL; false otherwise.

Parameters:
address - Address of the pointer.

redrawLinkedList

public void redrawLinkedList(exe.GAIGSMemoryManager.Index head)
                      throws java.io.IOException
Straightens out the linked list by redrawing its nodes one after the other in a row (or a column, depending on the current layout manager). The destination row (or column) is determined by the location of the head reference. Assumes that no node other than those in the list are located in the destination row (or column). No references pointed to any node in the list are moved.

Parameters:
head - The address of the head of the linked list.
Throws:
java.io.IOException

getInfo

public java.lang.String getInfo(exe.memorymanager.PointerExpression exp)

getDataBox

public exe.GAIGSMemoryManager.Box getDataBox(exe.memorymanager.PointerExpression exp)

getValue

public exe.GAIGSMemoryManager.Index getValue(exe.memorymanager.PointerExpression exp)

eval

public boolean eval(exe.memorymanager.BooleanExpression b,
                    int lineNumber)
             throws java.io.IOException
Throws:
java.io.IOException

compare

public boolean compare(exe.memorymanager.PointerExpression exp1,
                       exe.memorymanager.PointerExpression exp2,
                       java.lang.String comparator,
                       int lineNumber,
                       int start,
                       int end)
                throws java.io.IOException
Throws:
java.io.IOException

compare

public boolean compare(exe.memorymanager.DataExpression exp1,
                       exe.memorymanager.DataExpression exp2,
                       java.lang.String comparator,
                       int lineNumber,
                       int start,
                       int end)
                throws java.io.IOException
Comparison of DataExpressions

Throws:
java.io.IOException

dataAssign

public void dataAssign(exe.memorymanager.PointerExpression LHS,
                       java.lang.String RHS,
                       int lineNumber)
                throws java.io.IOException
Throws:
java.io.IOException

dataAssign

public void dataAssign(exe.memorymanager.PointerExpression LHS,
                       exe.memorymanager.PointerExpression RHS,
                       int lineNumber)
                throws java.io.IOException
Throws:
java.io.IOException

isNull

public boolean isNull(java.lang.String name)
Returns true if ...

Parameters:
name - Name of the pointer variable.

doBold

public void doBold(exe.GAIGSMemoryManager.Index address)

undoBold

public void undoBold(exe.GAIGSMemoryManager.Index address)

createLinkedList

public void createLinkedList(java.lang.String head,
                             java.lang.String[] elements,
                             java.lang.String tail)
                      throws java.io.IOException
Throws:
java.io.IOException

toXML

public java.lang.String toXML()
Creates and returns GAIGS XML code for the current state of the grid

Returns:
A String containing GAIGS XML code for the linked list