Loading src/hspcmp/codegen.cpp +20 −5 Changes for src/hspcmp/codegen.cpp: 20 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -1275,6 +1275,7 @@ void CToken::CheckInternalListenerCMD( int opt ) t = lb->GetType(i); o = lb->GetOpt(i); if ( t != TYPE_PROGCMD ) return; if ( o != 0x001 && o != 0x000 ) return;// not either gosub or goto if ( o == 0x001 ) { // gosub PutCS(t, o & 0xffff, 0); } Loading Loading @@ -1337,7 +1338,17 @@ void CToken::CheckInternalProgCMD( int opt, int orgcs ) if ( ttype != TK_OBJ ) throw CGERROR_SYNTAX; i = lb->Search( cg_str ); if ( i < 0 ) throw CGERROR_SYNTAX; PutCS( lb->GetType(i), lb->GetOpt(i), EXFLG_2 ); { int labelType = lb->GetType(i); int labelOpt = lb->GetOpt(i); if ((labelType == TYPE_PROGCMD) && (labelOpt == 0 || labelOpt == 1)) { // goto or gosub PutCS(labelType, labelOpt, EXFLG_2 ); } else { throw CGERROR_SYNTAX; } } break; case 0x08: // await Loading @@ -1350,14 +1361,14 @@ void CToken::CheckInternalProgCMD( int opt, int orgcs ) case 0x0d: // dimtype case 0x0e: // dup case 0x0f: // dupptr GetTokenCG( GETTOKEN_DEFAULT ); if ( ttype == TK_OBJ ) { i = SetVarsFixed( cg_str, cg_defvarfix ); { char *firstSymbolName = GetSymbolCG(cg_ptr); if (firstSymbolName == NULL || isdigit(*reinterpret_cast<unsigned char *>(firstSymbolName)) ) break; i = SetVarsFixed(firstSymbolName, cg_defvarfix ); // 変数の初期化フラグをセットする lb->SetInitFlag( i, LAB_INIT_DONE ); //Mesf( "#initflag set [%s]", cg_str ); } cg_ptr = cg_ptr_bak; break; } } Loading Loading @@ -2110,6 +2121,10 @@ void CToken::GenerateCodePP( char *buf ) // int i; GetTokenCG( GETTOKEN_DEFAULT ); // 最初の'#'を読み飛ばし if (*cg_ptr != PickNextCodeCG()) { // preprocesser command "#" throw CGERROR_UNKNOWN; } GetTokenCG( GETTOKEN_DEFAULT ); if ( ttype == TK_NONE ) { // プリプロセッサから渡される行情報 Loading src/hspcmp/token.cpp +32 −10 Changes for src/hspcmp/token.cpp: 32 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -748,41 +748,48 @@ void CToken::Calc_compare( CALCVAR &v ) int v1i,v2i,op; Calc_addsub(v1); while( (ttype=='<')||(ttype=='>')||(ttype=='=')) { op=ttype; Calc_token(); op=ttype; if (op=='=') { Calc_token(); Calc_addsub(v2); v1i = v1==v2; v1=(CALCVAR)v1i; continue; } if (op=='<') { if ( ttype=='=' ) { if ( *wp=='=' ) { wp++; Calc_token();Calc_addsub(v2); v1i=(v1<=v2); v1=(CALCVAR)v1i; continue; } if ( ttype=='<' ) { if ( *wp=='<' ) { wp++; Calc_token();Calc_addsub(v2); v1i = (int)v1; v2i = (int)v2; v1i<<=v2i; v1=(CALCVAR)v1i; continue; } Calc_token(); Calc_addsub(v2); v1i=(v1<v2); v1=(CALCVAR)v1i; continue; } if (op=='>') { if ( ttype=='=' ) { if ( *wp=='=' ) { wp++; Calc_token();Calc_addsub(v2); v1i=(v1>=v2); v1=(CALCVAR)v1i; continue; } if ( ttype=='>' ) { if ( *wp=='>' ) { wp++; Calc_token();Calc_addsub(v2); v1i = (int)v1; v2i = (int)v2; v1i>>=v2i; v1=(CALCVAR)v1i; continue; } Calc_token(); Calc_addsub(v2); v1i=(v1>v2); v1=(CALCVAR)v1i; continue; Loading Loading @@ -844,6 +851,10 @@ int CToken::Calc( CALCVAR &val ) SetError("abnormal calculation"); return -1; } if (ttype != TK_NONE) { SetError("expression syntax error"); return -1; } if ( wp==NULL ) { val = v; return 0; } if ( *wp==0 ) { val = v; return 0; } SetError("expression syntax error"); Loading Loading @@ -3024,12 +3035,15 @@ ppresult_t CToken::PreprocessNM( char *str ) word = (char *)s3; wp = (unsigned char *)str; unsigned char topUChar = *wp; *s3 = 0; if ( ahtmodel != NULL ) { PreprocessCommentCheck( str ); } type = GetToken(); if ( topUChar != *s3 ) return PPRESULT_UNKNOWN_DIRECTIVE; if ( type != TK_OBJ ) return PPRESULT_UNKNOWN_DIRECTIVE; // ソース生成コントロール Loading Loading @@ -3112,31 +3126,39 @@ ppresult_t CToken::Preprocess( char *str ) CALCVAR cres; word = (char *)s3; *s3 = 0; wp = (unsigned char *)str; unsigned char topUChar = *wp; type = GetToken(); if ( type != TK_OBJ ) return PPRESULT_SUCCESS; if (topUChar != *s3) { type = TK_NONE; } // ソース生成コントロール // if (type == TK_OBJ) { if (tstrcmp(word, "if")) { // generate control if (mulstr == LMODE_OFF) { res = PP_SwitchStart(0); } else { } else { res = PPRESULT_SUCCESS; if (Calc(cres) == 0) { a = (int)cres; res = PP_SwitchStart(a); } else res=PPRESULT_ERROR; } else res = PPRESULT_ERROR; } return res; } } // これ以降は#off時に実行しません // if (mulstr == LMODE_OFF) { return PPRESULT_SUCCESS; } // コード生成コントロール // if (type == TK_OBJ) { if (tstrcmp(word, "include")) { // text include res = PP_Include(0); return res; Loading Loading @@ -3258,7 +3280,7 @@ ppresult_t CToken::Preprocess( char *str ) res = PP_Usecom(); return res; } } // 登録キーワード以外はコンパイラに渡す // wrtbuf->Put( (char)'#' ); Loading Loading
src/hspcmp/codegen.cpp +20 −5 Changes for src/hspcmp/codegen.cpp: 20 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -1275,6 +1275,7 @@ void CToken::CheckInternalListenerCMD( int opt ) t = lb->GetType(i); o = lb->GetOpt(i); if ( t != TYPE_PROGCMD ) return; if ( o != 0x001 && o != 0x000 ) return;// not either gosub or goto if ( o == 0x001 ) { // gosub PutCS(t, o & 0xffff, 0); } Loading Loading @@ -1337,7 +1338,17 @@ void CToken::CheckInternalProgCMD( int opt, int orgcs ) if ( ttype != TK_OBJ ) throw CGERROR_SYNTAX; i = lb->Search( cg_str ); if ( i < 0 ) throw CGERROR_SYNTAX; PutCS( lb->GetType(i), lb->GetOpt(i), EXFLG_2 ); { int labelType = lb->GetType(i); int labelOpt = lb->GetOpt(i); if ((labelType == TYPE_PROGCMD) && (labelOpt == 0 || labelOpt == 1)) { // goto or gosub PutCS(labelType, labelOpt, EXFLG_2 ); } else { throw CGERROR_SYNTAX; } } break; case 0x08: // await Loading @@ -1350,14 +1361,14 @@ void CToken::CheckInternalProgCMD( int opt, int orgcs ) case 0x0d: // dimtype case 0x0e: // dup case 0x0f: // dupptr GetTokenCG( GETTOKEN_DEFAULT ); if ( ttype == TK_OBJ ) { i = SetVarsFixed( cg_str, cg_defvarfix ); { char *firstSymbolName = GetSymbolCG(cg_ptr); if (firstSymbolName == NULL || isdigit(*reinterpret_cast<unsigned char *>(firstSymbolName)) ) break; i = SetVarsFixed(firstSymbolName, cg_defvarfix ); // 変数の初期化フラグをセットする lb->SetInitFlag( i, LAB_INIT_DONE ); //Mesf( "#initflag set [%s]", cg_str ); } cg_ptr = cg_ptr_bak; break; } } Loading Loading @@ -2110,6 +2121,10 @@ void CToken::GenerateCodePP( char *buf ) // int i; GetTokenCG( GETTOKEN_DEFAULT ); // 最初の'#'を読み飛ばし if (*cg_ptr != PickNextCodeCG()) { // preprocesser command "#" throw CGERROR_UNKNOWN; } GetTokenCG( GETTOKEN_DEFAULT ); if ( ttype == TK_NONE ) { // プリプロセッサから渡される行情報 Loading
src/hspcmp/token.cpp +32 −10 Changes for src/hspcmp/token.cpp: 32 added lines, 10 removed lines. Original line number Diff line number Diff line Loading @@ -748,41 +748,48 @@ void CToken::Calc_compare( CALCVAR &v ) int v1i,v2i,op; Calc_addsub(v1); while( (ttype=='<')||(ttype=='>')||(ttype=='=')) { op=ttype; Calc_token(); op=ttype; if (op=='=') { Calc_token(); Calc_addsub(v2); v1i = v1==v2; v1=(CALCVAR)v1i; continue; } if (op=='<') { if ( ttype=='=' ) { if ( *wp=='=' ) { wp++; Calc_token();Calc_addsub(v2); v1i=(v1<=v2); v1=(CALCVAR)v1i; continue; } if ( ttype=='<' ) { if ( *wp=='<' ) { wp++; Calc_token();Calc_addsub(v2); v1i = (int)v1; v2i = (int)v2; v1i<<=v2i; v1=(CALCVAR)v1i; continue; } Calc_token(); Calc_addsub(v2); v1i=(v1<v2); v1=(CALCVAR)v1i; continue; } if (op=='>') { if ( ttype=='=' ) { if ( *wp=='=' ) { wp++; Calc_token();Calc_addsub(v2); v1i=(v1>=v2); v1=(CALCVAR)v1i; continue; } if ( ttype=='>' ) { if ( *wp=='>' ) { wp++; Calc_token();Calc_addsub(v2); v1i = (int)v1; v2i = (int)v2; v1i>>=v2i; v1=(CALCVAR)v1i; continue; } Calc_token(); Calc_addsub(v2); v1i=(v1>v2); v1=(CALCVAR)v1i; continue; Loading Loading @@ -844,6 +851,10 @@ int CToken::Calc( CALCVAR &val ) SetError("abnormal calculation"); return -1; } if (ttype != TK_NONE) { SetError("expression syntax error"); return -1; } if ( wp==NULL ) { val = v; return 0; } if ( *wp==0 ) { val = v; return 0; } SetError("expression syntax error"); Loading Loading @@ -3024,12 +3035,15 @@ ppresult_t CToken::PreprocessNM( char *str ) word = (char *)s3; wp = (unsigned char *)str; unsigned char topUChar = *wp; *s3 = 0; if ( ahtmodel != NULL ) { PreprocessCommentCheck( str ); } type = GetToken(); if ( topUChar != *s3 ) return PPRESULT_UNKNOWN_DIRECTIVE; if ( type != TK_OBJ ) return PPRESULT_UNKNOWN_DIRECTIVE; // ソース生成コントロール Loading Loading @@ -3112,31 +3126,39 @@ ppresult_t CToken::Preprocess( char *str ) CALCVAR cres; word = (char *)s3; *s3 = 0; wp = (unsigned char *)str; unsigned char topUChar = *wp; type = GetToken(); if ( type != TK_OBJ ) return PPRESULT_SUCCESS; if (topUChar != *s3) { type = TK_NONE; } // ソース生成コントロール // if (type == TK_OBJ) { if (tstrcmp(word, "if")) { // generate control if (mulstr == LMODE_OFF) { res = PP_SwitchStart(0); } else { } else { res = PPRESULT_SUCCESS; if (Calc(cres) == 0) { a = (int)cres; res = PP_SwitchStart(a); } else res=PPRESULT_ERROR; } else res = PPRESULT_ERROR; } return res; } } // これ以降は#off時に実行しません // if (mulstr == LMODE_OFF) { return PPRESULT_SUCCESS; } // コード生成コントロール // if (type == TK_OBJ) { if (tstrcmp(word, "include")) { // text include res = PP_Include(0); return res; Loading Loading @@ -3258,7 +3280,7 @@ ppresult_t CToken::Preprocess( char *str ) res = PP_Usecom(); return res; } } // 登録キーワード以外はコンパイラに渡す // wrtbuf->Put( (char)'#' ); Loading