Changeset 828 in dev for trunk/ab5.0/abdev/BasicCompiler_Common/src
- Timestamp:
- Mar 19, 2012, 1:59:48 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
-
Property svn:mergeinfo
set to
/branches/egtra merged eligible
-
Property svn:mergeinfo
set to
-
trunk/ab5.0/abdev
-
Property svn:ignore
set to
*.opensdf
*.sdf
*.suo
*.user
int
ipch
out
-
Property svn:ignore
set to
-
trunk/ab5.0/abdev/BasicCompiler_Common/src/BoostSerializationSupport.cpp
r751 r828 1 #pragma warning(disable : 4996)2 3 1 #include <map> 4 2 #include <string> … … 19 17 #include <limits.h> 20 18 #include <shlobj.h> 21 #include <process.h>22 #include <fcntl.h>23 #include <io.h>24 19 #include <shlwapi.h> 25 20 #include <tchar.h> 26 #include <stdarg.h>27 21 28 22 //boost libraries 29 23 #include <boost/foreach.hpp> 30 24 #include <boost/cast.hpp> 25 26 #pragma warning(push) 27 #pragma warning(disable: 4244 6326) 31 28 #include <boost/archive/xml_oarchive.hpp> 32 29 #include <boost/archive/xml_iarchive.hpp> … … 41 38 #include <boost/serialization/map.hpp> 42 39 #include <boost/serialization/version.hpp> 43 # include <boost/serialization/is_abstract.hpp>40 #pragma warning(pop) 44 41 45 42 #include <jenga/include/jenga.h> … … 49 46 using namespace Jenga::Common; 50 47 48 using boost::polymorphic_downcast; 49 51 50 template<class T_xml_schema> void BoostSerializationSupport<T_xml_schema>::echo( const char *msg ) const 52 51 { 53 MessageBox( NULL, msg, " XMLシリアライズの例外", MB_OK );52 MessageBox( NULL, msg, "シリアライズの例外", MB_OK ); 54 53 } 55 54 template<class T_xml_schema> bool BoostSerializationSupport<T_xml_schema>::ReadXml( std::istream& ifs, bool isShowExceptionMessage ) … … 61 60 62 61 // ファイルから読込 63 ia >> boost::serialization::make_nvp( RootTagName(), * (T_xml_schema *)this);64 65 isSuccessful = true; 66 } 67 catch( boost::archive::archive_exception e )62 ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) ); 63 64 isSuccessful = true; 65 } 66 catch( boost::archive::archive_exception const& e ) 68 67 { 69 68 if( isShowExceptionMessage ) … … 94 93 95 94 // ファイルに書き出し 96 oa << boost::serialization::make_nvp( RootTagName(), * (T_xml_schema *)this);97 98 isSuccessful = true; 99 } 100 catch( boost::archive::archive_exception e )95 oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) ); 96 97 isSuccessful = true; 98 } 99 catch( boost::archive::archive_exception const& e ) 101 100 { 102 101 if( isShowExceptionMessage ) … … 154 153 155 154 // 文字列ストリームから読込 156 ia >> boost::serialization::make_nvp( RootTagName(), * (T_xml_schema *)this);155 ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) ); 157 156 158 157 isSuccessful = true; … … 179 178 180 179 // 文字列ストリームに書き出し 181 oa << boost::serialization::make_nvp( RootTagName(), * (T_xml_schema *)this);182 183 isSuccessful = true; 184 } 185 catch( boost::archive::archive_exception e )180 oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) ); 181 182 isSuccessful = true; 183 } 184 catch( boost::archive::archive_exception const& e ) 186 185 { 187 186 echo( e.what() ); … … 211 210 212 211 // ファイルから読込 213 ia >> boost::serialization::make_nvp( RootTagName(), * (T_xml_schema *)this);214 215 isSuccessful = true; 216 } 217 catch( boost::archive::archive_exception e )212 ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) ); 213 214 isSuccessful = true; 215 } 216 catch( boost::archive::archive_exception const& e ) 218 217 { 219 218 if( isShowExceptionMessage ) … … 249 248 250 249 // ファイルに書き出し 251 oa << boost::serialization::make_nvp( RootTagName(), * (T_xml_schema *)this);252 253 isSuccessful = true; 254 } 255 catch( boost::archive::archive_exception e )250 oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) ); 251 252 isSuccessful = true; 253 } 254 catch( boost::archive::archive_exception const& e ) 256 255 { 257 256 if( isShowExceptionMessage ) … … 289 288 290 289 // 文字列ストリームから読込 291 ia >> boost::serialization::make_nvp( RootTagName(), * (T_xml_schema *)this);292 293 isSuccessful = true; 294 } 295 catch( boost::archive::archive_exception e )290 ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) ); 291 292 isSuccessful = true; 293 } 294 catch( boost::archive::archive_exception const& e ) 296 295 { 297 296 echo( e.what() ); … … 313 312 314 313 // 文字列ストリームに書き出し 315 oa << boost::serialization::make_nvp( RootTagName(), * (T_xml_schema *)this);316 317 isSuccessful = true; 318 } 319 catch( boost::archive::archive_exception e )314 oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) ); 315 316 isSuccessful = true; 317 } 318 catch( boost::archive::archive_exception const& e ) 320 319 { 321 320 echo( e.what() ); … … 342 341 343 342 // ファイルから読込 344 ia >> boost::serialization::make_nvp( RootTagName(), * (T_xml_schema *)this);345 346 isSuccessful = true; 347 } 348 catch( boost::archive::archive_exception e )343 ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) ); 344 345 isSuccessful = true; 346 } 347 catch( boost::archive::archive_exception const& e ) 349 348 { 350 349 if( isShowExceptionMessage ) … … 380 379 381 380 // ファイルに書き出し 382 oa << boost::serialization::make_nvp( RootTagName(), * (T_xml_schema *)this);383 384 isSuccessful = true; 385 } 386 catch( boost::archive::archive_exception e )381 oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) ); 382 383 isSuccessful = true; 384 } 385 catch( boost::archive::archive_exception const& e ) 387 386 { 388 387 if( isShowExceptionMessage ) … … 420 419 421 420 // 文字列ストリームから読込 422 ia >> boost::serialization::make_nvp( RootTagName(), * (T_xml_schema *)this);421 ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) ); 423 422 424 423 isSuccessful = true; … … 445 444 446 445 // 文字列ストリームに書き出し 447 oa << boost::serialization::make_nvp( RootTagName(), * (T_xml_schema *)this);448 449 isSuccessful = true; 450 } 451 catch( boost::archive::archive_exception e )446 oa << boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema const*>(this) ); 447 448 isSuccessful = true; 449 } 450 catch( boost::archive::archive_exception const& e ) 452 451 { 453 452 echo( e.what() ); … … 478 477 479 478 // 文字列ストリームから読込 480 ia >> boost::serialization::make_nvp( RootTagName(), * (T_xml_schema *)this);479 ia >> boost::serialization::make_nvp( RootTagName(), *polymorphic_downcast<T_xml_schema*>(this) ); 481 480 482 481 isSuccessful = true; -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Compiler.cpp
r750 r828 353 353 const std::string Compiler::TypeToString( const Type &type ) 354 354 { 355 if( PTR_LEVEL( type.GetBasicType() ) ){355 if(type.GetBasicType() != DEF_NON && PTR_LEVEL( type.GetBasicType() ) ){ 356 356 //ポインタレベルが1以上の場合 357 357 Type tempType( type ); -
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer.cpp
r625 r828 3 3 using namespace ActiveBasic::Compiler; 4 4 5 bool LexicalAnalyzer::CollectNamespaces( const char *source, NamespaceScopesCollection &namespaceScopesCollection ) 5 using boost::numeric_cast; 6 7 bool LexicalAnalyzer::CollectNamespaces(char const* source, NamespaceScopesCollection &namespaceScopesCollection) 6 8 { 7 int i, i2;8 char temporary[1024];9 10 9 bool isSuccessful = true; 11 10 … … 13 12 NamespaceScopes namespaceScopes; 14 13 15 for(i=0;;i++){ 14 for (int i = 0; ; i++) 15 { 16 16 if(source[i]=='\0') break; 17 17 18 18 if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){ 19 for(i+=2,i2=0;;i2++,i++){ 20 if( IsCommandDelimitation( source[i] ) ){ 21 temporary[i2]=0; 22 break; 23 } 24 temporary[i2]=source[i]; 19 i+=2; 20 char const* p = &source[i]; 21 while (!IsCommandDelimitation(source[i])) 22 { 23 ++i; 25 24 } 26 namespaceScopes.push_back( temporary);25 namespaceScopes.push_back(std::string(p, &source[i])); 27 26 28 27 if( !namespaceScopesCollection.IsExist( namespaceScopes ) ){ … … 46 45 } 47 46 48 if( namespaceScopes.size() > 0){47 if( !namespaceScopes.empty() ){ 49 48 compiler.errorMessenger.Output( 63, NULL, cp ); 50 49 isSuccessful = false; -
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Class.cpp
r750 r828 15 15 void LexicalAnalyzer::CollectClassesForNameOnly( const char *source, Classes &classes ) 16 16 { 17 int i , i2;17 int i2; 18 18 char temporary[VN_SIZE]; 19 19 … … 25 25 compiler.GetNamespaceSupporter().ClearImportedNamespaces(); 26 26 27 for(i =0;;i++){27 for(int i=0;;i++){ 28 28 if(source[i]=='\0') break; 29 29 30 30 if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){ 31 for(i+=2,i2=0;;i2++,i++){ 32 if( IsCommandDelimitation( source[i] ) ){ 33 temporary[i2]=0; 34 break; 35 } 36 temporary[i2]=source[i]; 37 } 38 namespaceScopes.push_back( temporary ); 31 i+=2; 32 char const* p = &source[i]; 33 while (!IsCommandDelimitation(source[i])) 34 { 35 ++i; 36 } 37 namespaceScopes.push_back(std::string(p, &source[i])); 39 38 40 39 continue; … … 52 51 } 53 52 else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){ 54 for(i+=2,i2=0;;i2++,i++){55 if( IsCommandDelimitation( source[i] ) ){56 temporary[i2]=0;57 break;58 }59 temporary[i2]=source[i];60 }61 if ( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ))62 { 63 compiler.errorMessenger.Output(64, temporary,i);53 i+=2; 54 char const* p = &source[i]; 55 while (!IsCommandDelimitation(source[i])) 56 { 57 ++i; 58 } 59 std::string s(p, &source[i]); 60 if (!compiler.GetNamespaceSupporter().ImportsNamespace(s)) 61 { 62 compiler.errorMessenger.Output(64, s.c_str(), i); 64 63 } 65 64 … … 1348 1347 delete pobj_LoopRefCheck; 1349 1348 pobj_LoopRefCheck=0; 1350 1351 // イテレータの準備1352 classes.Iterator_Init();1353 1349 } 1354 1350 … … 1412 1408 1413 1409 compiler.GetObjectModule().meta.GetUserProcs().Put( pUserProc ); 1414 compiler.GetObjectModule().meta.GetUserProcs().Iterator_Init();1415 1410 1416 1411 LexicalAnalyzer::AddMethod( … … 1522 1517 else 1523 1518 { 1524 for( int i=0; i<pInterface->GetDynamicMethods().size(); i++ )1519 for( std::size_t i=0; i<pInterface->GetDynamicMethods().size(); i++ ) 1525 1520 { 1526 1521 if( pInterface->GetDynamicMethods()[i]->IsAbstract() != pExpandedInterface->GetDynamicMethods()[i]->IsAbstract() ) -
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Const.cpp
r637 r828 85 85 86 86 int i2; 87 char temporary[1024];88 87 89 88 // 名前空間管理 … … 91 90 namespaceScopes.clear(); 92 91 93 for(int i=0;;i++){ 92 for (int i = 0; ; ++i) 93 { 94 94 if( source[i] == '\0' ) break; 95 95 96 96 if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){ 97 for(i+=2,i2=0;;i2++,i++){ 98 if( IsCommandDelimitation( source[i] ) ){ 99 temporary[i2]=0; 100 break; 101 } 102 temporary[i2]=source[i]; 103 } 104 namespaceScopes.push_back( temporary ); 97 i+=2; 98 char const* p = &source[i]; 99 while (!IsCommandDelimitation(source[i])) 100 { 101 ++i; 102 } 103 namespaceScopes.push_back(std::string(p, &source[i])); 105 104 106 105 continue; … … 131 130 } 132 131 132 char const* beginTemp = &source[i]; 133 char const* endTemp = &source[i]; 134 133 135 for(i2=0;;i++,i2++){ 134 136 if(source[i]=='\"'){ 135 temporary[i2]=source[i];136 137 for(i++,i2++;;i++,i2++){ 137 temporary[i2]=source[i];138 138 if(source[i]=='\"') break; 139 139 } … … 141 141 } 142 142 if(IsCommandDelimitation(source[i])){ 143 temporary[i2]=0;143 endTemp = beginTemp + i2; 144 144 break; 145 145 } 146 temporary[i2]=source[i];147 146 } 148 147 149 148 //名前を取得 150 char name[VN_SIZE];149 char const* nameEnd; 151 150 for(i2=0;;i2++){ 152 if( temporary[i2]=='\0'){151 if(beginTemp[i2]=='\0'){ 153 152 compiler.errorMessenger.Output(10,"Const",cp); 154 153 return; 155 154 } 156 if( temporary[i2]=='='||temporary[i2]=='('){157 name [i2]=0;155 if(beginTemp[i2]=='='||beginTemp[i2]=='('){ 156 nameEnd = beginTemp + i2; 158 157 break; 159 158 } 160 name[i2]=temporary[i2];161 }159 } 160 std::string name(beginTemp, nameEnd); 162 161 163 162 //重複チェック … … 165 164 || compiler.GetObjectModule().meta.GetGlobalConsts().IsExistDuplicationKeyName( name ) ) 166 165 { 167 compiler.errorMessenger.Output(15, name,cp);166 compiler.errorMessenger.Output(15, name, cp); 168 167 return; 169 168 } 170 169 171 if( temporary[i2] == '=' )170 if( beginTemp[i2] == '=' ) 172 171 { 173 172 // 定数 174 const char *expression = temporary + i2 + 1;173 std::string expression(beginTemp + i2 + 1, endTemp); 175 174 176 175 _int64 i64data; 177 176 Type resultType; 178 if( StaticCalculation(false, expression , 0, &i64data, resultType) )177 if( StaticCalculation(false, expression.c_str(), 0, &i64data, resultType) ) 179 178 { 180 179 consts.Add( Symbol( namespaceScopes, name ), i64data, resultType ); … … 184 183 { 185 184 // 定数マクロ 186 const char *params = temporary + i2;187 if( !constMacros.Add( Symbol( namespaceScopes, name ), params ) )185 std::string params(beginTemp + i2, endTemp); 186 if( !constMacros.Add( Symbol( namespaceScopes, name ), params.c_str() ) ) 188 187 { 189 188 compiler.errorMessenger.Output( 1, NULL, i ); … … 206 205 } 207 206 } 208 209 // イテレータを初期化 210 compiler.GetObjectModule().meta.GetGlobalConsts().Iterator_Init(); 211 compiler.GetObjectModule().meta.GetGlobalConstMacros().Iterator_Init(); 212 } 213 214 bool LexicalAnalyzer::ConstMacroToExpression( const ConstMacro &constMacro, const char *parameterStr, char *dest ) 215 { 216 extern HANDLE hHeap; 217 int i2,i3,i4,num; 207 } 208 209 bool LexicalAnalyzer::ConstMacroToExpression( const ConstMacro &constMacro, const char *parameterStr, char *dest, std::size_t destSize ) 210 { 211 std::string s; 212 auto ret = ConstMacroToExpression(constMacro, parameterStr, s); 213 strcpy_s(dest, destSize, s.c_str()); 214 return ret; 215 } 216 217 bool LexicalAnalyzer::ConstMacroToExpression( const ConstMacro &constMacro, const char *parameterStr, std::string& dest ) 218 { 219 int i2,i3; 218 220 char temporary[VN_SIZE]; 219 char *pParms[MAX_PARMS];220 num=0;221 std::vector<std::string> Parms; 222 dest.reserve(8192); 221 223 i2=0; 222 224 while(1){ 223 225 i2=GetOneParameter(parameterStr,i2,temporary); 224 226 225 pParms[num]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1); 226 lstrcpy(pParms[num],temporary); 227 228 num++; 227 Parms.push_back(temporary); 228 229 229 if(parameterStr[i2]=='\0') break; 230 230 } 231 if( num!= constMacro.GetParameters().size() ){231 if( Parms.size() != constMacro.GetParameters().size() ){ 232 232 extern int cp; 233 for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);234 233 compiler.errorMessenger.Output(10,constMacro.GetName().c_str(),cp); 235 lstrcpy(dest,"0");234 dest = '0'; 236 235 return true; 237 236 } 238 237 239 238 i2=0; 240 i4=0;241 239 while(1){ 242 240 … … 257 255 if( i3 == (int)constMacro.GetParameters().size() ){ 258 256 //パラメータでないとき 259 lstrcpy(dest+i4,temporary); 260 i4+=lstrlen(temporary); 257 dest += temporary; 261 258 } 262 259 else{ 263 260 //パラメータのとき 264 lstrcpy(dest+i4,pParms[i3]); 265 i4+=lstrlen(pParms[i3]); 261 dest += Parms[i3]; 266 262 } 267 263 268 264 //演算子をコピー 269 for(;;i2++ ,i4++){265 for(;;i2++){ 270 266 if( constMacro.GetExpression()[i2] == 1 ){ 271 dest [i4++]= constMacro.GetExpression()[i2++];272 dest [i4]= constMacro.GetExpression()[i2];267 dest += constMacro.GetExpression()[i2++]; 268 dest += constMacro.GetExpression()[i2]; 273 269 continue; 274 270 } 275 271 if(IsVariableTopChar( constMacro.GetExpression()[i2] )) break; 276 dest [i4]= constMacro.GetExpression()[i2];272 dest += constMacro.GetExpression()[i2]; 277 273 if( constMacro.GetExpression()[i2] == '\0' ) break; 278 274 } … … 281 277 } 282 278 283 for(i2=0;i2<num;i2++) HeapDefaultFree(pParms[i2]);284 285 279 return true; 286 280 } -
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Delegate.cpp
r750 r828 5 5 void LexicalAnalyzer::CollectDelegates( const char *source, Delegates &delegates ) 6 6 { 7 int i2;8 char temporary[VN_SIZE];9 10 7 // 名前空間管理 11 8 NamespaceScopes &namespaceScopes = compiler.GetNamespaceSupporter().GetLivingNamespaceScopes(); … … 15 12 compiler.GetNamespaceSupporter().ClearImportedNamespaces(); 16 13 17 int length = lstrlen( source ); 18 for( int i=0; i<length; i++ ) 14 for (int i=0; source[i] != '\0'; i++) 19 15 { 20 16 if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){ 21 for(i+=2,i2=0;;i2++,i++){ 22 if( IsCommandDelimitation( source[i] ) ){ 23 temporary[i2]=0; 24 break; 25 } 26 temporary[i2]=source[i]; 27 } 28 namespaceScopes.push_back( temporary ); 17 i+=2; 18 char const* p = &source[i]; 19 while (!IsCommandDelimitation(source[i])) 20 { 21 ++i; 22 } 23 namespaceScopes.push_back(std::string(p, &source[i])); 29 24 30 25 continue; … … 42 37 } 43 38 else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){ 44 for(i+=2,i2=0;;i2++,i++){45 if( IsCommandDelimitation( source[i] ) ){46 temporary[i2]=0;47 break;48 }49 temporary[i2]=source[i];50 }51 if ( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ))52 { 53 compiler.errorMessenger.Output(64, temporary,i);39 i+=2; 40 char const* p = &source[i]; 41 while (!IsCommandDelimitation(source[i])) 42 { 43 ++i; 44 } 45 std::string s(p, &source[i]); 46 if (!compiler.GetNamespaceSupporter().ImportsNamespace(s)) 47 { 48 compiler.errorMessenger.Output(64, s.c_str(), i); 54 49 } 55 50 … … 112 107 { 113 108 compiler.errorMessenger.Output(-104,name,nowLine); 114 lstrcpy( returnTypeName, "Double" );109 strcpy( returnTypeName, "Double" ); 115 110 } 116 111 } … … 127 122 Jenga::Common::SourceTemplate sourceTemplate( ActiveBasic::Common::Environment::GetAbdevSystemDirPath() + "\\templates\\delegate_class.tab" ); 128 123 129 delegates.Iterator_Reset(); 130 while( delegates.Iterator_HasNext() ) 131 { 132 const Delegate &dg = *delegates.Iterator_GetNext(); 124 foreach (auto pDelegate, delegates) 125 { 126 const Delegate &dg = *pDelegate; 133 127 134 128 if( dg.IsExternal() ) … … 263 257 void LexicalAnalyzer::RefleshDelegatesParameterAndReturnType( Delegates &delegates ) 264 258 { 265 delegates.Iterator_Reset(); 266 while( delegates.Iterator_HasNext() ) 267 { 268 Delegate &dg = *delegates.Iterator_GetNext(); 269 RefleshDelegateParameterAndReturnType( dg ); 270 } 271 } 259 foreach (auto *pDelegate, delegates) 260 { 261 RefleshDelegateParameterAndReturnType(*pDelegate); 262 } 263 } -
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_Procedure.cpp
r750 r828 913 913 914 914 if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){ 915 for(i+=2,i2=0;;i2++,i++){ 916 if( IsCommandDelimitation( source[i] ) ){ 917 temporary[i2]=0; 918 break; 919 } 920 temporary[i2]=source[i]; 921 } 922 namespaceScopes.push_back( temporary ); 915 i+=2; 916 char const* p = &source[i]; 917 while (!IsCommandDelimitation(source[i])) 918 { 919 ++i; 920 } 921 namespaceScopes.push_back(std::string(p, &source[i])); 923 922 924 923 continue; … … 936 935 } 937 936 else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){ 938 for(i+=2,i2=0;;i2++,i++){939 if( IsCommandDelimitation( source[i] ) ){940 temporary[i2]=0;941 break;942 }943 temporary[i2]=source[i];944 }945 if ( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ))946 { 947 compiler.errorMessenger.Output(64, temporary,cp);937 i+=2; 938 char const* p = &source[i]; 939 while (!IsCommandDelimitation(source[i])) 940 { 941 ++i; 942 } 943 std::string s(p, &source[i]); 944 if (!compiler.GetNamespaceSupporter().ImportsNamespace(s)) 945 { 946 compiler.errorMessenger.Output(64, s.c_str(), i); 948 947 } 949 948 -
trunk/ab5.0/abdev/BasicCompiler_Common/src/LexicalAnalyzer_TypeDef.cpp
r668 r828 1 1 #include "stdafx.h" 2 #include <abdev/ab_common/include/ab_common.h> 3 #include "LexicalAnalyzer.h" 4 #include "Compiler.h" 5 #include "StrOperation.h" 6 #include <boost/algorithm/string/predicate.hpp> 2 7 3 8 using namespace ActiveBasic::Compiler; 4 9 5 void LexicalAnalyzer::AddTypeDef( TypeDefCollection &typeDefs, const NamespaceScopes &namespaceScopes, const std::string&expression, int nowLine )10 void LexicalAnalyzer::AddTypeDef( TypeDefCollection &typeDefs, const NamespaceScopes &namespaceScopes, const boost::iterator_range<char const*> &expression, int nowLine ) 6 11 { 7 int i; 8 char temporary[VN_SIZE]; 12 auto name = boost::find<boost::return_begin_found>(expression, '='); 9 13 10 for(i=0;;i++){ 11 if(expression[i]=='='||expression[i]=='\0'){ 12 temporary[i]=0; 13 break; 14 } 15 temporary[i]=expression[i]; 16 } 17 18 if(expression[i]!='='){ 19 compiler.errorMessenger.Output(10,"TypeDef",nowLine); 14 if (boost::end(name) == boost::end(expression)) 15 { 16 compiler.errorMessenger.Output(10, "TypeDef", nowLine); 20 17 return; 21 18 } 22 19 23 const char *pTemp =expression.c_str()+i+1;20 const char *pTemp = expression.begin() + boost::size(name) + 1; 24 21 25 22 //識別文字のエラーチェック(新しい型) 26 i=0; 27 for(;;i++){ 28 if(temporary[i]=='\0') break; 29 if( !( IsVariableChar( temporary[i], true) ) ){ 30 compiler.errorMessenger.Output(10,"TypeDef",nowLine); 31 return; 32 } 23 if (!boost::algorithm::all(name, [](char c) {return IsVariableChar(c, true);})) 24 { 25 compiler.errorMessenger.Output(10, "TypeDef", nowLine); 26 return; 33 27 } 34 28 … … 41 35 } 42 36 } 43 else{ 44 i=0; 37 else 38 { 39 int i=0; 45 40 while(pTemp[i]=='*') i++; 46 for(;;i++){ 47 if(pTemp[i]=='\0') break; 48 if( !( IsVariableChar( pTemp[i], true) ) ) 49 { 50 compiler.errorMessenger.Output(10,"TypeDef",nowLine); 51 return; 52 } 41 if (!boost::algorithm::all(name, [](char c) {return IsVariableChar(c, true);})) 42 { 43 compiler.errorMessenger.Output(10,"TypeDef",nowLine); 44 return; 53 45 } 54 46 } 55 47 48 std::string baseName(pTemp, expression.end()); 49 56 50 //識別子が重複している場合はエラーにする 57 if(lstrcmp(temporary,pTemp)==0){ 51 if (boost::algorithm::equals(name, baseName)) 52 { 58 53 compiler.errorMessenger.Output(1,NULL,nowLine); 59 54 return; … … 67 62 68 63 Type baseType; 69 if( !compiler.StringToType( pTemp, baseType ) )64 if( !compiler.StringToType( baseName, baseType ) ) 70 65 { 71 compiler.errorMessenger.Output(3, pTemp, nowLine );66 compiler.errorMessenger.Output(3, baseName, nowLine ); 72 67 return; 73 68 } … … 75 70 typeDefs.push_back( 76 71 TypeDef( 77 Symbol( namespaceScopes, temporary),78 pTemp,72 Symbol(namespaceScopes, boost::copy_range<std::string>(name)), 73 baseName, 79 74 baseType 80 75 ) … … 90 85 compiler.GetNamespaceSupporter().ClearImportedNamespaces(); 91 86 92 int i=-1, i2; 93 char temporary[VN_SIZE]; 94 while(1){ 95 96 i++; 97 87 for (int i = 0; ; ++i) 88 { 98 89 if( source[i] == 1 && source[i+1] == ESC_NAMESPACE ){ 99 for(i+=2,i2=0;;i2++,i++){ 100 if( IsCommandDelimitation( source[i] ) ){ 101 temporary[i2]=0; 102 break; 103 } 104 temporary[i2]=source[i]; 90 i+=2; 91 char const* p = &source[i]; 92 while (!IsCommandDelimitation(source[i])) 93 { 94 ++i; 105 95 } 106 namespaceScopes.push_back( temporary);96 namespaceScopes.push_back(std::string(p, &source[i])); 107 97 108 98 continue; … … 120 110 } 121 111 else if( source[i] == 1 && source[i+1] == ESC_IMPORTS ){ 122 for(i+=2,i2=0;;i2++,i++){ 123 if( IsCommandDelimitation( source[i] ) ){ 124 temporary[i2]=0; 125 break; 126 } 127 temporary[i2]=source[i]; 112 i+=2; 113 char const* p = &source[i]; 114 while (!IsCommandDelimitation(source[i])) 115 { 116 ++i; 128 117 } 129 if( !compiler.GetNamespaceSupporter().ImportsNamespace( temporary ) ) 118 std::string s(p, &source[i]); 119 if (!compiler.GetNamespaceSupporter().ImportsNamespace(s)) 130 120 { 131 compiler.errorMessenger.Output(64, temporary,i);121 compiler.errorMessenger.Output(64, s.c_str(), i); 132 122 } 133 123 … … 144 134 char temporary[VN_SIZE]; 145 135 if(source[i+1]==ESC_TYPEDEF){ 146 int i2 = 0; 147 for(i+=2;;i2++,i++){ 148 if(source[i]=='\n'){ 149 temporary[i2]=0; 150 break; 151 } 152 temporary[i2]=source[i]; 153 if(source[i]=='\0') break; 136 i+=2; 137 char const* p = &source[i]; 138 while (!IsCommandDelimitation(source[i])) 139 { 140 ++i; 154 141 } 155 AddTypeDef( typeDefs, namespaceScopes, temporary, i ); 156 142 AddTypeDef(typeDefs, namespaceScopes, boost::make_iterator_range(p, &source[i]), i); 157 143 continue; 158 144 } … … 168 154 } 169 155 170 Type baseType;171 if( !compiler.StringToType( "Long", baseType ) )172 {173 throw;174 }175 176 156 typeDefs.push_back( 177 157 TypeDef( 178 158 Symbol( namespaceScopes, temporary ), 179 159 "Long", 180 baseType160 Type(DEF_LONG) 181 161 ) 182 162 ); -
trunk/ab5.0/abdev/BasicCompiler_Common/src/Linker.cpp
r750 r828 257 257 nativeCode.PutEx( masterObjectModule.globalNativeCode ); 258 258 259 masterObjectModule.meta.GetUserProcs().Iterator_Reset(); 260 while( masterObjectModule.meta.GetUserProcs().Iterator_HasNext() ) 261 { 262 const UserProc *pUserProc = masterObjectModule.meta.GetUserProcs().Iterator_GetNext(); 263 259 foreach (auto pUserProc, masterObjectModule.meta.GetUserProcs()) 260 { 264 261 if( pUserProc->GetNativeCode().GetSize() > 0 ) 265 262 { -
trunk/ab5.0/abdev/BasicCompiler_Common/src/ProcedureGenerator.cpp
r750 r828 18 18 int back_cp=cp; 19 19 20 classes.Iterator_Reset();21 while(classes.Iterator_HasNext()){22 CClass &objClass = * classes.Iterator_GetNext();20 foreach(auto pClass, classes) 21 { 22 CClass &objClass = *pClass; 23 23 if( objClass.IsExternal() ) 24 24 { … … 83 83 //////////////////////////////////////////////////////////////////// 84 84 85 // イテレータをリセット 86 classes.Iterator_Reset(); 87 88 while( classes.Iterator_HasNext() ){ 89 const CClass &objClass = *classes.Iterator_GetNext(); 85 foreach (auto pClass, classes) 86 { 87 const CClass &objClass = *pClass; 90 88 91 89 if( !objClass.IsUsing() ){ … … 152 150 ChangeOpcode( temporary ); 153 151 154 // イテレータをリセット 155 classes.Iterator_Reset(); 156 157 while( classes.Iterator_HasNext() ){ 158 const CClass &objClass = *classes.Iterator_GetNext(); 152 foreach (auto pClass, classes) 153 { 154 const CClass &objClass = *pClass; 159 155 160 156 if( !objClass.IsUsing() ){ -
trunk/ab5.0/abdev/BasicCompiler_Common/src/VtblGenerator.cpp
r750 r828 93 93 void VtblGenerator::GenerateVTablesForAllClasses( Classes &classes ) 94 94 { 95 classes.Iterator_Reset(); 96 while( classes.Iterator_HasNext() ) 95 foreach (auto pClass, classes) 97 96 { 98 CClass *pClass = classes.Iterator_GetNext();99 97 GenerateFullVTables( *pClass ); 100 98 … … 177 175 void VtblGenerator::ActionVtblScheduleForAllClasses( Classes &classes, LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection, LONG_PTR MemPos_DataSection ) 178 176 { 179 classes.Iterator_Reset(); 180 while( classes.Iterator_HasNext() ) 177 foreach(auto pClass, classes) 181 178 { 182 CClass *pClass = classes.Iterator_GetNext();183 179 ActionVtblSchedule( *pClass, ImageBase, MemPos_CodeSection, MemPos_DataSection ); 184 180
Note:
See TracChangeset
for help on using the changeset viewer.