NAME
Jako::Construct::Block - Abstract superclass for Jako Blocks.
SYNOPSIS
TODO
DESCRIPTION
A subclass of Jako::Construct.
Maintains a symbol table, a referenct to its parent block, and a list of content Constructs.
CLASS->new(BLOCK, KIND, TYPE, PREFIX)
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?
BLOCK->set_symbol(NAME, VALUE)
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().
BLOCK->get_symbol(NAME)
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().
BLOCK->symbol_names()
Returns the names of the symbols defined locally in this block.
BLOCK->dump_symbols()
FOR DEBUGGING ONLY.
Dumps the complete list of symbols visible from this block, including those from the symbol tables of parent blocks.
BLOCK->find_symbol(NAME)
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.
BLOCK->find_block(KIND [, LABEL])
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.
BLOCK->type_of_ident(NAME)
This is a shortcut method that uses find_symbol() to locate a matching symbol, and then returns that symbol's type.
BLOCK->kind_of_ident(NAME)
This is a shortcut method that uses find_symbol() to locate a matching symbol, and then returns that symbol's kind.
BLOCK->scope_of_ident(NAME)
This is a shortcut method that uses find_symbol() to locate a matching symbol, and then returns that symbol's scope (global or local).
BLOCK->access_of_ident(NAME)
This is a shortcut method that uses find_symbol() to locate a matching symbol, and then returns that symbol's access (const or not).
BLOCK->content()
Return the content list for the Block.
BLOCK->push_content(LIST)
Append Constructs to the Block's content list.
BLOCK->compile(COMPILER, FILTER)
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.
VERSION
$Id$
AUTHOR
Gregor N. Purdy <gregor@focusresearch.com>
COPYRIGHT
Copyright (C) 2002-2005, Parrot Foundation.
LICENSE
THIS PROGRAM IS FREE SOFTWARE. ITS USE IS SUBJECT TO THE SAME LICENSE AS THE PARROT VIRTUAL MACHINE.