/*
TM - Tape Machine
- This file has the template parameter: `CVT`
-
- `CVT` Cell Value Type`. It is the type of the datum placed in a cell. By default (when the macro CVT has no definition) the cell value type is taken as AUM. This file must
- be included with CVT undefined ,before inclusions with it defined.
-
- 'Tape' is operated on by the Tape Machine.
-
- 'Area' is subset of an address space that is used as a virtual Tape by a machine.
-
- An Area with zero elements has 'length == 0' or is 'empty'. In contrast ,and
- area located (position specified) with a null pointer is said not to exist.
-
- ----
-
- CVT is a template variable that affects type names that show on the interface.
- They affect all implementations in the same way.
-
- There are multiple implementations, such as Array. Each has its own FG
- table instance. For example Array路fg. Also each has its own Tableau type, for
- example, `typedef struct { ... } 螢(TM路Array ,CVT)` is the Tableau type for
- the array implementation.
-
- This implementation uses pointer pairs to stand for 'TM type' that are
- passed around.
+ `TM路CVT` Cell Value Type`.
*/
-#define TM路DEBUG
-#ifdef TM路DEBUG
- #include <stdio.h>
-#endif
-
-#define TM路ALL ( defined(CVT) ) // ... && defined( ...
-#define TM路NONE ( !defined(CVT) )
-#if !( TM路ALL || TM路NONE )
- #error "TM template inconsistency: must define all or none of: CVT"
-#endif
-
#ifndef FACE
#define TM路IMPLEMENTATION
#define FACE
#endif
//--------------------------------------------------------------------------------
-// Interface - always included
-
-#if TM路ALL
- #define TM路ALL_VAL = CVT
- #define TM_t 螢(TM ,TM路ALL_VAL)
-#endif
+// Interface
-#ifndef 螢(TM ,FACE)
-#define 螢(TM ,FACE)
+// once per translation unit
+#ifndef TM路TYPE_LIST
+#define TM路TYPE_LIST
-
#include <stdint.h>
#include <stddef.h>
+ #include "cpp_ext.c"
#include "Core.lib.c"
#include "FG.lib.c"
- //----------------------------------------
- // Tape Machine interface
- //----------------------------------------
+ #define TM路DEBUG
+ #ifdef TM路DEBUG
+ #include <stdio.h>
+ #endif
- #if TM路NONE
- typedef enum{
- TM路Tape路Topo路mu = 0
- ,TM路Tape路Topo路empty = 1
- ,TM路Tape路Topo路singleton = 1 << 1
- ,TM路Tape路Topo路segment = 1 << 2
- ,TM路Tape路Topo路circle = 1 << 3
- ,TM路Tape路Topo路tail_cyclic = 1 << 4
- ,TM路Tape路Topo路infinite = 1 << 5
- }TM路Tape路Topo;
-
- const TM路Tape路Topo TM路Tape路Topo路bounded =
- TM路Tape路Topo路singleton
- | TM路Tape路Topo路segment
- ;
-
- // If tape machine does not support step left ,then Status路leftmost
- // will be reported as Status路interim.
- typedef enum{
- TM路Head路Status路mu = 0
- ,TM路Head路Status路dismounted = 1
- ,TM路Head路Status路out_of_area = 1 << 1
- ,TM路Head路Status路leftmost = 1 << 2
- ,TM路Head路Status路interim = 1 << 3
- ,TM路Head路Status路rightmost = 1 << 4
- } TM路Head路Status;
-
- const TM路Head路Status TM路Head路Status路on_tape =
- TM路Head路Status路leftmost
- | TM路Head路Status路interim
- | TM路Head路Status路rightmost
- ;
-
- #endif // #ifndef CVT
-
- #if TM路All
-
- // TM路<CVT>路Tableau
- typedef struct 螢(TM ,Tableau);
-
- // create an FG路Binding so that FG路call will work
- #define FG路Type TM
- #include "FG.lib.c"
- #undef FG路Type
-
- // extent is an index, hence its effect is a function of CVT
- typedef 螢(extent_t ,CVT) size_t;
-
- typedef struct{
-
- TM路Tape路Topo (*Tape路topo)(TM tm);
- bool (*Tape路bounded)(TM tm);
-
- TM路Head路Status (*Head路status)(TM tm);
- bool (*Head路on_tape)(TM tm);
- bool (*Head路on_leftmost) (TM tm);
- bool (*Head路on_rightmost)(TM tm);
-
- // tape machine functions
- Core路Status (*mount) (TM tm);
- Core路Status (*dismount)(TM tm);
-
- void (*step) (TM tm);
- void (*step_left) (TM tm);
- void (*rewind) (TM tm);
-
- TM路FG TM路fg; // points to TM路FG instance
- 螢(extent_t ,CVT) (*extent)(TM tm);
- CVT (*read) (TM tm);
- void (*write)(TM tm ,CVT *remote_pt);
-
- } 螢(TM ,FG);
+ typedef enum{
+ TM路Tape路Topo路mu = 0
+ ,TM路Tape路Topo路empty = 1
+ ,TM路Tape路Topo路singleton = 1 << 1
+ ,TM路Tape路Topo路segment = 1 << 2
+ ,TM路Tape路Topo路circle = 1 << 3
+ ,TM路Tape路Topo路tail_cyclic = 1 << 4
+ ,TM路Tape路Topo路infinite = 1 << 5
+ }TM路Tape路Topo;
+ const TM路Tape路Topo TM路Tape路Topo路bounded =
+ TM路Tape路Topo路singleton
+ | TM路Tape路Topo路segment
+ ;
+
+ typedef enum{
+ TM路Head路Status路mu = 0
+ ,TM路Head路Status路dismounted = 1
+ ,TM路Head路Status路out_of_area = 1 << 1
+ ,TM路Head路Status路leftmost = 1 << 2
+ ,TM路Head路Status路interim = 1 << 3
+ ,TM路Head路Status路rightmost = 1 << 4
+ } TM路Head路Status;
+
+ const TM路Head路Status TM路Head路Status路on_tape =
+ TM路Head路Status路leftmost
+ | TM路Head路Status路interim
+ | TM路Head路Status路rightmost
+ ;
+
+ // set type equality pattern
+ #define EQ__TM__oo__TM
- //----------------------------------------
- // Array interface
- //----------------------------------------
+#endif
+
+// once per TM路CVT value
+#if ! FIND_ITEM( TM路CVT ,TM路TYPE_LIST )
+#define TM路TYPE_LIST APPEND(TM路TYPE_LIST ,TM路TYPE)
+
+ // TM路<TM路CVT>路Tableau
+ typedef struct 螢(TM ,Tableau);
+
+ // bind the tableau to an FG table, call the binding a 'TM' type
+ #define FG路Type TM
+ #include "FG.lib.c"
+
+ // extent is an index, hence its effect is a function of TM路CVT
+ typedef 螢(extent_t ,TM路CVT) size_t;
+
+ typedef struct{
+
+ TM路Tape路Topo (*Tape路topo)(TM tm);
+ bool (*Tape路bounded)(TM tm);
- typedef struct 螢(TM ,Array)路Tableau;
-
- TM 螢(TM ,Array)路init_pe(
- 螢(TM ,Array)路Tableau *t
- ,CVT position[]
- ,螢(extent_t ,CVT) extent
- );
+ TM路Head路Status (*Head路status)(TM tm);
+ bool (*Head路on_tape)(TM tm);
+ bool (*Head路on_leftmost) (TM tm);
+ bool (*Head路on_rightmost)(TM tm);
- TM 螢(TM ,Array)路init_pp(
- 螢(TM ,Array)路Tableau *t
- ,CVT *position_left
- ,CVT *position_right
- );
+ // tape machine functions
+ Core路Status (*mount) (TM tm);
+ Core路Status (*dismount)(TM tm);
- #endif // #ifdef CVT
+ void (*step) (TM tm);
+ void (*step_left) (TM tm);
+ void (*rewind) (TM tm);
-#endif // FACE
+ TM路FG TM路fg; // points to TM路FG instance
+ 螢(extent_t ,TM路CVT) (*extent)(TM tm);
+ TM路CVT (*read) (TM tm);
+ void (*write)(TM tm ,TM路CVT *remote_pt);
+
+ } 螢(TM ,FG);
+
+ //----------------------------------------
+ // Array interface
+ //----------------------------------------
+
+ typedef struct 螢(TM ,Array)路Tableau;
+
+ TM 螢(TM ,Array)路init_pe(
+ 螢(TM ,Array)路Tableau *t
+ ,TM路CVT position[]
+ ,螢(extent_t ,TM路CVT) extent
+ );
+
+ TM 螢(TM ,Array)路init_pp(
+ 螢(TM ,Array)路Tableau *t
+ ,TM路CVT *position_left
+ ,TM路CVT *position_right
+ );
+
+#endif
//--------------------------------------------------------------------------------
// Implementation
// Dispatch wrapper
//----------------------------------------
- #ifndef CVT
+ #ifndef TM路CVT
//-----------------------------------
// common error messages
};
- #endif // ifndef CVT
+ #endif // ifndef TM路CVT
//-----------------------------------
- // CVT dependent functions
+ // TM路CVT dependent functions
- #ifdef CVT
+ #ifdef TM路CVT
- Local 螢(extent_t ,CVT) 螢(TM ,CVT)路extent(TM *tm){
+ Local 螢(extent_t ,TM路CVT) 螢(TM ,TM路CVT)路extent(TM *tm){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
Core路Guard路fg.check(&chk ,1 ,TM路Tape路bounded(tm) ,"Tape is not bounded.");
return tm->fg.extent(tm);
}
- Local CVT TM路read(TM *tm){
+ Local TM路CVT TM路read(TM *tm){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
Core路Guard路fg.check( &chk ,1 ,TM路head_on_tape(tm) ,TM路Msg路head);
return tm->fg.read(tm);
}
- Local void TM路write(TM *tm ,CVT *write_pt){
+ Local void TM路write(TM *tm ,TM路CVT *write_pt){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
Core路Guard路fg.check( &chk ,1 ,TM路head_on_tape(tm) ,TM路Msg路head);
return tm->fg.write(tm ,write_pt);
}
- Local 螢(TM ,CVT)路FG 螢(TM ,CVT)路fg = {
+ Local 螢(TM ,TM路CVT)路FG 螢(TM ,TM路CVT)路fg = {
.parent = TM路fg
- ,.extent = 螢(TM ,CVT)路extent
- ,.read = 螢(TM ,CVT)路read
- ,.write = 螢(TM ,CVT)路write
+ ,.extent = 螢(TM ,TM路CVT)路extent
+ ,.read = 螢(TM ,TM路CVT)路read
+ ,.write = 螢(TM ,TM路CVT)路write
};
- #endif // ifdef CVT
+ #endif // ifdef TM路CVT
//----------------------------------------
// TM路Array implementation
//----------------------------------------
- #ifndef CVT
+ #ifndef TM路CVT
//-----------------------------------
// common error messages
const char *TM路Array路Msg路status="bad head status";
- #endif // #ifndef CVT
+ #endif // #ifndef TM路CVT
- #ifdef CVT
+ #ifdef TM路CVT
- typedef struct 螢(TM ,CVT)路Tableau;
+ typedef struct 螢(TM ,TM路CVT)路Tableau;
typedef struct{
- CVT *hd;
- CVT *position;
- 螢(extent_t ,CVT) extent;
- }螢(TM路Array ,CVT)路Tableau;
+ TM路CVT *hd;
+ TM路CVT *position;
+ 螢(extent_t ,TM路CVT) extent;
+ }螢(TM路Array ,TM路CVT)路Tableau;
//-----------------------------------
// TM路Array.tape implementation
//----------------------------------------
- // TM Array implementation, not CVT differentiated
+ // TM Array implementation, not TM路CVT differentiated
- Local TM路Tape路Topo TM路Array路Tape路topo( 螢(TM ,CVT)路Tableau *tableau ){
- 螢(TM路Array ,CVT)路Tableau *t = (螢(TM路Array ,CVT)路Tableau *)tableau;
+ Local TM路Tape路Topo TM路Array路Tape路topo( 螢(TM ,TM路CVT)路Tableau *tableau ){
+ 螢(TM路Array ,TM路CVT)路Tableau *t = (螢(TM路Array ,TM路CVT)路Tableau *)tableau;
if(!t || !t->position) return T路Tape路Topo路mu;
if(t->extent == 0) TM路Tape路Topo路singleton;
return TM路Tape路Topo路segment;
}
// For an Array Tape Machine ,a bound tape will be singleton or segment.
- TM路Tape路Topo 螢(TM路Array ,CVT)路Tape路topo(螢(TM路Array ,CVT) *tm){
+ TM路Tape路Topo 螢(TM路Array ,TM路CVT)路Tape路topo(螢(TM路Array ,TM路CVT) *tm){
if(!tm || !tm->position) return TM路Tape路Topo路mu;
if(tm->extent == 0) TM路Tape路Topo路singleton;
return TM路Tape路Topo路segment;
}
// check the Tape路topo to make sure tape has extent before calling this
- // `extent路CVT` returns the index to the rightmost cell in the array.
- Local 螢(extent_t ,CVT) 螢(TM路Array ,CVT)路extent(螢(TM路Array ,CVT) *tm){
+ // `extent路TM路CVT` returns the index to the rightmost cell in the array.
+ Local 螢(extent_t ,TM路CVT) 螢(TM路Array ,TM路CVT)路extent(螢(TM路Array ,TM路CVT) *tm){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
Core路Tape路Topo Tape路topo = Core路Tape路Topo路mu;
- Core路Status status = 螢(TM路Array ,CVT)路Tape路topo(tm ,&Tape路topo);
+ Core路Status status = 螢(TM路Array ,TM路CVT)路Tape路topo(tm ,&Tape路topo);
bool good_Tape路topo =
(status == Core路Status路on_track) && (Tape路topo & Core路Tape路Topo路finite_nz)
;
//-----------------------------------
// TM路Array.area implementation
- Local Core路Status 螢(TM路Array ,CVT)路mount_pe(
- 螢(TM路Array ,CVT) *tm ,CVT *position ,螢(extent_t ,CVT) extent
+ Local Core路Status 螢(TM路Array ,TM路CVT)路mount_pe(
+ 螢(TM路Array ,TM路CVT) *tm ,TM路CVT *position ,螢(extent_t ,TM路CVT) extent
){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
return Core路Status路on_track;
}
- // If size of CVT is not a power of two this can perform a divide
- Local Core路Status 螢(TM路Array ,CVT)路mount_pp(
- 螢(TM路Array ,CVT) *tm ,CVT *pos_leftmost ,CVT *pos_rightmost
+ // If size of TM路CVT is not a power of two this can perform a divide
+ Local Core路Status 螢(TM路Array ,TM路CVT)路mount_pp(
+ 螢(TM路Array ,TM路CVT) *tm ,TM路CVT *pos_leftmost ,TM路CVT *pos_rightmost
){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
Core路Guard路if_return(chk);
#endif
- 螢(extent_t ,CVT) extent = pos_rightmost - pos_leftmost);
- return 螢(TM路Array ,CVT)路mount_pe(tm ,pos_leftmost ,extent);
+ 螢(extent_t ,TM路CVT) extent = pos_rightmost - pos_leftmost);
+ return 螢(TM路Array ,TM路CVT)路mount_pe(tm ,pos_leftmost ,extent);
}
//-----------------------------------
// base Tape Machine operations
- Local Core路Status 螢(TM路Array ,CVT)路mount(螢(TM路Array ,CVT) *tm){
+ Local Core路Status 螢(TM路Array ,TM路CVT)路mount(螢(TM路Array ,TM路CVT) *tm){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
Core路Guard路fg.check(&chk ,1 ,tm ,TM路Array路Msg路tm);
return Core路Status路on_track;
}
- Local Core路Status 螢(TM路Array ,CVT)路dismount(螢(TM路Array ,CVT) *tm){
+ Local Core路Status 螢(TM路Array ,TM路CVT)路dismount(螢(TM路Array ,TM路CVT) *tm){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
Core路Guard路fg.check(&chk ,1 ,tm ,TM路Array路Msg路tm);
return Core路Status路on_track;
}
- Local TM路Head路Status 螢(TM路Array ,CVT)路head_status(TM *tm){
+ Local TM路Head路Status 螢(TM路Array ,TM路CVT)路head_status(TM *tm){
if(!tm || !tm->position) return TM路Head路Status路mu;
if(!tm->hd) return TM路Head路Status路dismounted;
if(tm->hd == tm->position) return TM路Head路Status路leftmost;
- CVT *rightmost_pt = tm->position + tm->extent;
+ TM路CVT *rightmost_pt = tm->position + tm->extent;
if(tm->hd == rightmost_pt) TM路Head路Status路rightmost;
if(tm->hd < tm->position || tm->hd > rightmost_pt)
return TM路Head路Status路out_of_area;
return TM路Head路Status路interim;
}
- bool 螢(TM路Array ,CVT)路can_read(螢(TM路Array ,CVT) *tm){
+ bool 螢(TM路Array ,TM路CVT)路can_read(螢(TM路Array ,TM路CVT) *tm){
return tm && tm->position && tm->hd;
}
// can_read was true
- bool 螢(TM路Array ,CVT)路on_origin(螢(TM路Array ,CVT) *tm){
+ bool 螢(TM路Array ,TM路CVT)路on_origin(螢(TM路Array ,TM路CVT) *tm){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
bool flag = true ,s;
- s = 螢(TM路Array ,CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
+ s = 螢(TM路Array ,TM路CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
Core路Guard路fg.check(&chk ,1 ,s && flag ,"head off format");
Core路Guard路assert(chk);
#endif
}
// can_read was true
- bool 螢(TM路Array ,CVT)路on_rightmost(螢(TM路Array ,CVT) *tm){
+ bool 螢(TM路Array ,TM路CVT)路on_rightmost(螢(TM路Array ,TM路CVT) *tm){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
bool flag = true ,s;
- s = 螢(TM路Array ,CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
+ s = 螢(TM路Array ,TM路CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
Core路Guard路fg.check(&chk ,1 ,s && flag ,"head off format");
Core路Guard路assert(chk);
#endif
return tm->hd == tm->position;
}
- void 螢(TM路Array ,CVT)路step(螢(TM路Array ,CVT) *tm){
+ void 螢(TM路Array ,TM路CVT)路step(螢(TM路Array ,TM路CVT) *tm){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
bool flag = true ,s;
- s = 螢(TM路Array ,CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
+ s = 螢(TM路Array ,TM路CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
Core路Guard路fg.check(&chk ,1 ,s && flag ,"head off format");
Core路Guard路assert(chk);
#endif
tm->hd++;
}
- void 螢(TM路Array ,CVT)路step_left(螢(TM路Array ,CVT) *tm){
+ void 螢(TM路Array ,TM路CVT)路step_left(螢(TM路Array ,TM路CVT) *tm){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
bool flag = true ,s;
- s = 螢(TM路Array ,CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
+ s = 螢(TM路Array ,TM路CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
Core路Guard路fg.check(&chk ,1 ,s && flag ,"head off format");
Core路Guard路assert(chk);
#endif
tm->hd--;
}
- void 螢(TM路Array ,CVT)路rewind(螢(TM路Array ,CVT) *tm){
+ void 螢(TM路Array ,TM路CVT)路rewind(螢(TM路Array ,TM路CVT) *tm){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
bool flag = true ,s;
- s = 螢(TM路Array ,CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
+ s = 螢(TM路Array ,TM路CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
Core路Guard路fg.check(&chk ,1 ,s && flag ,"head off format");
Core路Guard路assert(chk);
#endif
}
// tm_can_read must be true for both machines.
- void 螢(TM路Array ,CVT)路copy_datum(螢(TM路Array ,CVT) *tm_read ,螢(TM路Array ,CVT) *tm_write){
+ void 螢(TM路Array ,TM路CVT)路copy_datum(螢(TM路Array ,TM路CVT) *tm_read ,螢(TM路Array ,TM路CVT) *tm_write){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
bool flag = true ,s;
- s = 螢(TM路Array ,CVT)路head_on_format(tm_read ,flag) == Control路Status路on_track;
+ s = 螢(TM路Array ,TM路CVT)路head_on_format(tm_read ,flag) == Control路Status路on_track;
Core路Guard路fg.check(&chk ,1 ,s && flag ,"tm_read head off track");
- s = 螢(TM路Array ,CVT)路head_on_format(tm_write ,flag) == Control路Status路on_track;
+ s = 螢(TM路Array ,TM路CVT)路head_on_format(tm_write ,flag) == Control路Status路on_track;
Core路Guard路fg.check(&chk ,1 ,s && flag ,"tm_write head off track");
Core路Guard路assert(chk);
#endif
return Core路Status路on_track;
}
- void 螢(TM路Array ,CVT)路read(螢(TM路Array ,CVT) *tm ,CVT *read_pt){
+ void 螢(TM路Array ,TM路CVT)路read(螢(TM路Array ,TM路CVT) *tm ,TM路CVT *read_pt){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
bool flag = true ,s;
- s = 螢(TM路Array ,CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
+ s = 螢(TM路Array ,TM路CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
Core路Guard路fg.check(&chk ,1 ,s && flag ,"head off format");
Core路Guard路assert(chk);
#endif
//----------------------------------------
- // Initialization for 螢(TM路Array ,CVT)路fg
+ // Initialization for 螢(TM路Array ,TM路CVT)路fg
- Local 螢(TM路Array ,CVT)路FG 螢(TM路Array ,CVT)路fg = {
+ Local 螢(TM路Array ,TM路CVT)路FG 螢(TM路Array ,TM路CVT)路fg = {
.tape = {
- .Tape路topo = 螢(TM路Array ,CVT)路Tape路topo
- .extent = 螢(TM路Array ,CVT)路extent
+ .Tape路topo = 螢(TM路Array ,TM路CVT)路Tape路topo
+ .extent = 螢(TM路Array ,TM路CVT)路extent
}
,.area = {
- .mount_pe = 螢(TM路Array ,CVT)路mount_pe
- ,.mount_pp = 螢(TM路Array ,CVT)路mount_pp
+ .mount_pe = 螢(TM路Array ,TM路CVT)路mount_pe
+ ,.mount_pp = 螢(TM路Array ,TM路CVT)路mount_pp
}
- ,.mount = 螢(TM路Array ,CVT)路mount
- ,.dismount = 螢(TM路Array ,CVT)路dismount
+ ,.mount = 螢(TM路Array ,TM路CVT)路mount
+ ,.dismount = 螢(TM路Array ,TM路CVT)路dismount
- ,.status = 螢(TM路Array ,CVT)路status
- ,.head_on_format = 螢(TM路Array ,CVT)路head_on_format
+ ,.status = 螢(TM路Array ,TM路CVT)路status
+ ,.head_on_format = 螢(TM路Array ,TM路CVT)路head_on_format
- ,.can_read = 螢(TM路Array ,CVT)路can_read
- ,.on_origin = 螢(TM路Array ,CVT)路on_origin
- ,.on_rightmost = 螢(TM路Array ,CVT)路on_rightmost
+ ,.can_read = 螢(TM路Array ,TM路CVT)路can_read
+ ,.on_origin = 螢(TM路Array ,TM路CVT)路on_origin
+ ,.on_rightmost = 螢(TM路Array ,TM路CVT)路on_rightmost
- ,.step = 螢(TM路Array ,CVT)路step
- ,.step_left = 螢(TM路Array ,CVT)路step_left
- ,.step_right = 螢(TM路Array ,CVT)路step_right // Synonym for step
- ,.rewind = 螢(TM路Array ,CVT)路rewind
+ ,.step = 螢(TM路Array ,TM路CVT)路step
+ ,.step_left = 螢(TM路Array ,TM路CVT)路step_left
+ ,.step_right = 螢(TM路Array ,TM路CVT)路step_right // Synonym for step
+ ,.rewind = 螢(TM路Array ,TM路CVT)路rewind
- ,.copy_datum = 螢(TM路Array ,CVT)路copy_datum
- ,.read = 螢(TM路Array ,CVT)路read
- ,.write = 螢(TM路Array ,CVT)路write
+ ,.copy_datum = 螢(TM路Array ,TM路CVT)路copy_datum
+ ,.read = 螢(TM路Array ,TM路CVT)路read
+ ,.write = 螢(TM路Array ,TM路CVT)路write
};
- #endif // ifdef CVT
+ #endif // ifdef TM路CVT
#endif // LOCAL
#endif // IMPLEMENTATION
-void 螢(TM路Array ,CVT)路write(螢(TM路Array ,CVT) *tm ,CVT *write_pt){
+void 螢(TM路Array ,TM路CVT)路write(螢(TM路Array ,TM路CVT) *tm ,TM路CVT *write_pt){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
bool flag = true ,s;
- s = 螢(TM路Array ,CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
+ s = 螢(TM路Array ,TM路CVT)路head_on_format(tm ,flag) == Core路Status路on_track;
Core路Guard路fg.check(&chk ,1 ,s && flag ,"head off format");
Core路Guard路assert(chk);
#endif
// TM struct initializers
Local Core路Status TM路mount_pe(
- TM *tm ,CVT *position ,螢(extent_t ,CVT) extent
+ TM *tm ,TM路CVT *position ,螢(extent_t ,TM路CVT) extent
){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
return Core路Status路on_track;
}
- // If size of CVT is not a power of two this can perform a divide
+ // If size of TM路CVT is not a power of two this can perform a divide
Local Core路Status TM路mount_pp(
- TM *tm ,CVT *pos_leftmost ,CVT *pos_rightmost
+ TM *tm ,TM路CVT *pos_leftmost ,TM路CVT *pos_rightmost
){
#ifdef TM路DEBUG
Core路Guard路init_count(chk);
Core路Guard路if_return(chk);
#endif
- 螢(extent_t ,CVT) extent = pos_rightmost - pos_leftmost);
+ 螢(extent_t ,TM路CVT) extent = pos_rightmost - pos_leftmost);
return TM路mount_pe(tm ,pos_leftmost ,extent);
}
#ifndef CPP_EXT
#define CPP_EXT
+
#include "cpp_ext_0.c"
#include "cpp_ext_1.c"
+
+ /*
+ Types must be registered with predicates.
+
+ // all legal FG路Type are registered here
+ #define EQ__int__oo__int
+ #define EQ__float__oo__float
+ #define EQ__char__oo__char
+ #define EQ__void__oo__void
+
+ */
+
+ #define FIRST_SEEN(type ,list) \
+ NOT(FIND_ITEM(type ,list)) )
+
+ // CAT(SEP, ...) will soon be added to cpp_ext_1, then this will be:
+ // #define 螢(...) CAT(路 ,__VA_ARGS__)
+
+ // Individual macros for specific argument counts
+ #define _螢0()
+ #define 螢0() _螢0()
+
+ #define _螢1(a) a
+ #define 螢1(a) _螢1(a)
+
+ #define _螢2(a ,b) a##路##b
+ #define 螢2(a ,b) _螢2(a ,b)
+
+ #define _螢3(a ,b ,c) a##路##b##路##c
+ #define 螢3(a ,b ,c) _螢3(a ,b ,c)
+
+ #define _螢4(a ,b ,c ,d) a##路##b##路##c##路##d
+ #define 螢4(a ,b ,c ,d) _螢4(a ,b ,c ,d)
+
+ #define _螢5(a ,b ,c ,d ,e) a##路##b##路##c##路##d##路##e
+ #define 螢5(a ,b ,c ,d ,e) _螢5(a ,b ,c ,d ,e)
+
+ #define _螢6(a ,b ,c ,d ,e ,f) a##路##b##路##c##路##d##路##e##路##f
+ #define 螢6(a ,b ,c ,d ,e ,f) _螢6(a ,b ,c ,d ,e ,f)
+
+ #define _螢7(a ,b ,c ,d ,e ,f ,g) a##路##b##路##c##路##d##路##e##路##f##路##g
+ #define 螢7(a ,b ,c ,d ,e ,f ,g) _螢7(a ,b ,c ,d ,e ,f ,g)
+
+ #define _螢8(a ,b ,c ,d ,e ,f ,g ,h) a##路##b##路##c##路##d##路##e##路##f##路##g##路##h
+ #define 螢8(a ,b ,c ,d ,e ,f ,g ,h) _螢8(a ,b ,c ,d ,e ,f ,g ,h)
+
+ #define _螢9(a ,b ,c ,d ,e ,f ,g ,h ,i) a##路##b##路##c##路##d##路##e##路##f##路##g##路##h##路##i
+ #define 螢9(a ,b ,c ,d ,e ,f ,g ,h ,i) _螢9(a ,b ,c ,d ,e ,f ,g ,h ,i)
+
+ #define _螢10(a ,b ,c ,d ,e ,f ,g ,h ,i ,j) a##路##b##路##c##路##d##路##e##路##f##路##g##路##h##路##i##路##j
+ #define 螢10(a ,b ,c ,d ,e ,f ,g ,h ,i ,j) _螢10(a ,b ,c ,d ,e ,f ,g ,h ,i ,j)
+
+ // Argument counting mechanism
+ #define _ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
+ #define COUNT_ARGS(...) _ARG_N(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
+
+ // Macro name concatenation
+ #define _CONCAT(a, b) a##b
+ #define CONCAT(a, b) _CONCAT(a, b)
+
+ // Selector that chooses the right macro based on argument count
+ #define 螢_EXPAND(count, ...) CONCAT(螢, count)(__VA_ARGS__)
+ #define 螢(...) 螢_EXPAND(COUNT_ARGS(__VA_ARGS__), __VA_ARGS__)
+
+
#endif
+++ /dev/null
-/* Xi (螢) macro implementation with variable argument support
- *
- * This file provides macros from 螢0 through 螢10 along with a selector
- * that automatically chooses the right macro based on argument count.
- *
- * Usage:
- * 螢(a) -> a
- * 螢(a ,b) -> a路b
- * 螢(a ,b ,c) -> a路b路c
- * ...
- * 螢(a ,b ,c ,d ,e ,f) -> a路b路c路d路e路f
- *
- * For Map with two template parameters:
- * 螢(Map ,CVT_read ,CVT_write) -> Map路CVT_read路CVT_write
- */
-
-#ifndef XI_C
-#define XI_C
-
-// Individual macros for specific argument counts
-#define _螢0()
-#define 螢0() _螢0()
-
-#define _螢1(a) a
-#define 螢1(a) _螢1(a)
-
-#define _螢2(a ,b) a##路##b
-#define 螢2(a ,b) _螢2(a ,b)
-
-#define _螢3(a ,b ,c) a##路##b##路##c
-#define 螢3(a ,b ,c) _螢3(a ,b ,c)
-
-#define _螢4(a ,b ,c ,d) a##路##b##路##c##路##d
-#define 螢4(a ,b ,c ,d) _螢4(a ,b ,c ,d)
-
-#define _螢5(a ,b ,c ,d ,e) a##路##b##路##c##路##d##路##e
-#define 螢5(a ,b ,c ,d ,e) _螢5(a ,b ,c ,d ,e)
-
-#define _螢6(a ,b ,c ,d ,e ,f) a##路##b##路##c##路##d##路##e##路##f
-#define 螢6(a ,b ,c ,d ,e ,f) _螢6(a ,b ,c ,d ,e ,f)
-
-#define _螢7(a ,b ,c ,d ,e ,f ,g) a##路##b##路##c##路##d##路##e##路##f##路##g
-#define 螢7(a ,b ,c ,d ,e ,f ,g) _螢7(a ,b ,c ,d ,e ,f ,g)
-
-#define _螢8(a ,b ,c ,d ,e ,f ,g ,h) a##路##b##路##c##路##d##路##e##路##f##路##g##路##h
-#define 螢8(a ,b ,c ,d ,e ,f ,g ,h) _螢8(a ,b ,c ,d ,e ,f ,g ,h)
-
-#define _螢9(a ,b ,c ,d ,e ,f ,g ,h ,i) a##路##b##路##c##路##d##路##e##路##f##路##g##路##h##路##i
-#define 螢9(a ,b ,c ,d ,e ,f ,g ,h ,i) _螢9(a ,b ,c ,d ,e ,f ,g ,h ,i)
-
-#define _螢10(a ,b ,c ,d ,e ,f ,g ,h ,i ,j) a##路##b##路##c##路##d##路##e##路##f##路##g##路##h##路##i##路##j
-#define 螢10(a ,b ,c ,d ,e ,f ,g ,h ,i ,j) _螢10(a ,b ,c ,d ,e ,f ,g ,h ,i ,j)
-
-// Argument counting mechanism
-#define _ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
-#define COUNT_ARGS(...) _ARG_N(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
-
-// Macro name concatenation
-#define _CONCAT(a, b) a##b
-#define CONCAT(a, b) _CONCAT(a, b)
-
-// Selector that chooses the right macro based on argument count
-#define 螢_EXPAND(count, ...) CONCAT(螢, count)(__VA_ARGS__)
-#define 螢(...) 螢_EXPAND(COUNT_ARGS(__VA_ARGS__), __VA_ARGS__)
-
-#endif /* XI_C */