Skip to content

Commit

Permalink
kernel: remove incomplete support for !{...} syntax
Browse files Browse the repository at this point in the history
Specifically, `posobj!{indices}` was meant to relate to `list{indices}` the
same way as `posobj![i]` does to `list[i]`. But it was never fully
implemented. Specifically, no printing or execution functions for the
relevant statement and expression types were implemented; and for the
interpreter and compiler, mostly trying to use these lead to an error a long
the line of "sorry, this feature has not been implemented". Due to all this,
trying to use this feature in a coded function could trigger all kinds of
problems, up to crashes.

Since this code serves no clear purpose, we just remote it, instead of trying
to implement the missing bits.

Fixes #2765
  • Loading branch information
fingolfin committed Sep 4, 2018
1 parent 2e992fe commit d17d0f6
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 557 deletions.
122 changes: 12 additions & 110 deletions src/code.c
Original file line number Diff line number Diff line change
Expand Up @@ -2287,9 +2287,7 @@ void CodeIsbGVar (
*F CodeAssListLevel( <level> ) . . . . . . code assignment to several lists
*F CodeAsssListLevel( <level> ) . code multiple assignment to several lists
*/
void CodeAssListUniv (
Stat ass,
Int narg)
static void CodeAssListUniv(Stat ass, Int narg)
{
Expr list; /* list expression */
Expr pos; /* position expression */
Expand Down Expand Up @@ -2404,7 +2402,7 @@ void CodeUnbList ( Int narg )
*F CodeElmListLevel( <level> ) . . . . . . . code selection of several lists
*F CodeElmsListLevel( <level> ) . code multiple selection of several lists
*/
void CodeElmListUniv (
static void CodeElmListUniv (
Expr ref,
Int narg)
{
Expand Down Expand Up @@ -2709,17 +2707,17 @@ void CodeIsbRecExpr ( void )
/****************************************************************************
**
*F CodeAssPosObj() . . . . . . . . . . . . . . . . code assignment to a list
*F CodeAsssPosObj() . . . . . . . . . . code multiple assignment to a list
*F CodeAssPosObjLevel( <level> ) . . . . . code assignment to several lists
*F CodeAsssPosObjLevel( <level> ) code multiple assignment to several lists
*/
void CodeAssPosObjUniv (
Stat ass )
void CodeAssPosObj ( void )
{
Stat ass; /* assignment, result */
Expr list; /* list expression */
Expr pos; /* position expression */
Expr rhsx; /* right hand side expression */

/* allocate the assignment */
ass = NewStat( T_ASS_POSOBJ, 3 * sizeof(Stat) );

/* enter the right hand side expression */
rhsx = PopExpr();
WRITE_STAT(ass, 2, rhsx);
Expand All @@ -2736,54 +2734,6 @@ void CodeAssPosObjUniv (
PushStat( ass );
}

void CodeAssPosObj ( void )
{
Stat ass; /* assignment, result */

/* allocate the assignment */
ass = NewStat( T_ASS_POSOBJ, 3 * sizeof(Stat) );

/* let 'CodeAssPosObjUniv' do the rest */
CodeAssPosObjUniv( ass );
}

void CodeAsssPosObj ( void )
{
Stat ass; /* assignment, result */

/* allocate the assignment */
ass = NewStat( T_ASSS_POSOBJ, 3 * sizeof(Stat) );

/* let 'CodeAssPosObjUniv' do the rest */
CodeAssPosObjUniv( ass );
}

void CodeAssPosObjLevel (
UInt level )
{
Stat ass; /* assignment, result */

/* allocate the assignment and enter the level */
ass = NewStat( T_ASS_POSOBJ_LEV, 4 * sizeof(Stat) );
WRITE_STAT(ass, 3, level);

/* let 'CodeAssPosObjUniv' do the rest */
CodeAssPosObjUniv( ass );
}

void CodeAsssPosObjLevel (
UInt level )
{
Stat ass; /* assignment, result */

/* allocate the assignment and enter the level */
ass = NewStat( T_ASSS_POSOBJ_LEV, 4 * sizeof(Stat) );
WRITE_STAT(ass, 3, level);

/* let 'CodeAssPosObjUniv' do the rest */
CodeAssPosObjUniv( ass );
}


/****************************************************************************
**
Expand Down Expand Up @@ -2814,16 +2764,16 @@ void CodeUnbPosObj ( void )
/****************************************************************************
**
*F CodeElmPosObj() . . . . . . . . . . . . . . . . code selection of a list
*F CodeElmsPosObj() . . . . . . . . . . . code multiple selection of a list
*F CodeElmPosObjLevel( <level> ) . . . . . . code selection of several lists
*F CodeElmsPosObjLevel( <level> ) code multiple selection of several lists
*/
void CodeElmPosObjUniv (
Expr ref )
void CodeElmPosObj ( void )
{
Expr ref; /* reference, result */
Expr list; /* list expression */
Expr pos; /* position expression */

/* allocate the reference */
ref = NewExpr( T_ELM_POSOBJ, 2 * sizeof(Expr) );

/* enter the position expression */
pos = PopExpr();
WRITE_EXPR(ref, 1, pos);
Expand All @@ -2836,54 +2786,6 @@ void CodeElmPosObjUniv (
PushExpr( ref );
}

void CodeElmPosObj ( void )
{
Expr ref; /* reference, result */

/* allocate the reference */
ref = NewExpr( T_ELM_POSOBJ, 2 * sizeof(Expr) );

/* let 'CodeElmPosObjUniv' to the rest */
CodeElmPosObjUniv( ref );
}

void CodeElmsPosObj ( void )
{
Expr ref; /* reference, result */

/* allocate the reference */
ref = NewExpr( T_ELMS_POSOBJ, 2 * sizeof(Expr) );

/* let 'CodeElmPosObjUniv' to the rest */
CodeElmPosObjUniv( ref );
}

void CodeElmPosObjLevel (
UInt level )
{
Expr ref; /* reference, result */

/* allocate the reference and enter the level */
ref = NewExpr( T_ELM_POSOBJ_LEV, 3 * sizeof(Expr) );
WRITE_EXPR(ref, 2, level);

/* let 'CodeElmPosObjUniv' do the rest */
CodeElmPosObjUniv( ref );
}

void CodeElmsPosObjLevel (
UInt level )
{
Expr ref; /* reference, result */

/* allocate the reference and enter the level */
ref = NewExpr( T_ELMS_POSOBJ_LEV, 3 * sizeof(Expr) );
WRITE_EXPR(ref, 2, level);

/* let 'CodeElmPosObjUniv' do the rest */
CodeElmPosObjUniv( ref );
}


/****************************************************************************
**
Expand Down
28 changes: 0 additions & 28 deletions src/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,6 @@ enum STAT_TNUM {
T_UNB_REC_EXPR,

T_ASS_POSOBJ,
T_ASSS_POSOBJ,
T_ASS_POSOBJ_LEV,
T_ASSS_POSOBJ_LEV,
T_UNB_POSOBJ,

T_ASS_COMOBJ_NAME,
Expand Down Expand Up @@ -424,9 +421,6 @@ enum EXPR_TNUM {
T_ISB_REC_EXPR,

T_ELM_POSOBJ,
T_ELMS_POSOBJ,
T_ELM_POSOBJ_LEV,
T_ELMS_POSOBJ_LEV,
T_ISB_POSOBJ,

T_ELM_COMOBJ_NAME,
Expand Down Expand Up @@ -1254,40 +1248,18 @@ extern void CodeIsbRecExpr ( void );
/****************************************************************************
**
*F CodeAssPosObj() . . . . . . . . . . . . . . . . code assignment to a list
*F CodeAsssPosObj() . . . . . . . . . . code multiple assignment to a list
*F CodeAssPosObjLevel(<level>) . . . . . . code assignment to several lists
*F CodeAsssPosObjLevel(<level>) . code multiple assignment to several lists
*/
extern void CodeAssPosObj ( void );

extern void CodeAsssPosObj ( void );

extern void CodeAssPosObjLevel (
UInt level );

extern void CodeAsssPosObjLevel (
UInt level );

extern void CodeUnbPosObj ( void );


/****************************************************************************
**
*F CodeElmPosObj() . . . . . . . . . . . . . . . . code selection of a list
*F CodeElmsPosObj() . . . . . . . . . . . code multiple selection of a list
*F CodeElmPosObjLevel(<level>) . . . . . . . code selection of several lists
*F CodeElmsPosObjLevel(<level>) . code multiple selection of several lists
*/
extern void CodeElmPosObj ( void );

extern void CodeElmsPosObj ( void );

extern void CodeElmPosObjLevel (
UInt level );

extern void CodeElmsPosObjLevel (
UInt level );

extern void CodeIsbPosObj ( void );


Expand Down
100 changes: 0 additions & 100 deletions src/compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -3432,42 +3432,6 @@ CVar CompElmPosObj (
}


/****************************************************************************
**
*F CompElmsPosObj( <expr> ) . . . . . . . . . . . . . . . . . T_ELMS_POSOBJ
*/
CVar CompElmsPosObj (
Expr expr )
{
Emit( "CANNOT COMPILE EXPRESSION OF TNUM %d;\n", TNUM_EXPR(expr) );
return 0;
}


/****************************************************************************
**
*F CompElmPosObjLev( <expr> ) . . . . . . . . . . . . . . T_ELM_POSOBJ_LEV
*/
CVar CompElmPosObjLev (
Expr expr )
{
Emit( "CANNOT COMPILE EXPRESSION OF TNUM %d;\n", TNUM_EXPR(expr) );
return 0;
}


/****************************************************************************
**
*F CompElmsPosObjLev( <expr> ) . . . . . . . . . . . . . . . . T_ELMS_POSOBJ
*/
CVar CompElmsPosObjLev (
Expr expr )
{
Emit( "CANNOT COMPILE EXPRESSION OF TNUM %d;\n", TNUM_EXPR(expr) );
return 0;
}


/****************************************************************************
**
*F CompIsbPosObj( <expr> ) . . . . . . . . . . . . . . . . . . T_ISB_POSOBJ
Expand Down Expand Up @@ -4983,64 +4947,6 @@ void CompAssPosObj (
}



/****************************************************************************
**
*F CompAsssPosObj( <stat> ) . . . . . . . . . . . . . . . . . T_ASSS_POSOBJ
*/
void CompAsssPosObj (
Stat stat )
{
CVar list; /* list */
CVar poss; /* positions */
CVar rhss; /* right hand sides */

/* print a comment */
if ( CompPass == 2 ) {
Emit( "\n/* " ); PrintStat( stat ); Emit( " */\n" );
}

/* compile the list expression */
list = CompExpr(READ_STAT(stat, 0));

/* compile and check the position expression */
poss = CompExpr(READ_STAT(stat, 1));

/* compile the right hand side */
rhss = CompExpr(READ_STAT(stat, 2));

/* emit the code */
Emit( "AsssPosObjCheck( %c, %c, %c );\n", list, poss, rhss );

/* free the temporaries */
if ( IS_TEMP_CVAR( rhss ) ) FreeTemp( TEMP_CVAR( rhss ) );
if ( IS_TEMP_CVAR( poss ) ) FreeTemp( TEMP_CVAR( poss ) );
if ( IS_TEMP_CVAR( list ) ) FreeTemp( TEMP_CVAR( list ) );
}


/****************************************************************************
**
*F CompAssPosObjLev( <stat> ) . . . . . . . . . . . . . . T_ASS_POSOBJ_LEV
*/
void CompAssPosObjLev (
Stat stat )
{
Emit( "CANNOT COMPILE STATEMENT OF TNUM %d;\n", TNUM_STAT(stat) );
}


/****************************************************************************
**
*F CompAsssPosObjLev( <stat> ) . . . . . . . . . . . . . . T_ASSS_POSOBJ_LEV
*/
void CompAsssPosObjLev (
Stat stat )
{
Emit( "CANNOT COMPILE STATEMENT OF TNUM %d;\n", TNUM_STAT(stat) );
}


/****************************************************************************
**
*F CompUnbPosObj( <stat> ) . . . . . . . . . . . . . . . . . . T_UNB_POSOBJ
Expand Down Expand Up @@ -5918,9 +5824,6 @@ static Int InitKernel (
CompExprFuncs[ T_ISB_REC_EXPR ] = CompIsbRecExpr;

CompExprFuncs[ T_ELM_POSOBJ ] = CompElmPosObj;
CompExprFuncs[ T_ELMS_POSOBJ ] = CompElmsPosObj;
CompExprFuncs[ T_ELM_POSOBJ_LEV ] = CompElmPosObjLev;
CompExprFuncs[ T_ELMS_POSOBJ_LEV ] = CompElmsPosObjLev;
CompExprFuncs[ T_ISB_POSOBJ ] = CompIsbPosObj;
CompExprFuncs[ T_ELM_COMOBJ_NAME ] = CompElmComObjName;
CompExprFuncs[ T_ELM_COMOBJ_EXPR ] = CompElmComObjExpr;
Expand Down Expand Up @@ -6005,9 +5908,6 @@ static Int InitKernel (
CompStatFuncs[ T_UNB_REC_EXPR ] = CompUnbRecExpr;

CompStatFuncs[ T_ASS_POSOBJ ] = CompAssPosObj;
CompStatFuncs[ T_ASSS_POSOBJ ] = CompAsssPosObj;
CompStatFuncs[ T_ASS_POSOBJ_LEV ] = CompAssPosObjLev;
CompStatFuncs[ T_ASSS_POSOBJ_LEV ] = CompAsssPosObjLev;
CompStatFuncs[ T_UNB_POSOBJ ] = CompUnbPosObj;
CompStatFuncs[ T_ASS_COMOBJ_NAME ] = CompAssComObjName;
CompStatFuncs[ T_ASS_COMOBJ_EXPR ] = CompAssComObjExpr;
Expand Down
Loading

0 comments on commit d17d0f6

Please sign in to comment.