SH::ShProgramNode Class Reference

A particular Sh program. More...

#include <ShProgramNode.hpp>

Inheritance diagram for SH::ShProgramNode:

Inheritance graph
[legend]
Collaboration diagram for SH::ShProgramNode:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::set< ShVariableNodePtrVarSet
typedef std::list< ShVariableNodePtrVarList
typedef std::list< ShTextureNodePtrTexList
typedef std::list< ShChannelNodePtrChannelList
typedef std::list< ShPaletteNodePtrPaletteList

Public Member Functions

 ShProgramNode (const std::string &target)
 ~ShProgramNode ()
void compile (const ShPointer< ShBackend > &backend)
 Forcefully compile this program for a particular backend, even if it has been compiled previously.
void compile (const std::string &target, const ShPointer< ShBackend > &backend)
 Forcefully compile this program for a particular backend, even if it has been compiled previously.
bool is_compiled () const
 Check whether the program has been compiled for the default backend.
bool is_compiled (const std::string &target) const
 Check whether the program has been compiled for the default backend and the given target.
bool is_compiled (const std::string &target, const ShPointer< ShBackend > &backend) const
 Check whether the program has been compiled for the given backend and the given target.
std::string describe_interface () const
 Describe the inputs and outputs of this program.
std::string describe_vars () const
 Describes all the variables in this program.
std::string describe_decls () const
 Describes all the temps declared in this program.
std::string describe_bindings ()
 Describe the binding of the inputs under the current backend.
std::string describe_bindings (const std::string &target)
 Describe the binding of the inputs for the given target.
void dump (std::string filename) const
 Describes all of the above to the file filename.vars and dumps a DOT version of the cfg to filename.ps.
ShPointer< ShBackendCodecode ()
 Obtain the code for currently active backend.
ShPointer< ShBackendCodecode (const ShPointer< ShBackend > &backend)
 Obtain the code for a particular backend.
ShPointer< ShBackendCodecode (const std::string &target, const ShPointer< ShBackend > &backend)
 Obtain the code for a particular backend.
void updateUniform (const ShVariableNodePtr &uniform)
 Notify this program that a uniform variable has changed.
void collectDecls ()
 Called right before optimization to collect temporary declarations.
void collectVariables ()
 Called right after optimization to make lists of all the variables used in the program.
bool hasDecl (const ShVariableNodePtr &node) const
 Returns whether a temporary variable is declared in this program.
VarList::const_iterator begin_inputs () const
VarList::const_iterator end_inputs () const
VarList::const_iterator begin_outputs () const
VarList::const_iterator end_outputs () const
VarList::const_iterator begin_temps () const
VarList::const_iterator end_temps () const
VarList::const_iterator begin_constants () const
VarList::const_iterator end_constants () const
VarList::const_iterator begin_parameters () const
VarList::const_iterator end_parameters () const
VarList::const_iterator begin_all_parameters () const
VarList::const_iterator end_all_parameters () const
TexList::const_iterator begin_textures () const
TexList::const_iterator end_textures () const
ChannelList::const_iterator begin_channels () const
ChannelList::const_iterator end_channels () const
PaletteList::const_iterator begin_palettes () const
PaletteList::const_iterator end_palettes () const
std::string backend_name () const
 Return the name of the backend for which the program is currently compiled.
std::string target () const
 Can be empty, if there is no target associated with this program.
std::string & target ()
 It may be useful to change a program's target sometimes.
ShPointer< ShProgramNodeclone () const
 Make a copy of this program.
bool finished () const
 True if this program has been completed with SH_END.
void finish ()
void assign (const ShVariableNodePtr &var) const
void addDecl (const ShVariableNodePtr &node, const ShCtrlGraphNodePtr &)
 Add a declaration.
void addDecl (const ShVariableNodePtr &node)

Static Public Member Functions

static std::ostream & print (std::ostream &out, const VarList &list)
 Print a description of a list of variables.

Public Attributes

ShTokenizer tokenizer
 The tokenizer for this program's body.
ShPointer< ShCtrlGraphctrlGraph
 The control graph (the parsed form of the token list).
