parrotcode: Abstract superclass for Jako Blocks. | |
Contents | Language Implementations | Jako |
Jako::Construct::Block - Abstract superclass for Jako Blocks.
TODO
A subclass of Jako::Construct.
Maintains a symbol table, a referenct to its parent block, and a list of content Constructs.
If BLOCK is defined, it is the new Block's parent.
The KIND tells what kind of block we are dealing with (sub, while, bare, etc.).
The TYPE tells the return type of the block.
The PREFIX tells the prefix that will be used for block-related labels. For example, while loops have labels related to the loop control statements, and these are kept distinct by applying the prefix to the labels. Of course, the prefix could come explicitly from the source code if the loop was labeled.
TODO: Do we really need KIND, since we have subclasses?
Set a symbol in this block's symbol table. If the symbol already exists, we throw an error.
TODO: We should generate real compiler errors and warnings instead of using confess() and warn().
Attempt to get a symbol from this block's symbol table only. If there is no locally defined symbol with that name, then we return undef.
See also: find_symbol(), which will also search (recursively) parent blocks' symbol tables.
TODO: We should generate real compiler errors and warnings instead of using die() and warn().
Returns the names of the symbols defined locally in this block.
FOR DEBUGGING ONLY.
Dumps the complete list of symbols visible from this block, including those from the symbol tables of parent blocks.
Search for a symbol, starting with this block, but also checking parent blocks recursively until a matching symbol is found or the root block is encountered without a match (in which case we return undef).
See also: get_symbol(), which searches only locally.
Search this block and recursively through parent Blocks for a Block with the specified kind (such as a while loop) and label (if given).
This is used to find the target blocks for loop control statements.
This is a shortcut method that uses find_symbol() to locate a matching symbol, and then returns that symbol's type.
This is a shortcut method that uses find_symbol() to locate a matching symbol, and then returns that symbol's access (const or not).
Return the content list for the Block.
Append Constructs to the Block's content list.
Compile the block's content using COMPILER. If FILTER is provided, only those Constructs in the content for which FILTER returns a true value will be compiled.
The FILTER feature is used to arrange for two passes over the root block. The first pass compiles all subroutine declarations and definitions, while the second pass compiles any other content. This is how we collect all the non-sub stuff into the main sub at the end of the script's compiled code.
$Id$
Gregor N. Purdy <gregor@focusresearch.com>
Copyright (C) 2002-2003 Gregor N. Purdy. All rights reserved.
THIS PROGRAM IS FREE SOFTWARE. ITS USE IS SUBJECT TO THE SAME LICENSE AS THE PARROT VIRTUAL MACHINE.
|