/** * A root-block is the root block for any SymbolScope whether program, function, trigger, or internal procedure. */ public boolean isRootBlock() { return symbolScope.getRootBlock() == this; }
/** * A root-block is the root block for any SymbolScope whether program, function, trigger, or internal procedure. */ public boolean isRootBlock() { return symbolScope.getRootBlock() == this; }
/** A method-block is a block for a function/trigger/internal-procedure. */ public boolean isMethodBlock() { return (symbolScope.getRootBlock() == this) && (symbolScope.getParentScope() != null); }
/** The program-block is the outer program block (not internal procedure block) */ public boolean isProgramBlock() { return (symbolScope.getRootBlock() == this) && (symbolScope.getParentScope() == null); }
/** A method-block is a block for a function/trigger/internal-procedure. */ public boolean isMethodBlock() { return (symbolScope.getRootBlock() == this) && (symbolScope.getParentScope() != null); }
/** The program-block is the outer program block (not internal procedure block) */ public boolean isProgramBlock() { return (symbolScope.getRootBlock() == this) && (symbolScope.getParentScope() == null); }
/** * In the case of a function definition that comes some time after a function forward declaration, we want to use the * scope that was created with the forward declaration, because it is the scope that has all of the parameter * definitions. We have to do this because the definition itself may have left out the parameter list - it's not * required - it just uses the parameter list from the declaration. */ private void scopeSwap(TreeParserSymbolScope scope) { currentScope = scope; blockEnd(); // pop the unused block from the stack currentBlock = pushBlock(scope.getRootBlock()); }
/** Can a buffer reference be scoped to this block? */ private boolean canScopeBufferReference(TableBuffer symbol) { // REPEAT, FOR, and Program_root blocks can scope a buffer. switch (blockStatementNode.getType()) { case ProParserTokenTypes.REPEAT: case ProParserTokenTypes.FOR: case ProParserTokenTypes.Program_root: return true; } // If this is the root block for the buffer's symbol, then the scope // cannot be any higher. if (symbol.getScope().getRootBlock() == this) return true; return false; } // canScopeBufferReference
/** * In the case of a function definition that comes some time after a function forward declaration, we want to use the * scope that was created with the forward declaration, because it is the scope that has all of the parameter * definitions. We have to do this because the definition itself may have left out the parameter list - it's not * required - it just uses the parameter list from the declaration. */ private void scopeSwap(TreeParserSymbolScope scope) { currentScope = scope; blockEnd(); // pop the unused block from the stack currentBlock = pushBlock(scope.getRootBlock()); }
/** * For constructing a root (method root or program root) block. * * @param symbolScope * @param node Is the Program_root if this is the program root block. */ public Block(TreeParserSymbolScope symbolScope, JPNode node) { this.blockStatementNode = node; this.symbolScope = symbolScope; if (symbolScope.getParentScope() != null) this.parent = symbolScope.getParentScope().getRootBlock(); else this.parent = null; // is program-block }
/** * For constructing a root (method root or program root) block. * * @param symbolScope * @param node Is the Program_root if this is the program root block. */ public Block(TreeParserSymbolScope symbolScope, JPNode node) { this.blockStatementNode = node; this.symbolScope = symbolScope; if (symbolScope.getParentScope() != null) this.parent = symbolScope.getParentScope().getRootBlock(); else this.parent = null; // is program-block }
/** Can a buffer reference be scoped to this block? */ private boolean canScopeBufferReference(TableBuffer symbol) { // REPEAT, FOR, and Program_root blocks can scope a buffer. switch (blockStatementNode.getType()) { case ProParserTokenTypes.REPEAT: case ProParserTokenTypes.FOR: case ProParserTokenTypes.Program_root: return true; } // If this is the root block for the buffer's symbol, then the scope // cannot be any higher. if (symbol.getScope().getRootBlock() == this) return true; return false; } // canScopeBufferReference
/** * 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. */ public void addBufferScopeReferences(BufferScope bufferScope) { // References do not get added to DO blocks. if (blockStatementNode.getNodeType() != ABLNodeType.DO) bufferScopes.add(bufferScope); if (parent != null && bufferScope.getSymbol().getScope().getRootBlock() != this) { parent.addBufferScopeReferences(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. */ public void addBufferScopeReferences(BufferScope bufferScope) { // References do not get added to DO blocks. if (blockStatementNode.getNodeType() != ABLNodeType.DO) bufferScopes.add(bufferScope); if (parent != null && bufferScope.getSymbol().getScope().getRootBlock() != this) { parent.addBufferScopeReferences(bufferScope); } }
/** Find nearest BufferScope for a BufferSymbol, if any */ private BufferScope findBufferScope(TableBuffer symbol) { for (BufferScope buff : bufferScopes) { if (buff.getSymbol() != symbol) continue; if (buff.getBlock() == this) return buff; } if (parent != null && symbol.getScope().getRootBlock() != this) return parent.findBufferScope(symbol); return null; }
/** Find nearest BufferScope for a BufferSymbol, if any */ private BufferScope findBufferScope(TableBuffer symbol) { for (BufferScope buff : bufferScopes) { if (buff.getSymbol() != symbol) continue; if (buff.getBlock() == this) return buff; } if (parent != null && symbol.getScope().getRootBlock() != this) return parent.findBufferScope(symbol); return null; }
@Override public void funcDef(JPNode funcAST, JPNode idAST) { LOG.trace("Entering funcDef {} {}", funcAST, idAST); /* * If this function definition had a function forward declaration, then we use the block and scope from that * declaration, in case it is where the parameters were defined. (You can define the params in the FORWARD, and * leave them out at the body.) * * However, if this statement re-defines the formal args, then we use this statement's scope - because the formal * arg names from here will be in effect rather than the names from the FORWARD. (The names don't have to match.) */ if (!currentRoutine.getParameters().isEmpty()) return; TreeParserSymbolScope forwardScope = funcForwards.get(idAST.getText()); if (forwardScope != null) { Routine routine = (Routine) forwardScope.getRootBlock().getNode().getSymbol(); scopeSwap(forwardScope); BlockNode blocknode = (BlockNode) funcAST; blocknode.setBlock(currentBlock); blocknode.setSymbol(routine); routine.setDefOrIdNode(blocknode); currentRoutine = routine; } }
@Override public void funcDef(JPNode funcAST, JPNode idAST) { LOG.trace("Entering funcDef {} {}", funcAST, idAST); /* * If this function definition had a function forward declaration, then we use the block and scope from that * declaration, in case it is where the parameters were defined. (You can define the params in the FORWARD, and * leave them out at the body.) * * However, if this statement re-defines the formal args, then we use this statement's scope - because the formal * arg names from here will be in effect rather than the names from the FORWARD. (The names don't have to match.) */ if (!currentRoutine.getParameters().isEmpty()) return; TreeParserSymbolScope forwardScope = funcForwards.get(idAST.getText()); if (forwardScope != null) { Routine routine = (Routine) forwardScope.getRootBlock().getNode().getSymbol(); scopeSwap(forwardScope); BlockNode blocknode = (BlockNode) funcAST; blocknode.setBlock(currentBlock); blocknode.setSymbol(routine); routine.setDefOrIdNode(blocknode); currentRoutine = routine; } }
private BufferScope getBufferScopeSub(TableBuffer symbol, BufferScope.Strength creating) { if (parent != null && symbol.getScope().getRootBlock() != this) { BufferScope buff = parent.getBufferScopeSub(symbol, creating); if (buff != null)
private BufferScope getBufferScopeSub(TableBuffer symbol, BufferScope.Strength creating) { if (parent != null && symbol.getScope().getRootBlock() != this) { BufferScope buff = parent.getBufferScopeSub(symbol, creating); if (buff != null)