Changeset 422 in dev
- Timestamp:
- Mar 8, 2008, 10:38:39 PM (17 years ago)
- Location:
- trunk/abdev
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/abdev/BasicCompiler32/MakePeHdr.cpp
r415 r422 178 178 //TypeDef情報を初期化 179 179 compiler.GetObjectModule().meta.GetTypeDefs().CollectTypeDefs(); 180 181 /* 182 デリゲートのパラメータを再取得 183 クラス/TypeDefなどの型名前情報がすべて揃ってからでないと 184 型情報に依存するパラメータ情報を取得できないため、ここでの再取得が必要 185 */ 186 compiler.GetObjectModule().meta.GetDelegates().RefleshParameterAndReturnType(); 180 187 181 188 //定数情報を取得 -
trunk/abdev/BasicCompiler_Common/include/Delegate.h
r339 r422 4 4 #include <Procedure.h> 5 5 6 class Delegate : public Procedure, public Jenga::Common::ObjectInHashmap<Delegate> 6 class Delegates; 7 8 class Delegate 9 : public Procedure 10 , public Jenga::Common::ObjectInHashmap<Delegate> 7 11 { 12 friend Delegates; 13 14 std::string paramStr; 15 std::string returnTypeName; 16 int sourceIndex; 17 8 18 Parameters dynamicParams; 9 19 20 // XMLシリアライズ用 21 private: 22 friend class boost::serialization::access; 23 template<class Archive> void serialize(Archive& ar, const unsigned int version) 24 { 25 trace_for_serialize( "serializing - Delegate" ); 26 27 ar & BOOST_SERIALIZATION_BASE_OBJECT_NVP( Procedure ); 28 ar & BOOST_SERIALIZATION_NVP( dynamicParams ); 29 } 30 10 31 public: 11 Delegate( const NamespaceScopes &namespaceScopes, const std::string &name, Procedure::Kind procKind, const char *paramStr, const Type &returnType, int nowLine ); 32 Delegate( const NamespaceScopes &namespaceScopes, const std::string &name, Procedure::Kind procKind, const char *paramStr, const std::string &returnTypeName, int sourceIndex ) 33 : Procedure( namespaceScopes, name, procKind, false ) 34 , paramStr( paramStr ) 35 , returnTypeName( returnTypeName ) 36 , sourceIndex( sourceIndex ) 37 { 38 } 12 39 Delegate() 13 40 { 14 41 } 42 43 void RefleshParameterAndReturnType(); 15 44 16 45 virtual const std::string &GetKeyName() const … … 30 59 void Collect( const BasicSource &source ); 31 60 void GenerateSourceCode( std::string &destSource ); 61 void RefleshParameterAndReturnType(); 32 62 }; -
trunk/abdev/BasicCompiler_Common/src/Delegate.cpp
r339 r422 3 3 #include <Delegate.h> 4 4 5 Delegate::Delegate( const NamespaceScopes &namespaceScopes, const std::string &name, Procedure::Kind procKind, const char *paramStr, const Type &returnType, int nowLine)6 : Procedure( namespaceScopes, name, procKind, false ) 7 { 8 this->returnType = returnType;9 params.Analyze( paramStr, nowLine ); 10 5 void Delegate::RefleshParameterAndReturnType() 6 { 7 // パラメータを解析 8 params.Analyze( paramStr.c_str(), sourceIndex ); 9 10 // 動的パラメータを作る 11 11 dynamicParams = params; 12 12 dynamicParams.insert( dynamicParams.begin(), new Parameter( "_System_LocalThis", Type( DEF_PTR_VOID ) ) ); 13 14 if( IsFunction() ) 15 { 16 // 戻り値を取得 17 if( !compiler.StringToType( returnTypeName, returnType ) ) 18 { 19 SetError(3,returnTypeName,sourceIndex); 20 } 21 } 13 22 } 14 23 … … 93 102 GetIdentifierToken( name, source.GetBuffer(), i ); 94 103 104 if( source[i] != '(' ) 105 { 106 SetError(1,NULL,nowLine); 107 continue; 108 } 109 110 // パラメータ文字列 95 111 char paramStr[8192]; 96 i += GetStringInPare( paramStr, source.GetBuffer() + i );97 98 // 戻り値 99 Type returnType;112 i += GetStringInPare( paramStr, source.GetBuffer() + i, true ); 113 114 // 戻り値の型の文字列 115 char returnTypeName[VN_SIZE] = ""; 100 116 if( source[i] == 1 && source[i+1] == ESC_AS ) 101 117 { 102 118 i += 2; 103 char typeName[VN_SIZE]; 104 GetCommandToken( typeName, source.GetBuffer(), i ); 105 compiler.StringToType( typeName, returnType ); 106 } 107 108 this->Put( new Delegate( namespaceScopes, name, procKind, paramStr, returnType, nowLine ) ); 119 GetCommandToken( returnTypeName, source.GetBuffer(), i ); 120 121 if( procKind != Procedure::Function ) 122 { 123 SetError(38,name,nowLine); 124 } 125 } 126 else 127 { 128 if( procKind == Procedure::Function ) 129 { 130 SetError(-104,name,nowLine); 131 lstrcpy( returnTypeName, "Double" ); 132 } 133 } 134 135 this->Put( new Delegate( namespaceScopes, name, procKind, paramStr, returnTypeName, nowLine ) ); 109 136 } 110 137 } … … 156 183 values.insert( std::map<std::string,std::string>::value_type( "#name#", dg.GetName() ) ); 157 184 158 std::string paramsStr = dg.Params().GetString();159 160 185 if( dg.IsFunction() ) 161 186 { 162 187 values.insert( std::map<std::string,std::string>::value_type( 163 188 "#call_method_begin#", 164 (string)"Function Call(" + paramsStr + ") As " + compiler.TypeToString( dg.ReturnType() )189 (string)"Function Call(" + dg.paramStr + ") As " + dg.returnTypeName 165 190 ) ); 166 191 … … 176 201 values.insert( std::map<std::string,std::string>::value_type( 177 202 "#call_method_begin#", 178 (string)"Sub Call(" + paramsStr + ")"203 (string)"Sub Call(" + dg.paramStr + ")" 179 204 ) ); 180 205 … … 187 212 } 188 213 189 values.insert( std::map<std::string,std::string>::value_type( "#params#", paramsStr ) );214 values.insert( std::map<std::string,std::string>::value_type( "#params#", dg.paramStr ) ); 190 215 191 216 destSource += sourceTemplate.GetResult( values ); … … 197 222 */ 198 223 } 224 225 void Delegates::RefleshParameterAndReturnType() 226 { 227 this->Iterator_Reset(); 228 while( this->Iterator_HasNext() ) 229 { 230 Delegate &dg = *this->Iterator_GetNext(); 231 dg.RefleshParameterAndReturnType(); 232 } 233 } -
trunk/abdev/BasicCompiler_Common/src/Parameter.cpp
r383 r422 85 85 //パラメータ 86 86 int i = 0; 87 if(sourceOfParams[i]!='('){88 SetError(1,NULL,nowLine);89 return 0;90 }91 i++;92 87 while(1){ 93 if(sourceOfParams[i]==')') break; 88 if( sourceOfParams[i] == '\0' ) 89 { 90 break; 91 } 94 92 95 93 //ByRef … … 222 220 this->push_back( pParam ); 223 221 224 if(sourceOfParams[i]==','){ 222 if( sourceOfParams[i] == ',' ) 223 { 225 224 i++; 226 225 continue; 227 226 } 228 else if(sourceOfParams[i]==')') continue; 227 else if( sourceOfParams[i] == '\0' ) 228 { 229 break; 230 } 229 231 else{ 230 232 SetError(1,NULL,nowLine);
Note:
See TracChangeset
for help on using the changeset viewer.