% "chapters/definition.tex"
%	$Id: definition.tex,v 1.4 2005/05/06 02:51:22 fang Exp $

\chapter{Definitions and Types}
\label{sec:definition}

NOTE: This chapter is very incomplete.  

All definitions types contain two (possibly empty) lists of template
formals: a strict parameter list and a relaxed parameter list.  
The template parameter list format is summarized
in Section~\ref{sec:definition:template}.  

All definitions start with the following data:
\begin{enumerate}
\item string: name
\item pointer: back-reference to parent namespace
\item Template parameters (Section~\ref{sec:definition:template})
\end{enumerate}

The sub-types of definitions extend the fields:

\subsubsection{Data type definitions}
\begin{enumerate}
\item ...
\end{enumerate}

\subsubsection{Channel type definitions}
\begin{enumerate}
\item ...
\end{enumerate}

\subsubsection{Process type definitions}
\begin{enumerate}
\item Sequence of public ports
\item Symbol table: same as described in Section~\ref{sec:namespace:table}
\item Sequential instance management for unrolling (internal connections), 
	as described in Chapter~\ref{sec:sequential}
\end{enumerate}

Definitions contain member layout maps, 
one \emph{per unique tuple} of template arguments.  
Before type-checking is complete, the list of layout maps will be empty.  
After unrolling (before expansion), 
each definition will be populated with layout maps for each 
unique tuple of parameters that it is invoked with.  
(Does NOT exhaustively check all possible values --- impossible.)

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Template Parameters}
\label{sec:definition:template}

Template parameters contain two sequences (lists) of pointers of parameters, 
that may include formal values, 
or formal type parameters (not yet implemented).  
(All formal parameters in these lists are also 
registered with the local symbol table.)  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Process Ports}
\label{sec:definition:ports}

Ports are implemented as a sequence (list) of pointers to 
physical instances (collections) that are publicly accessible to the outside.  
(All referenced instances here are also registered with the symbol table.)  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Typedefs}
\label{sec:definition:typedef}

Typedefs are aliases to defined types.  
Typedefs may also contain template parameters.  
Typedefs' symbol tables should contain only template formal parameters
	and public port parameters, i.e. no additional local symbols.  

\begin{enumerate}
\item string: name
\item pointer: to parent namespace
\item Template parameters
\item pointer: to base type reference (Section~\ref{sec:definition:typeref})
\end{enumerate}

Incidentally, typedefs are sub-typed for processes, channels, data-types.  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Type References}
\label{sec:definition:typeref}

Type references contain:

\begin{enumerate}
\item pointer: to a base definition
\item pair sequence of template arguments that complete the type
	(first pair of strict arguments, second pair for relaxed arguments)
\end{enumerate}

Incidentally, type references are sub-typed for 
processes, channels, data-types.  
There is no different in content except that the base definition's
type is restricted to the respective subtype.  

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\section{Member Layout Maps}
\label{sec:definition:layout}

NOTE: Not yet implemented, in progress.  

Each time a template definition is `used' with fully specified parameters 
(a complete type), it is fully type-checked with those parameter values.  
If the type-check passes, it creates a layout map, whose purpose is
to translate member references into data offsets.  
(Those offsets are used to \emph{address} the 
appropriate (physical) sub-instance.  

A member layout map entry consists of a string (name of member)
and an offset (integer).  

(Subtype layout maps by process, channel, data?
Depends on how physical instances are structured, 
see Chapter~\ref{sec:instance}.)


