Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

Block_scope Class Reference

#include <block.h>

Inheritance diagram for Block_scope:

Inheritance graph
[legend]
Collaboration diagram for Block_scope:

Collaboration graph
[legend]
List of all members.

Public Methods

 Block_scope (Function_signature *fsig)
 Block that implements a function. More...

 Block_scope (Block_scope *parent, bool use_parent)
 Sub-block inside another block. More...

 ~Block_scope ()
Variable_symboladd_variable (Storage_class_specifier storage, Type type, Ptree *name, Ptree *init, Ptree *bitsize)
 Add a variable. More...

Function_signatureadd_function_decl (Storage_class_specifier storage, Function_specifier_set fspec, Type type, const Symbol_name &sym_name)
 Declare a function. More...

void add_function_implementation (Function_signature *fsig, Block_scope *scope, Ptree *defn, Ptree *initializer)
 Add function implementation. More...

void add_symbol (std::string name, Symbol *sym)
 Add another symbol (nested type, ...). More...

std::string get_unique_name (std::string name)
 Get unique naming prefix. More...

Type get_this_type () const
 Get type of "*this". More...

Function_signatureget_function () const
void set_this_type (Type t)
Symbol_pair lookup_here (std::string name, bool for_decl)
 Look up a symbol in this scope. More...


Private Attributes

bool use_parent
 if set, symbols declared in the parent are treated identical to those declared here. More...

std::string fun_prefix
std::string block_prefix
Abstract_scopenonblock
Type this_type
Function_signaturefsig

Constructor & Destructor Documentation

Block_scope::Block_scope Function_signature   fsig
 

Block that implements a function.

Parameters:
fsig  the function

Definition at line 12 of file block.cc.

Block_scope::Block_scope Block_scope *    parent,
bool    use_parent
 

Sub-block inside another block.

Parameters:
parent  parent block
use_parent  true iff this "inherits" our parent's variables. This is needed to implement combined scopes like "if (int i = ...) { ... }".

Definition at line 30 of file block.cc.

Block_scope::~Block_scope  
 

Definition at line 42 of file block.cc.


Member Function Documentation

Function_signature * Block_scope::add_function_decl Storage_class_specifier    storage,
Function_specifier_set    fspec,
Type    type,
const Symbol_name   sym_name
[virtual]
 

Declare a function.

Returns the declared signature.

Implements Abstract_scope.

Definition at line 91 of file block.cc.

References compile_error(), Function_specifier_set, and Storage_class_specifier.

void Block_scope::add_function_implementation Function_signature   fsig,
Block_scope *    scope,
Ptree   defn,
Ptree   initializer
[virtual]
 

Add function implementation.

Implements Abstract_scope.

Definition at line 101 of file block.cc.

References compile_error().

void Block_scope::add_symbol std::string    name,
Symbol   sym
[virtual]
 

Add another symbol (nested type, ...).

Implements Abstract_scope.

Definition at line 112 of file block.cc.

References Symbol_table::add_symbol(), Symbol_table::get_instance(), and get_unique_name().

Referenced by add_variable().

Variable_symbol * Block_scope::add_variable Storage_class_specifier    storage,
Type    type,
Ptree   name,
Ptree   init,
Ptree   bitsize
[virtual]
 

Add a variable.

Returns variable symbol if this is a definition of a variable which must appear in output.

Implements Abstract_scope.

Definition at line 48 of file block.cc.

References Function_signature::add_parameter(), add_symbol(), compile_error(), fsig, Symbol_name::get_name(), Type::get_unqualified_type(), Symbol_name::is_qualified(), Symbol_name::is_template(), s_Auto, s_Extern, s_None, s_Parameter, s_Register, s_Static, Symbol::st_Defined, and Storage_class_specifier.

Referenced by Simple_declaration_reader::declare_variable().

Function_signature * Block_scope::get_function   const [inline]
 

Definition at line 76 of file block.h.

References fsig.

Referenced by Annotator::visit_return().

Type Block_scope::get_this_type   const [virtual]
 

Get type of "*this".

Implements Abstract_scope.

Definition at line 137 of file block.cc.

References this_type.

std::string Block_scope::get_unique_name std::string    name [virtual]
 

Get unique naming prefix.

I hope to never need this function

Implements Abstract_scope.

Definition at line 129 of file block.cc.

References block_prefix, and Symbol_name::get_mangled_symbol_name().

Referenced by add_symbol(), and lookup_here().

Symbol_pair Block_scope::lookup_here std::string    name,
bool    for_decl
[virtual]
 

Look up a symbol in this scope.

Parameters:
for_decl=true  this is a declaration, don't scan bases or using

Implements Abstract_scope.

Definition at line 153 of file block.cc.

References Symbol_table::get_instance(), Abstract_scope::get_parent(), Symbol_table::get_symbol(), get_unique_name(), and Abstract_scope::lookup_here().

void Block_scope::set_this_type Type    t
 

Definition at line 145 of file block.cc.

References this_type.

Referenced by process_function_body().


Member Data Documentation

std::string Block_scope::block_prefix [private]
 

Definition at line 31 of file block.h.

Referenced by get_unique_name().

Function_signature* Block_scope::fsig [private]
 

Definition at line 34 of file block.h.

Referenced by add_variable(), and get_function().

std::string Block_scope::fun_prefix [private]
 

Definition at line 31 of file block.h.

Abstract_scope* Block_scope::nonblock [private]
 

Definition at line 32 of file block.h.

Type Block_scope::this_type [private]
 

Definition at line 33 of file block.h.

Referenced by get_this_type(), and set_this_type().

bool Block_scope::use_parent [private]
 

if set, symbols declared in the parent are treated identical to those declared here.

Definition at line 30 of file block.h.


The documentation for this class was generated from the following files:
Generated on Mon Feb 10 17:35:19 2003 for VFiasco Semantics Compiler by doxygen1.2.15