org.prorefactor.treeparser
Class Block

java.lang.Object
  extended by org.prorefactor.treeparser.Block
All Implemented Interfaces:
Xferable

public class Block
extends java.lang.Object
implements Xferable

For keeping track of blocks, block attributes, and the things that are scoped within those blocks - especially buffer scopes.


Constructor Summary
Block()
          Only to be used for persistence/serialization.
Block(Block parent, JPNode node)
          For constructing nested blocks
Block(SymbolScope symbolScope, JPNode node)
          For constructing a root (method root or program root) block.
 
Method Summary
 void addBufferScopeReferences(BufferScope bufferScope)
          Add a reference to a BufferScope to this and all outer blocks.
 Block addFrame(Frame frame)
          Called by Frame.setFrameScopeBlock() - not intended to be called by any client code.
 void addHiddenCursor(RecordNameNode node)
          A "hidden cursor" is a BufferScope which has no side-effects on surrounding blocks like strong, weak, and reference scopes do.
 void addStrongBufferScope(RecordNameNode node)
          Create a "strong" buffer scope.
 BufferScope addWeakBufferScope(TableBuffer symbol)
          Create a "weak" buffer scope.
 TableBuffer[] getBlockBuffers()
          Get the buffers that are scoped to this block
 BufferScope getBufferForReference(TableBuffer symbol)
          Find or create a buffer for the input BufferSymbol
 Frame getDefaultFrame()
          From the nearest frame scoping block, get the default (possibly unnamed) frame if it exists.
 java.util.ArrayList<Frame> getFrames()
          Get a copy of the list of frames scoped to this block.
 JPNode getNode()
          Get the node for this block.
 Block getParent()
          This returns the block of the parent scope.
 SymbolScope getSymbolScope()
           
 boolean isBufferLocal(BufferScope buff)
          Is a buffer scoped to this or any parent of this block.
 boolean isMethodBlock()
          A method-block is a block for a function/trigger/internal-procedure.
 boolean isProgramBlock()
          The program-block is the outer program block (not internal procedure block)
 boolean isRootBlock()
          A root-block is the root block for any SymbolScope whether program, function, trigger, or internal procedure.
 FieldLookupResult lookupField(java.lang.String name, boolean getBufferScope)
          General lookup for Field or Variable.
protected  FieldLookupResult lookupUnqualifiedField(java.lang.String name)
          Find a field based on buffers which are referenced in nearest enclosing blocks.
 void setDefaultFrameExplicit(Frame frame)
          Explicitly set the default frame for this block.
 Block setDefaultFrameImplicit(Frame frame)
          In the nearest frame scoping block, set the default implicit (unnamed) frame.
 void setParent(Block parent)
           
 void writeXferBytes(DataXferStream out)
          Implement Xferable.
 void writeXferSchema(DataXferStream out)
          Implement Xferable.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Block

public Block()
Only to be used for persistence/serialization.


Block

public Block(Block parent,
             JPNode node)
For constructing nested blocks


Block

public Block(SymbolScope symbolScope,
             JPNode node)
For constructing a root (method root or program root) block.

Parameters:
symbolScope -
node - Is the Program_root if this is the program root block.
Method Detail

addBufferScopeReferences

public void addBufferScopeReferences(BufferScope bufferScope)
Add a reference to a BufferScope to this and all outer blocks. These references are required for duplicating Progress's scope and "raise scope" behaviours. BufferScope references are not added up past the symbol's scope.


addFrame

public Block addFrame(Frame frame)
Called by Frame.setFrameScopeBlock() - not intended to be called by any client code. This should only be called by the Frame object itself. Adds a frame to this or the appropriate parent block. Returns the scoping block. Frames are scoped to FOR and REPEAT blocks, or else to a symbol scoping block. They may also be scoped with a DO WITH FRAME block, but that is handled elsewhere.


addHiddenCursor

public void addHiddenCursor(RecordNameNode node)
A "hidden cursor" is a BufferScope which has no side-effects on surrounding blocks like strong, weak, and reference scopes do. These are used within a CAN-FIND function. (2004.Sep:John: Maybe in triggers too? Haven't checked.)

Parameters:
node - The RECORD_NAME node. Must have the BufferSymbol linked to it already.

addStrongBufferScope

public void addStrongBufferScope(RecordNameNode node)
Create a "strong" buffer scope. This is called within a DO FOR or REPEAT FOR statement. A STRONG scope prevents the scope from being raised to an enclosing block. Note that the compiler performs additional checks here that we don't.

Parameters:
node - The RECORD_NAME node. It must already have the BufferSymbol linked to it.

addWeakBufferScope

public BufferScope addWeakBufferScope(TableBuffer symbol)
Create a "weak" buffer scope. This is called within a FOR or PRESELECT statement.

Parameters:
node - The RECORD_NAME node. It must already have the BufferSymbol linked to it.

getBlockBuffers

public TableBuffer[] getBlockBuffers()
Get the buffers that are scoped to this block


getBufferForReference

public BufferScope getBufferForReference(TableBuffer symbol)
Find or create a buffer for the input BufferSymbol


getDefaultFrame

public Frame getDefaultFrame()
From the nearest frame scoping block, get the default (possibly unnamed) frame if it exists. Returns null if no default frame has been established yet.


getFrames

public java.util.ArrayList<Frame> getFrames()
Get a copy of the list of frames scoped to this block.


getNode

public JPNode getNode()
Get the node for this block. Returns a node of one of these types: Program_root/DO/FOR/REPEAT/EDITING/PROCEDURE/FUNCTION/ON/TRIGGERS.


getParent

public Block getParent()
This returns the block of the parent scope.


getSymbolScope

public SymbolScope getSymbolScope()

isBufferLocal

public boolean isBufferLocal(BufferScope buff)
Is a buffer scoped to this or any parent of this block.


isMethodBlock

public boolean isMethodBlock()
A method-block is a block for a function/trigger/internal-procedure.


isProgramBlock

public boolean isProgramBlock()
The program-block is the outer program block (not internal procedure block)


isRootBlock

public boolean isRootBlock()
A root-block is the root block for any SymbolScope whether program, function, trigger, or internal procedure.


lookupField

public FieldLookupResult lookupField(java.lang.String name,
                                     boolean getBufferScope)
General lookup for Field or Variable. Does not guarantee uniqueness. That job is left to the compiler.


lookupUnqualifiedField

protected FieldLookupResult lookupUnqualifiedField(java.lang.String name)
Find a field based on buffers which are referenced in nearest enclosing blocks. Note that the compiler enforces uniqueness here. We don't, we just find the first possible and return it.


setDefaultFrameExplicit

public void setDefaultFrameExplicit(Frame frame)
Explicitly set the default frame for this block. This should only be called by the Frame object itself. This is especially important to be called for DO WITH FRAME statements because DO blocks do not normally scope frames. This should also be called for REPEAT WITH FRAME and FOR WITH FRAME blocks.


setDefaultFrameImplicit

public Block setDefaultFrameImplicit(Frame frame)
In the nearest frame scoping block, set the default implicit (unnamed) frame. This should only be called by the Frame object itself. Returns the Block that scopes the frame.


setParent

public void setParent(Block parent)

writeXferBytes

public void writeXferBytes(DataXferStream out)
                    throws java.io.IOException
Implement Xferable.

Specified by:
writeXferBytes in interface Xferable
Throws:
java.io.IOException

writeXferSchema

public void writeXferSchema(DataXferStream out)
                     throws java.io.IOException
Implement Xferable.

Specified by:
writeXferSchema in interface Xferable
Throws:
java.io.IOException


Copyright © 2008 Joanju Software. All Rights Reserved.