Пример #1
0
/*
 * GenTestCond - generate test condition for current statement
 */
void GenTestCond( void )
{
    char        v1[MAX_SRC_LINE];

    /*
     * process syntax of test condition
     * IF expr
     */
    strcpy( v1, CurrentSrcData );
    RemoveLeadingSpaces( v1 );
    if( v1[0] == 0 ) {
        AbortGen( ERR_SRC_INVALID_IF );
    }

    /*
     * build the if data structure
     */
#ifndef VICOMP
    if( EditFlags.CompileScript ) {
#endif
        genItem( SRC_T_IF, v1 );
#ifndef VICOMP
    } else {
        genItem( SRC_T_IF, NULL );
        AddString( &tmpTail->arg1, v1 );
    }
#endif

} /* GenTestCond */
Пример #2
0
/*
 * GenLabel - stick a label before current statment
 */
void GenLabel( label where )
{
    vi_rc   rc;

    genItem( SRC_T_LABEL, where );
    if( (rc = AddLabel( tmpTail, cLab, where )) != ERR_NO_ERR ) {
        AbortGen( rc );
    }
    tmpTail->hasvar = FALSE;
    strcpy( where, cLab->name[cLab->cnt - 1] );

} /* GenLabel */
Пример #3
0
static void oopsBob( char *current, char *start )
{
    Error( "'%s' has no %s", current, start );
    AbortGen( DO_NOT_CLEAR_MESSAGE_WINDOW );

} /* oopsBob */
Пример #4
0
/*
 * genExpr - gen an expression assignment
 */
static void genExpr( void )
{
    char        v1[MAX_SRC_LINE], v2[MAX_SRC_LINE], tmp[MAX_SRC_LINE];
#ifndef VICOMP
    expr_oper   oper = EXPR_EQ;
#endif

    /*
     * get expression syntax :
     * EXPR %v = v1
     */
    if( NextWord1( CurrentSrcData, v1 ) <= 0 ) {
        AbortGen( ERR_SRC_INVALID_EXPR );
    }
    if( NextWord1( CurrentSrcData, tmp ) <= 0 ) {
        AbortGen( ERR_SRC_INVALID_EXPR );
    }
    if( tmp[1] == '=' && tmp[2] == 0 ) {
        switch( tmp[0] ) {
#ifndef VICOMP
        case '+': oper = EXPR_PLUSEQ; break;
        case '-': oper = EXPR_MINUSEQ; break;
        case '*': oper = EXPR_TIMESEQ; break;
        case '/': oper = EXPR_DIVIDEEQ; break;
#else
        case '+': break;
        case '-': break;
        case '*': break;
        case '/': break;
#endif
        default:
            AbortGen( ERR_SRC_INVALID_EXPR );
            break;
        }
    } else {
        if( tmp[0] != '=' || tmp[1] != 0 ) {
            AbortGen( ERR_SRC_INVALID_EXPR );
        }
    }
    strcpy( v2, CurrentSrcData );
    RemoveLeadingSpaces( v2 );
    if( v2[0] == 0 ) {
        AbortGen( ERR_SRC_INVALID_EXPR );
    }
#ifndef VICOMP
    if( EditFlags.CompileScript ) {
#endif
        genItem( SRC_T_EXPR, StrMerge( 4, v1, SingleBlank, tmp, SingleBlank, v2 ) );
#ifndef VICOMP
    } else {
        /*
         * build the expr data structure
         */
        genItem( SRC_T_EXPR, NULL );
        tmpTail->u.oper = oper;
        AddString( &tmpTail->arg1, v1 );
        AddString( &tmpTail->arg2, v2 );
    }
#endif

} /* genExpr */