Changeset 628 in dev for trunk/ab5.0/abdev/BasicCompiler_Common/src/Compiler.cpp
- Timestamp:
- May 29, 2008, 1:36:02 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ab5.0/abdev/BasicCompiler_Common/src/Compiler.cpp
r603 r628 14 14 } 15 15 16 bool Compiler::StringToType( const std::string &typeName, Type &type ){ 16 ActiveBasic::Compiler::Error::StringToTypeErrorCode::EnumType Compiler::StringToTypeEx( const std::string &typeName, Type &type, bool isResolveGenerics ) 17 { 17 18 type.SetIndex( -1 ); 18 19 … … 35 36 if( !pGenericClass ) 36 37 { 37 return false;38 return ActiveBasic::Compiler::Error::StringToTypeErrorCode::NotfoundGenericClass; 38 39 } 39 40 … … 70 71 type.SetActualGenericTypes( genericTypes ); 71 72 72 return true;73 return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful; 73 74 } 74 75 … … 102 103 type.SetBasicType( DEF_PTR_PROC ); 103 104 type.SetIndex( this->GetObjectModule().meta.GetProcPointers().size() - 1 ); 104 return true;105 return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful; 105 106 } 106 107 107 108 const std::string &nextTypeName = typeName.substr( 1 ); 108 109 109 if( !StringToType( nextTypeName, type ) ){ 110 return false; 110 ActiveBasic::Compiler::Error::StringToTypeErrorCode::EnumType result = StringToTypeEx( nextTypeName, type, isResolveGenerics ); 111 if( result != ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful ) 112 { 113 return result; 111 114 } 112 115 113 116 type.PtrLevelUp(); 114 117 115 return true;118 return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful; 116 119 } 117 120 118 121 { 119 122 int basicType; 120 if( Type::StringToBasicType( typeName, basicType ) ){ 123 if( Type::StringToBasicType( typeName, basicType ) ) 124 { 121 125 // 基本型だったとき 122 126 type.SetBasicType( basicType ); 123 return true;127 return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful; 124 128 } 125 129 } 126 130 127 131 // Object型だったとき 128 if( typeName == "Object" ){ 132 if( typeName == "Object" ) 133 { 129 134 type.SetType( DEF_OBJECT, this->GetObjectModule().meta.GetClasses().GetObjectClassPtr() ); 130 return true;135 return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful; 131 136 } 132 137 133 138 // String型だったとき 134 if( typeName == "String" ){ 139 if( typeName == "String" ) 140 { 135 141 type.SetType( DEF_OBJECT, this->GetObjectModule().meta.GetClasses().GetStringClassPtr() ); 136 return true;142 return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful; 137 143 } 138 144 … … 142 148 //////////////////// 143 149 int i=this->GetObjectModule().meta.GetTypeDefs().GetIndex( LexicalAnalyzer::FullNameToSymbol( typeName ) ); 144 if(i!=-1){ 150 if(i!=-1) 151 { 145 152 type = this->GetObjectModule().meta.GetTypeDefs()[i].GetBaseType(); 146 return true;153 return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful; 147 154 } 148 155 149 156 //クラス 150 157 const CClass *pobj_c = this->GetObjectModule().meta.GetClasses().FindEx( LexicalAnalyzer::FullNameToSymbol( typeName ) ); 151 if(pobj_c){ 152 if( pobj_c->IsStructure() ){ 158 if(pobj_c) 159 { 160 if( isResolveGenerics ) 161 { 162 if( pobj_c->IsGeneric() ) 163 { 164 // ジェネリッククラスの場合 165 trace( "型解決されていない" ); 166 return ActiveBasic::Compiler::Error::StringToTypeErrorCode::FailedResolveGenericType; 167 } 168 } 169 170 if( pobj_c->IsStructure() ) 171 { 153 172 type.SetBasicType( DEF_STRUCT ); 154 173 } 155 else{ 174 else 175 { 156 176 type.SetBasicType( DEF_OBJECT ); 157 177 } 158 178 type.SetClassPtr( pobj_c ); 159 return true;179 return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful; 160 180 } 161 181 … … 176 196 type.SetFormalTypeName( typeName ); 177 197 type.SetFormalTypeIndex( formalTypeIndex ); 178 return true;198 return ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful; 179 199 } 180 200 } … … 183 203 ///////////////////////////////////////////////////////// 184 204 185 return false; 205 return ActiveBasic::Compiler::Error::StringToTypeErrorCode::NotfoundType; 206 } 207 208 bool Compiler::StringToType( const std::string &typeName, Type &type ) 209 { 210 return ( StringToTypeEx( typeName, type, false ) == ActiveBasic::Compiler::Error::StringToTypeErrorCode::Successful ); 186 211 } 187 212
Note:
See TracChangeset
for help on using the changeset viewer.