Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several bugs (including crashes, and invalid permutations) #2766

Merged
merged 6 commits into from
Sep 4, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions doc/ref/language.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1653,8 +1653,7 @@ It is an error to use this statement other than inside a loop.
<P/>
<Log><![CDATA[
gap> break;
Error, A break statement can only appear inside a loop
not in any function
Syntax error: 'break' statement not enclosed in a loop
]]></Log>

</Section>
Expand Down Expand Up @@ -1688,8 +1687,7 @@ It is an error to use this statement other than inside a loop.
<P/>
<Log><![CDATA[
gap> continue;
Error, A continue statement can only appear inside a loop
not in any function
Syntax error: 'continue' statement not enclosed in a loop
]]></Log>

</Section>
Expand Down
134 changes: 18 additions & 116 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 @@ -2318,13 +2316,13 @@ void CodeAssList ( Int narg )
{
Stat ass; /* assignment, result */

GAP_ASSERT(narg == 1 || narg == 2);

/* allocate the assignment */
if (narg == 1)
ass = NewStat( T_ASS_LIST, 3 * sizeof(Stat) );
else if (narg == 2)
else /* if (narg == 2) */
ass = NewStat( T_ASS2_LIST, 4 * sizeof(Stat));
else
ass = NewStat( T_ASSX_LIST, (narg + 2) * sizeof(Stat));

/* let 'CodeAssListUniv' do the rest */
CodeAssListUniv( ass, narg );
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 All @@ -2431,13 +2429,13 @@ void CodeElmList ( Int narg )
{
Expr ref; /* reference, result */

GAP_ASSERT(narg == 1 || narg == 2);

/* allocate the reference */
if (narg == 1)
ref = NewExpr( T_ELM_LIST, 2 * sizeof(Expr) );
else if (narg == 2)
else /* if (narg == 2) */
ref = NewExpr( T_ELM2_LIST, 3 * sizeof(Expr) );
else
ref = NewExpr( T_ELMX_LIST, (narg + 1) * sizeof(Expr));

/* let 'CodeElmListUniv' to the rest */
CodeElmListUniv( ref, 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
30 changes: 0 additions & 30 deletions src/code.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ enum STAT_TNUM {

T_ASS_LIST,
T_ASS2_LIST,
T_ASSX_LIST,
T_ASSS_LIST,
T_ASS_LIST_LEV,
T_ASSS_LIST_LEV,
Expand All @@ -216,9 +215,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 @@ -412,7 +408,6 @@ enum EXPR_TNUM {

T_ELM_LIST,
T_ELM2_LIST,
T_ELMX_LIST,
T_ELMS_LIST,
T_ELM_LIST_LEV,
T_ELMS_LIST_LEV,
Expand All @@ -424,9 +419,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 +1246,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
Loading