/** Create the frame if necessary, set its scope if that hasn't already been done. */ private Frame initializeFrame(Frame frame, Block currentBlock) { // If we don't have a frame then get or create the unnamed default frame for the block. if (frame == null) frame = currentBlock.getDefaultFrame(); boolean newFrame = frame == null; if (newFrame) { frame = createFrame("", currentBlock.getSymbolScope()); frame.setFrameScopeUnnamedDefault(currentBlock); } if (!frame.isInitialized()) { frame.initialize(currentBlock); if (!newFrame) { frameMRU.remove(frame); frameMRU.addFirst(frame); } } return frame; }
/** Create the frame if necessary, set its scope if that hasn't already been done. */ private Frame initializeFrame(Frame frame, Block currentBlock) { // If we don't have a frame then get or create the unnamed default frame for the block. if (frame == null) frame = currentBlock.getDefaultFrame(); boolean newFrame = frame == null; if (newFrame) { frame = createFrame("", currentBlock.getSymbolScope()); frame.setFrameScopeUnnamedDefault(currentBlock); } if (!frame.isInitialized()) { frame.initialize(currentBlock); if (!newFrame) { frameMRU.remove(frame); frameMRU.addFirst(frame); } } return frame; }
/** * For an IO/UI statement which would initialize a frame, compute the frame and set the frame attribute on the * statement head node. This is not used from DEFINE FRAME, HIDE FRAME, or any other "frame" statements which would * not count as a "reference" for frame scoping purposes. */ void nodeOfInitializingStatement(JPNode stateNode, Block currentBlock) { JPNode containerTypeNode = getContainerTypeNode(stateNode); JPNode idNode = null; if (containerTypeNode != null) { idNode = containerTypeNode.nextNode(); assert idNode.getType() == ProParserTokenTypes.ID; } if (containerTypeNode != null && containerTypeNode.getType() == ProParserTokenTypes.BROWSE) { containerForCurrentStatement = browseRefSet(idNode, currentBlock.getSymbolScope()); } else { Frame frame = null; if (idNode != null) frame = frameRefSet(idNode, currentBlock.getSymbolScope()); // This returns the frame whether it already exists or it creates it new. frame = initializeFrame(frame, currentBlock); containerForCurrentStatement = frame; } stateNode.setFieldContainer(containerForCurrentStatement); containerForCurrentStatement.addStatement(stateNode); }
/** * For an IO/UI statement which would initialize a frame, compute the frame and set the frame attribute on the * statement head node. This is not used from DEFINE FRAME, HIDE FRAME, or any other "frame" statements which would * not count as a "reference" for frame scoping purposes. */ void nodeOfInitializingStatement(JPNode stateNode, Block currentBlock) { JPNode containerTypeNode = getContainerTypeNode(stateNode); JPNode idNode = null; if (containerTypeNode != null) { idNode = containerTypeNode.nextNode(); assert idNode.getType() == ProParserTokenTypes.ID; } if (containerTypeNode != null && containerTypeNode.getType() == ProParserTokenTypes.BROWSE) { containerForCurrentStatement = browseRefSet(idNode, currentBlock.getSymbolScope()); } else { Frame frame = null; if (idNode != null) frame = frameRefSet(idNode, currentBlock.getSymbolScope()); // This returns the frame whether it already exists or it creates it new. frame = initializeFrame(frame, currentBlock); containerForCurrentStatement = frame; } stateNode.setFieldContainer(containerForCurrentStatement); containerForCurrentStatement.addStatement(stateNode); }
/** FOR|REPEAT|DO blocks need to be checked for explicit WITH FRAME phrase. */ void nodeOfBlock(JPNode blockNode, Block currentBlock) { JPNode containerTypeNode = getContainerTypeNode(blockNode); if (containerTypeNode == null) return; // No such thing as DO WITH BROWSE... assert containerTypeNode.getType() == ProParserTokenTypes.FRAME; JPNode frameIDNode = containerTypeNode.nextNode(); assert frameIDNode.getType() == ProParserTokenTypes.ID; Frame frame = frameRefSet(frameIDNode, currentBlock.getSymbolScope()); frame.setFrameScopeBlockExplicitDefault(((BlockNode) blockNode).getBlock()); blockNode.setFieldContainer(frame); containerForCurrentStatement = frame; }
/** FOR|REPEAT|DO blocks need to be checked for explicit WITH FRAME phrase. */ void nodeOfBlock(JPNode blockNode, Block currentBlock) { JPNode containerTypeNode = getContainerTypeNode(blockNode); if (containerTypeNode == null) return; // No such thing as DO WITH BROWSE... assert containerTypeNode.getType() == ProParserTokenTypes.FRAME; JPNode frameIDNode = containerTypeNode.nextNode(); assert frameIDNode.getType() == ProParserTokenTypes.ID; Frame frame = frameRefSet(frameIDNode, currentBlock.getSymbolScope()); frame.setFrameScopeBlockExplicitDefault(((BlockNode) blockNode).getBlock()); blockNode.setFieldContainer(frame); containerForCurrentStatement = frame; }