예제 #1
0
void TermDo( void )
{
// Terminate a DO or an implied DO.

    do_entry    *do_pointer;
    sym_id      do_var;

    if( CSHead->typ == CS_DO ) {
        do_pointer = CSHead->cs_info.do_parms;
        if( do_pointer->do_parm != NULL ) {
            if( ( StmtSw & SS_DATA_INIT ) == 0 ) {
                GLabel( CSHead->cycle );
            }
            GDoEnd();
            do_var = do_pointer->do_parm;
            if( (do_var->u.ns.flags & SY_SPECIAL_PARM) &&
                !(do_var->u.ns.flags & SY_PS_ENTRY) ) {
                STUnShadow( do_var );
            }
            do_var->u.ns.flags &= ~SY_DO_PARM;
            if( ( StmtSw & SS_DATA_INIT ) == 0 ) {
                GLabel( CSHead->bottom );
            }
        }
    } else {
        Match();
    }
    if( ( StmtSw & SS_DATA_INIT ) == 0 ) {
        FreeLabel( CSHead->branch );
        FreeLabel( CSHead->bottom );
        FreeLabel( CSHead->cycle );
    }
    DelCSNode();
}
예제 #2
0
void CpWhile( void )
{
//=================

// Compile a WHILE statement.
//    WHILE( expr )DO <:label> -- block while
//    WHILE( expr )   <:label> -- block while
//    WHILE( expr ) STATEMENT  -- one line while

    CSExtn();
    InitLoop( CS_WHILE );
    CSCond( CSHead->bottom );
    if( RecNOpn() && RecNextOpr( OPR_COL ) ) {
        BlockLabel();
    } else if( RecKeyWord( "DO" ) &&
               ( RecNextOpr( OPR_TRM ) || RecNextOpr( OPR_COL ) ) ) {
        CITNode->opn.ds = DSOPN_PHI;
        BlockLabel();
    } else {
        Recurse();
        GLabel( CSHead->cycle );
        FiniLoop();
        DelCSNode();
    }
}
예제 #3
0
void    CpElseIf(void) {
//==================

// Process an ELSEIF statement.

    if( ( CSHead->typ == CS_IF ) || ( CSHead->typ == CS_ELSEIF ) ) {
        GBranch( CSHead->bottom );
        GLabel( CSHead->branch );
        FreeLabel( CSHead->branch );
        CSHead->typ = CS_ELSEIF;
        CSHead->branch = NextLabel();
        CSHead->block = ++BlockNum;
    } else if( CSHead->typ == CS_ELSE ) {
        Error( IF_ELSE_LAST );
    } else {
        Match();
    }
    CSCond( CSHead->branch );
    if( RecKeyWord( "THEN" ) ) {
        AdvanceITPtr();
        ReqEOS();
    } else {
        Error( IF_NO_THEN );
    }
}
예제 #4
0
static void FiniLoop( void )
{
    GBranch( CSHead->branch );
    GLabel( CSHead->bottom );
    FreeLabel( CSHead->branch );
    FreeLabel( CSHead->bottom );
    FreeLabel( CSHead->cycle );
}
예제 #5
0
static void InitLoop( int loop_type )
{
    AddCSNode( loop_type );
    CSHead->branch = NextLabel();
    CSHead->bottom = NextLabel();
    CSHead->cycle = NextLabel();
    GLabel( CSHead->branch );
}
예제 #6
0
void CpUntil( void )
{
// Compile an UNTIL statement.

    if( ( CSHead->typ == CS_LOOP ) || ( CSHead->typ == CS_WHILE ) ) {
        GLabel( CSHead->cycle );
        CSCond( CSHead->branch );
        GLabel( CSHead->bottom );
        FreeLabel( CSHead->branch );
        FreeLabel( CSHead->bottom );
        FreeLabel( CSHead->cycle );
    } else {
        Match();
    }
    DelCSNode();
    CSNoMore();
}
예제 #7
0
void    CpEndif(void) {
//=================

// Process an ENDIF statement.

    if( ( CSHead->typ == CS_IF ) || ( CSHead->typ == CS_ELSEIF ) ) {
        GLabel( CSHead->branch );
        FreeLabel( CSHead->branch );
        GLabel( CSHead->bottom );
        FreeLabel( CSHead->bottom );
    } else if( CSHead->typ == CS_ELSE ) {
        GLabel( CSHead->bottom );
        FreeLabel( CSHead->bottom );
    } else {
        Match();
    }
    DelCSNode();
    CSNoMore();
}
예제 #8
0
void CpEndLoop( void )
{
// Compile an ENDLOOP statment.

    if( CSHead->typ == CS_LOOP ) {
        GLabel( CSHead->cycle );
        FiniLoop();
    } else {
        Match();
    }
    DelCSNode();
    CSNoMore();
}
예제 #9
0
void CpEndWhile( void )
{
// Compile an ENDWHILE statement.

    if( CSHead->typ == CS_WHILE ) {
        GLabel( CSHead->cycle );
        FiniLoop();
    } else {
        Match();
    }
    DelCSNode();
    CSNoMore();
}
예제 #10
0
void CpEndBlock( void )
{
    CheckCSList( CS_REMOTEBLOCK );
    if( CSHead->typ == CS_REMOTEBLOCK ) {
        GLabel( CSHead->bottom );
        FreeLabel( CSHead->bottom );
        // Make sure REMOTEBLOCK statement was valid.
        if( CSHead->cs_info.rb != NULL ) {
            GEndBlock();
        }
        GLabel( CSHead->branch );
        FreeLabel( CSHead->branch );
        DelCSNode();
    } else {
        Match();
    }
    CSNoMore();
    StNumbers.in_remote = FALSE;
    ClearRem();
    CSNoMore();
    BIEndRBorEP();
}
예제 #11
0
void    GEpilog( void ) {
//=================

// Generate a subprogram epilogue.

    if( (SubProgId->u.ns.flags & SY_SUBPROG_TYPE) == SY_SUBROUTINE ) {
        GNullRetIdx();
    }
    if( EpilogLabel != 0 ) {
        GLabel( EpilogLabel );
        FreeLabel( EpilogLabel );
    }
    EmitOp( FC_EPILOGUE );
    OutPtr( SubProgId );
}
예제 #12
0
void    CpElse(void) {
//================

// Process an ELSE statement.

    if( ( CSHead->typ == CS_IF ) || ( CSHead->typ == CS_ELSEIF ) ) {
        GBranch( CSHead->bottom );
        GLabel( CSHead->branch );
        FreeLabel( CSHead->branch );
        CSHead->typ = CS_ELSE;
        CSHead->block = ++BlockNum;
    } else if( CSHead->typ == CS_ELSE ) {
        Error( IF_ELSE_LAST );
    } else {
        Match();
    }
    CSNoMore();
}
예제 #13
0
void    CpLogIf(void) {
//=================

// Process a logical IF statement.

    label_id    if_skip;

    if_skip = NextLabel();
    CSCond( if_skip );
    if( RecKeyWord( "THEN" ) &&
        ( RecNextOpr( OPR_TRM ) || RecNextOpr( OPR_COL ) ) ) {
        AddCSNode( CS_IF );
        CSHead->branch = if_skip;
        CSHead->bottom = NextLabel();
        CITNode->opn.ds = DSOPN_PHI;       // not part of the block label
        BlockLabel();
        CtrlFlgs |= CF_BAD_DO_ENDING;
    } else {
        Recurse();
        GLabel( if_skip );
        FreeLabel( if_skip );
    }
}
예제 #14
0
void    GEPProlog( void ) {
//===================

// Generate an entry point prologue.

    sym_id      ep;
    char        *ptr;
    char        name[MAX_SYMLEN+3];

    ep = ArgList->id;
    ep->u.ns.si.sp.u.entry = NextLabel();
    GLabel( ep->u.ns.si.sp.u.entry );
    // by the time we define the label for the entry point, the code that
    // references it will have been executed
    FreeLabel( ep->u.ns.si.sp.u.entry );
    SetArgAddrs();
    if( CommonEntry == NULL ) {
        ptr = name;
        *ptr = '$';
        ptr++;
        ptr = STGetName( SubProgId, ptr );
        *ptr = '.';
        ptr++;
        *ptr = NULLCHAR;
        CommonEntry = SymLookup( name, SubProgId->u.ns.u2.name_len + 2 );
        if( (SubProgId->u.ns.flags & SY_SUBPROG_TYPE) == SY_SUBROUTINE ) {
            CommonEntry->u.ns.flags = SY_USAGE | SY_SUBPROGRAM | SY_SUBROUTINE |
                                    SY_SENTRY | SY_REFERENCED;
        } else {
            CommonEntry->u.ns.flags = SY_USAGE | SY_SUBPROGRAM | SY_FUNCTION |
                                    SY_SENTRY | SY_REFERENCED;
        }
        EPValue = SymLookup( "$@EVAL", 6 );
        EPValue->u.ns.flags |= SY_REFERENCED;
        EPValue->u.ns.u1.s.xflags |= SY_DEFINED;
    }
}
예제 #15
0
void TermDoWhile( void )
{
    GLabel( CSHead->cycle );
    FiniLoop();
    DelCSNode();
}