VarList inputs
 Input variables used in this program.
VarList outputs
 Output variables used in this program.
VarList temps
 Temporary variables used in this program.
VarSet tempDecls
 Temporary variables declared in this program.
VarList constants
 Constants used in this program.
VarList uniforms
 Uniform variables used in the optimized program.
VarList all_uniforms
 All uniform variables including recursively dependent ones.
TexList textures
 Textures used in this program.
ChannelList channels
 Channels used in FETCH instructions in this program.
PaletteList palettes
 Palettes used in PAL instructions in this program.

Detailed Description

A particular Sh program.

Definition at line 44 of file ShProgramNode.hpp.


Member Function Documentation

void SH::ShProgramNode::addDecl const ShVariableNodePtr node,
const ShCtrlGraphNodePtr
 

Add a declaration.

This is for use when a program is transformed and new temporaries are added.

The first version adds to a specified cfg node in addition to this. The second adds to this and the entry node.

Todo:
range check that adding to the cfg node doesn't screw anything up... (i.e. if somewhere we don't copy cfg when manipulating program...)

Definition at line 296 of file ShProgramNode.cpp.

References ctrlGraph, and tempDecls.

Referenced by addDecl().

std::string SH::ShProgramNode::backend_name  )  const [inline]
 

Return the name of the backend for which the program is currently compiled.

Returns an empty string if the program is not yet compiled.

Definition at line 171 of file ShProgramNode.hpp.

ShPointer< ShBackendCode > SH::ShProgramNode::code const std::string &  target,
const ShPointer< ShBackend > &  backend
 

Obtain the code for a particular backend.

Generates it if necessary.

Definition at line 150 of file ShProgramNode.cpp.

References compile().

ShPointer< ShBackendCode > SH::ShProgramNode::code const ShPointer< ShBackend > &  backend  ) 
 

Obtain the code for a particular backend.

Generates it if necessary. This operation will fail if this program does not have a particular target.

Definition at line 143 of file ShProgramNode.cpp.

References code(), and SH::shError().

ShPointer< ShBackendCode > SH::ShProgramNode::code  ) 
 

Obtain the code for currently active backend.

This operation will fail if this program does not have a particular target.

Definition at line 138 of file ShProgramNode.cpp.

References SH::ShBackend::get_backend().

Referenced by code(), and describe_bindings().

void SH::ShProgramNode::compile const std::string &  target,
const ShPointer< ShBackend > &  backend
 

Forcefully compile this program for a particular backend, even if it has been compiled previously.

Use code() to obtain the actual code.

Definition at line 84 of file ShProgramNode.cpp.

References ctrlGraph, and SH::shError().

void SH::ShProgramNode::compile const ShPointer< ShBackend > &  backend  ) 
 

Forcefully compile this program for a particular backend, even if it has been compiled previously.

Use code() to obtain the actual code. This operation will fail if this program does not have a particular target.

Definition at line 78 of file ShProgramNode.cpp.

References SH::shError().

Referenced by code().

bool SH::ShProgramNode::is_compiled  )  const
 

Check whether the program has been compiled for the default backend.

This operation will fail if this program does not have particular target.

Definition at line 109 of file ShProgramNode.cpp.

References SH::ShBackend::get_backend(), and SH::shError().

Referenced by is_compiled().


Member Data Documentation

ShPointer<ShCtrlGraph> SH::ShProgramNode::ctrlGraph
 

The control graph (the parsed form of the token list).

Constructed during the parsing step, when shEndProgram() is called.

Definition at line 108 of file ShProgramNode.hpp.

Referenced by addDecl(), clone(), collectDecls(), collectVariables(), compile(), dump(), and shgl::PBufferStreamCache::PBufferStreamCache().

ShTokenizer SH::ShProgramNode::tokenizer
 

The tokenizer for this program's body.

Used only during construction of the program (before parsing)

Definition at line 103 of file ShProgramNode.hpp.


The documentation for this class was generated from the following files:
Generated on Thu Feb 16 14:56:42 2006 for Sh by  doxygen 1.4.6