Changeset 41 in dev


Ignore:
Timestamp:
Jan 28, 2007, 5:28:43 AM (17 years ago)
Author:
dai_9181
Message:

ByVal演算子を追加

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • BasicCompiler32/NumOpe.cpp

    r40 r41  
    667667                break;
    668668
     669            case CALC_BYVAL:
     670                //ポインタ型→参照型
     671                if( PTR_LEVEL( type[sp-1] ) <= 0 ){
     672                    //ポインタ型ではないとき
     673                    SetError( 3, NULL, cp );
     674                    goto error;
     675                }
     676
     677                type[sp-1] = PTR_LEVEL_DOWN( type[sp-1] );
     678
     679                break;
     680
    669681            default:
    670682                SetError(300,NULL,cp);
    671                 break;
     683                goto error;
    672684        }
    673685    }
  • BasicCompiler64/Compile_Var.cpp

    r40 r41  
    934934    }
    935935
     936
     937    ///////////////////////////////////////
     938    // 単発式([]で囲まれていない)
     939    ///////////////////////////////////////
     940
    936941    if(SubScripts[0]!=-1){
    937942        SetError(41,0,cp);
  • BasicCompiler64/NumOpe.cpp

    r38 r41  
    737737                if(!Calc_Cast(type,index_stack,&sp)) goto error;
    738738                break;
     739            case CALC_BYVAL:
     740                //ポインタ型→参照型
     741                if( PTR_LEVEL( type[sp-1] ) <= 0 ){
     742                    //ポインタ型ではないとき
     743                    SetError( 3, NULL, cp );
     744                    goto error;
     745                }
     746
     747                type[sp-1] = PTR_LEVEL_DOWN( type[sp-1] );
     748
     749                break;
    739750
    740751            default:
    741752                SetError(300,NULL,cp);
    742                 break;
     753                goto error;
    743754        }
    744755    }
  • BasicCompiler_Common/BasicFixed.h

    r40 r41  
    5454#define NATURAL_TYPE(t) ((t)&MASK_NATURAL)
    5555#define MAKE_PTR_TYPE(t,p)  ((t)|((p)<<8))
    56 #define PTR_LEVEL_UP(t) MAKE_PTR_TYPE(NATURAL_TYPE(t),PTR_LEVEL(t)+1)
     56#define PTR_LEVEL_UP(t)     MAKE_PTR_TYPE(NATURAL_TYPE(t),PTR_LEVEL(t)+1)
     57#define PTR_LEVEL_DOWN(t)   MAKE_PTR_TYPE(NATURAL_TYPE(t),PTR_LEVEL(t)-1)
    5758
    5859#define DEF_PTR_BYTE    MAKE_PTR_TYPE(DEF_BYTE,1)
     
    105106#define CALC_INTQUOTIENT    63  //整数除算
    106107#define CALC_AS             71  // As
     108#define CALC_BYVAL          72  // ByVal
    107109#define CALC_MINUSMARK      81  // -x
    108110#define CALC_POWER          91  // ^
  • BasicCompiler_Common/NumOpe_GetType.cpp

    r38 r41  
    163163        case CALC_AS:
    164164            if((type[sp-1]&FLAG_CAST)==0){
     165                //型名が指定されていないときはエラー
     166                SetError(47,NULL,cp);
     167                return 0;
     168            }
     169            break;
     170
     171        case CALC_BYVAL:
     172            if(type[sp-1]&FLAG_CAST){
    165173                //型名が指定されていないときはエラー
    166174                SetError(47,NULL,cp);
     
    601609                sp--;
    602610                break;
     611
     612            case CALC_BYVAL:
     613                //ポインタ型→参照型
     614                if( PTR_LEVEL( type[sp-1] ) <= 0 ){
     615                    //ポインタ型ではないとき
     616                    SetError( 3, NULL, cp );
     617                    goto error;
     618                }
     619
     620                type[sp-1] = PTR_LEVEL_DOWN( type[sp-1] );
     621                break;
    603622        }
    604623    }
  • BasicCompiler_Common/StrOperation.cpp

    r31 r41  
    652652            lstrcpy(name,"As");
    653653            break;
     654        case CALC_BYVAL:
     655            lstrcpy(name,"ByVal");
     656            break;
    654657        case CALC_MINUSMARK:
    655658            lstrcpy(name,"-");
  • BasicCompiler_Common/calculation.cpp

    r36 r41  
    3939        Command[p]=='='||Command[p]=='<'||Command[p]=='>'||
    4040        IsJudgMark(Command,p)||
    41         (Command[p]==1&&Command[p+1]==ESC_AS)) return 1;
     41        (Command[p]==1&&Command[p+1]==ESC_AS)||
     42        (Command[p]==1&&Command[p+1]==ESC_BYVAL)) return 1;
    4243    return 0;
    4344}
     
    775776            else if(Command[i]=='^') i3=CALC_POWER;
    776777            else if(Command[i]==1&&Command[i+1]==ESC_AS) i3=CALC_AS;
     778            else if(Command[i]==1&&Command[i+1]==ESC_BYVAL) i3=CALC_BYVAL;
    777779
    778780            i3+=PareNum*100;
     
    889891                sp--;
    890892                break;
     893            case CALC_BYVAL:
     894                //エラー
     895                break;
    891896        }
    892897    }
     
    14041409    else if(Command[0]=='^') return CALC_POWER;
    14051410    else if(Command[0]==1&&Command[1]==ESC_AS) return CALC_AS;
     1411    else if(Command[0]==1&&Command[1]==ESC_BYVAL) return CALC_BYVAL;
    14061412
    14071413    return 0;
     
    14801486            }
    14811487            else{
    1482                 if(!(Command[i]=='+'||Command[i]=='-'||(Command[i]==1&&Command[i+1]==ESC_NOT))){
    1483                     SetError(1,NULL,cp);
    1484                     return 0;
     1488                if(!(
     1489                        Command[i]=='+'||
     1490                        Command[i]=='-'||
     1491                        (Command[i]==1&&Command[i+1]==ESC_NOT)||
     1492                        (Command[i]==1&&Command[i+1]==ESC_BYVAL)
     1493                    )){
     1494                        SetError(1,NULL,cp);
     1495                        return 0;
    14851496                }
    14861497                if(Command[i]=='+'){
  • ProjectEditor/SubOperation.cpp

    r39 r41  
    504504    else if(str[0]=='o'||str[0]=='O'){
    505505        if(lstrcmpi(str,"Open")==0) return COM_OPEN;
     506        if(lstrcmpi(str,"Operator")==0) return -1;
    506507        if(lstrcmpi(str,"Override")==0) return COM_OVERRIDE;
    507508    }
Note: See TracChangeset for help on using the changeset viewer.