Changeset 181 in dev
- Timestamp:
- Jun 24, 2007, 2:05:40 PM (17 years ago)
- Location:
- trunk/jenga
- Files:
-
- 1 deleted
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/jenga/include/smoothie/Class.h
r180 r181 46 46 }; 47 47 48 pr ivate:48 protected: 49 49 ClassType classType; 50 50 51 51 bool isReady; 52 void Readed(){53 isReady = true;54 }55 bool IsReady() const{56 return isReady;57 }58 52 59 53 // importされている名前空間 … … 90 84 CClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name ); 91 85 ~CClass(); 86 87 void Readed(){ 88 isReady = true; 89 } 90 bool IsReady() const{ 91 return isReady; 92 } 92 93 93 94 const NamespaceScopesCollection &GetImportedNamespaces() const … … 126 127 } 127 128 128 //継承させる 129 bool Inherits( const char *inheritNames, int nowLine ); 130 bool InheritsClass( const CClass &inheritsClass, int nowLine ); 131 bool InheritsInterface( const CClass &inheritsClass, int nowLine ); 132 133 //メンバ、メソッドの追加 134 void AddMember( Prototype::Accessibility accessibility, bool idConst, bool isRef, char *buffer ); 135 void AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ); 129 // 継承させる 130 virtual bool Inherits( const char *inheritNames, int nowLine ) = 0; 131 virtual bool InheritsClass( const CClass &inheritsClass, int nowLine ) = 0; 132 virtual bool InheritsInterface( const CClass &inheritsClass, int nowLine ) = 0; 133 134 virtual void AddMember( Prototype::Accessibility accessibility, bool idConst, bool isRef, char *buffer, int nowLine ) = 0; 135 virtual void AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ) = 0; 136 137 virtual void AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract, 138 bool isVirtual, bool isOverride, char *buffer, int nowLine) = 0; 136 139 137 140 //重複チェック … … 173 176 } 174 177 175 //デフォルト コンストラクタ メソッドを取得178 //デフォルト コンストラクタ 176 179 const CMethod *GetConstructorMethod() const; 180 void SetConstructorMemberSubIndex( int constructorMemberSubIndex ) 181 { 182 this->ConstructorMemberSubIndex = constructorMemberSubIndex; 183 } 177 184 178 185 //デストラクタ メソッドを取得 179 186 const CMethod *GetDestructorMethod() const; 187 void SetDestructorMemberSubIndex( int destructorMemberSubIndex ) 188 { 189 this->DestructorMemberSubIndex = destructorMemberSubIndex; 190 } 180 191 181 192 // vtblに存在する仮想関数の数 … … 209 220 210 221 //vtbl 211 pr ivate:222 protected: 212 223 mutable long vtbl_offset; 213 224 public: 214 225 int GetFuncNumInVtbl( const UserProc *pUserProc ) const; 215 LONG_PTR GetVtblGlobalOffset(void) const;216 v oid ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection);226 virtual LONG_PTR GetVtblGlobalOffset(void) const = 0; 227 virtual void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection) = 0; 217 228 bool IsAbstract() const; 218 229 … … 306 317 const CClass *Find( const NamespaceScopes &namespaceScopes, const string &name ) const; 307 318 308 CClass *AddClass( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine); 319 virtual CClass *Create( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name) = 0; 320 CClass *Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine); 309 321 310 322 void ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection); 311 323 312 private:313 void AddMethod(CClass *pobj_c, Prototype::Accessibility accessibility, BOOL bStatic, bool isConst, bool isAbstract,314 bool isVirtual, bool isOverride, char *buffer, int nowLine);315 BOOL MemberVar_LoopRefCheck(const CClass &objClass);316 324 public: 317 325 318 326 // 実体収集 319 327 virtual void CollectClassesForNameOnly( const BasicSource &source ) = 0; 328 virtual void GetClass_recur(const char *lpszInheritsClass) = 0; 320 329 virtual void GetAllClassInfo() = 0; 321 330 virtual void Compile_System_InitializeUserTypes() = 0; -
trunk/jenga/include/smoothie/LexicalScoping.h
r174 r181 44 44 int level; 45 45 46 CScope *SearchScope( SCOPE_TYPE TypeOfStatement );47 48 46 virtual CScope *CreateScope( int level, int addr, SCOPE_TYPE TypeOfStatement ) = 0; 49 47 public: … … 57 55 void Start( int addr, SCOPE_TYPE TypeOfStatement ); 58 56 59 // スコープを終了57 // スコープを終了 60 58 void End(); 61 59 62 // スコープ抜け出しステートメント63 void Break();60 // スコープを検索 61 CScope *SearchScope( SCOPE_TYPE TypeOfStatement ); 64 62 65 63 int GetNowLevel(void); -
trunk/jenga/include/smoothie/Member.h
r180 r181 53 53 } 54 54 55 CMember( Prototype::Accessibility accessibility, const string &name, const Type &type, bool isConst )55 CMember( Prototype::Accessibility accessibility, const string &name, const Type &type, bool isConst, const string &initializeExpression, const string &constructParameter ) 56 56 : MemberPrototype( accessibility ) 57 57 , name( name ) 58 58 , type( type ) 59 59 , isConst( isConst ) 60 , initializeExpression( initializeExpression ) 61 , constructParameter( constructParameter ) 60 62 { 61 63 } -
trunk/jenga/include/smoothie/ObjectModule.h
r180 r181 9 9 class Meta{ 10 10 Classes *pClasses; 11 ProcPointers *pProcPointers; 11 12 public: 12 13 13 Meta( Classes *pNewClasses )14 Meta( Classes *pNewClasses, ProcPointers *pNewProcPointers ) 14 15 : pClasses( pNewClasses ) 16 , pProcPointers( pNewProcPointers ) 15 17 { 16 18 } … … 18 20 { 19 21 delete pClasses; 22 delete pProcPointers; 20 23 } 21 24 … … 28 31 return *pClasses; 29 32 } 33 void SetClasses( Classes *pClasses ) 34 { 35 this->pClasses = pClasses; 36 } 30 37 31 38 // TypeDef … … 33 40 34 41 // 関数ポインタ 35 vector<ProcPointer *> procPointers; 42 ProcPointers &GetProcPointers() 43 { 44 return *pProcPointers; 45 } 36 46 37 47 // blittable型 -
trunk/jenga/include/smoothie/Parameter.h
r170 r181 1 1 #pragma once 2 2 3 #include <string> 4 #include <vector> 5 3 6 #include "Type.h" 4 5 7 #include "BasicFixed.h" 6 8 7 9 class Parameter : public Type 8 10 { 9 st ring varName;11 std::string varName; 10 12 bool isRef; 11 13 bool isArray; 12 14 int subScripts[MAX_ARRAYDIM]; 13 15 14 const st ring initValue;16 const std::string initValue; 15 17 16 18 public: 17 Parameter( const st ring &varName, const Type &type, bool isRef = false, conststring initValue = "" ):19 Parameter( const std::string &varName, const Type &type, bool isRef = false, const std::string initValue = "" ): 18 20 Type( type ), 19 21 varName( varName ), … … 43 45 } 44 46 45 const st ring &GetVarName() const47 const std::string &GetVarName() const 46 48 { 47 49 return varName; … … 59 61 } 60 62 61 const st ring &GetInitValue() const63 const std::string &GetInitValue() const 62 64 { 63 65 return initValue; … … 89 91 }; 90 92 91 class Parameters : public vector<Parameter *>93 class Parameters : public std::vector<Parameter *> 92 94 { 93 95 public: -
trunk/jenga/include/smoothie/Procedure.h
r170 r181 94 94 string _paramStr; 95 95 96 pr ivate:96 protected: 97 97 bool isMacro; 98 98 … … 113 113 114 114 public: 115 116 void Serialize( bool isRead ) 117 { 118 119 } 115 120 116 121 UserProc( const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport ): … … 127 132 { 128 133 } 129 ~UserProc(); 134 ~UserProc() 135 { 136 BOOST_FOREACH( Parameter *pParam, realParams ){ 137 delete pParam; 138 } 139 } 130 140 131 141 string GetFullName() const; … … 136 146 } 137 147 138 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ) ;148 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ) = 0; 139 149 140 150 int GetSecondParmNum() const … … 246 256 return *pCompilingUserProc; 247 257 } 248 };249 250 class GlobalProc : public UserProc251 {252 const NamespaceScopes namespaceScopes;253 const NamespaceScopesCollection importedNamespaces;254 public:255 // ハッシュリスト用256 GlobalProc *pNextData;257 258 GlobalProc( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const string &name, Kind kind, bool isMacro, bool isCdecl, bool isExport ):259 UserProc( name, kind, isMacro, isCdecl, isExport ),260 namespaceScopes( namespaceScopes ),261 importedNamespaces( importedNamespaces ),262 pNextData( NULL )263 {}264 ~GlobalProc(){}265 /*266 GlobalProc *Create( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine );267 bool AddGlobalProc( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine );268 */269 virtual const NamespaceScopes &GetNamespaceScopes() const;270 virtual const NamespaceScopesCollection &GetImportedNamespaces() const271 {272 return importedNamespaces;273 }274 275 virtual bool IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const;276 virtual bool IsEqualSymbol( const GlobalProc &globalProc ) const;277 virtual bool IsEqualSymbol( const string &name ) const;278 258 }; 279 259 … … 309 289 } 310 290 311 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine ) ;291 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine ) = 0; 312 292 313 293 const string &GetDllFileName() const … … 339 319 ~ProcPointer(){} 340 320 341 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine ); 342 }; 321 virtual bool SetParamsAndReturnType( const char *sourceOfParams, int nowLine ) = 0; 322 }; 323 class ProcPointers : public vector<ProcPointer *> 324 { 325 public: 326 ProcPointers() 327 { 328 } 329 ~ProcPointers() 330 { 331 } 332 333 virtual int Add( const string &typeExpression ) = 0; 334 }; -
trunk/jenga/include/smoothie/Smoothie.h
r174 r181 6 6 7 7 class Smoothie{ 8 static bool isUnicode; 9 10 static Meta meta; 8 11 public: 12 13 static bool IsUnicode() 14 { 15 return isUnicode; 16 } 17 static void SetUnicodeMark( bool isUnicode ) 18 { 19 Smoothie::isUnicode = isUnicode; 20 } 21 22 static Meta &GetMeta() 23 { 24 return meta; 25 } 9 26 10 27 class Lexical{ … … 12 29 static string baseProjectDirPath; 13 30 static BasicSource source; 14 static NamespaceScopes liveingNamespaceScopes;15 31 }; 16 32 … … 18 34 class Temp{ 19 35 public: 36 // 現在の名前空間 37 static NamespaceScopes liveingNamespaceScopes; 38 20 39 // 現在インポートされている名前空間 21 40 static NamespaceScopesCollection importedNamespaces; … … 28 47 }; 29 48 30 // プロジェクト中に存在するメタ情報31 static Meta meta;32 33 49 static bool isFullCompile; 34 50 }; -
trunk/jenga/include/smoothie/SmoothieException.h
r172 r181 14 14 , keyword( keyword ) 15 15 , nowLine( nowLine ) 16 { 17 } 18 SmoothieException( int errorCode, const std::string &keyword ) 19 : errorCode( errorCode ) 20 , keyword( keyword ) 21 , nowLine( -1 ) 16 22 { 17 23 } -
trunk/jenga/projects/common/common.vcproj
r170 r181 42 42 AdditionalIncludeDirectories="..\..\..\;..\..\..\cpplibs\boost" 43 43 MinimalRebuild="true" 44 BasicRuntimeChecks=" 3"44 BasicRuntimeChecks="0" 45 45 RuntimeLibrary="1" 46 46 WarningLevel="3" … … 102 102 <Tool 103 103 Name="VCCLCompilerTool" 104 InlineFunctionExpansion="2" 105 EnableIntrinsicFunctions="true" 106 FavorSizeOrSpeed="1" 104 107 AdditionalIncludeDirectories="..\..\..\;..\..\..\cpplibs\boost" 105 108 RuntimeLibrary="0" -
trunk/jenga/projects/smoothie/smoothie.vcproj
r174 r181 42 42 AdditionalIncludeDirectories="..\..\..\;..\..\..\cpplibs\boost" 43 43 MinimalRebuild="true" 44 BasicRuntimeChecks=" 3"44 BasicRuntimeChecks="0" 45 45 RuntimeLibrary="1" 46 46 WarningLevel="3" … … 102 102 <Tool 103 103 Name="VCCLCompilerTool" 104 InlineFunctionExpansion="2" 105 EnableIntrinsicFunctions="true" 106 FavorSizeOrSpeed="1" 104 107 AdditionalIncludeDirectories="..\..\..\;..\..\..\cpplibs\boost" 105 108 RuntimeLibrary="0" … … 225 228 MinimalRebuild="true" 226 229 BasicRuntimeChecks="3" 227 RuntimeLibrary=" 3"230 RuntimeLibrary="1" 228 231 WarningLevel="3" 229 232 Detect64BitPortabilityProblems="true" -
trunk/jenga/src/smoothie/Class.cpp
r180 r181 4 4 #include <jenga/include/smoothie/Class.h> 5 5 #include <jenga/include/smoothie/SmoothieException.h> 6 7 8 class CLoopRefCheck{9 char **names;10 int num;11 void init(){12 int i;13 for(i=0;i<num;i++){14 free(names[i]);15 }16 free(names);17 }18 public:19 CLoopRefCheck()20 {21 names=(char **)malloc(1);22 num=0;23 }24 ~CLoopRefCheck()25 {26 init();27 }28 void add(const char *lpszInheritsClass)29 {30 names=(char **)realloc(names,(num+1)*sizeof(char *));31 names[num]=(char *)malloc(lstrlen(lpszInheritsClass)+1);32 lstrcpy(names[num],lpszInheritsClass);33 num++;34 }35 void del(const char *lpszInheritsClass)36 {37 int i;38 for(i=0;i<num;i++){39 if(lstrcmp(names[i],lpszInheritsClass)==0){40 free(names[i]);41 break;42 }43 }44 if(i!=num){45 num--;46 for(;i<num;i++){47 names[i]=names[i+1];48 }49 }50 }51 BOOL check(const CClass &inheritsClass) const52 {53 //ループ継承チェック54 int i;55 for(i=0;i<num;i++){56 if( inheritsClass.GetName() == names[i] ){57 return 1;58 }59 }60 return 0;61 }62 };63 CLoopRefCheck *pobj_LoopRefCheck;64 65 66 6 67 7 … … 125 65 } 126 66 127 bool CClass::Inherits( const char *inheritNames, int nowLine ){128 int i = 0;129 bool isInheritsClass = false;130 while( true ){131 132 char temporary[VN_SIZE];133 for( int i2=0;; i++, i2++ ){134 if( inheritNames[i] == '\0' || inheritNames[i] == ',' ){135 temporary[i2] = 0;136 break;137 }138 temporary[i2] = inheritNames[i];139 }140 141 //継承元クラスを取得142 const CClass *pInheritsClass = Smoothie::meta.GetClasses().Find(temporary);143 if( !pInheritsClass ){144 throw SmoothieException(106,temporary,nowLine);145 return false;146 }147 148 if( pInheritsClass->IsInterface() ){149 // インターフェイスはあとで継承する150 }151 else if( pInheritsClass->IsClass() ){152 // クラスを継承する153 isInheritsClass = true;154 155 if( !InheritsClass( *pInheritsClass, nowLine ) ){156 return false;157 }158 }159 else{160 throw SmoothieException(135,NULL,nowLine);161 return false;162 }163 164 if( inheritNames[i] == '\0' ){165 break;166 }167 i++;168 }169 170 if( !isInheritsClass ){171 // クラスを一つも継承していないとき172 const CClass *pObjectClass = Smoothie::meta.GetClasses().Find("Object");173 if( !pObjectClass ){174 throw SmoothieException(106,"Object",i);175 return false;176 }177 178 if( !InheritsClass( *pObjectClass, nowLine ) ){179 return false;180 }181 }182 183 i=0;184 while( true ){185 186 char temporary[VN_SIZE];187 for( int i2=0;; i++, i2++ ){188 if( inheritNames[i] == '\0' || inheritNames[i] == ',' ){189 temporary[i2] = 0;190 break;191 }192 temporary[i2] = inheritNames[i];193 }194 195 //継承元クラスを取得196 const CClass *pInheritsClass = Smoothie::meta.GetClasses().Find(temporary);197 if( !pInheritsClass ){198 throw SmoothieException(106,temporary,nowLine);199 return false;200 }201 202 if( pInheritsClass->IsInterface() ){203 // インターフェイスを継承する204 if( !InheritsInterface( *pInheritsClass, nowLine ) ){205 return false;206 }207 }208 else if( pInheritsClass->IsClass() ){209 // クラスはさっき継承した210 }211 else{212 throw SmoothieException(135,NULL,nowLine);213 return false;214 }215 216 if( inheritNames[i] == '\0' ){217 break;218 }219 i++;220 }221 222 return true;223 }224 /*225 bool CClass::InheritsClass( const CClass &inheritsClass, int nowLine ){226 227 //ループ継承でないかをチェック228 if(pobj_LoopRefCheck->check(inheritsClass)){229 throw SmoothieException(123,inheritsClass.GetName(),nowLine);230 return false;231 }232 233 if( !inheritsClass.IsReady() ){234 //継承先が読み取られていないとき235 pobj_LoopRefCheck->add(this->GetName().c_str());236 Smoothie::meta.GetClasses().GetClass_recur(inheritsClass.GetName().c_str());237 pobj_LoopRefCheck->del(this->GetName().c_str());238 }239 240 //メンバをコピー241 BOOST_FOREACH( CMember *inheritsClassDynamicMember, inheritsClass.dynamicMembers ){242 CMember *pMember = new CMember( *inheritsClassDynamicMember );243 244 // アクセシビリティ245 if( inheritsClassDynamicMember->IsPrivate() ){246 pMember->SetAccessibility( Prototype::None );247 }248 else{249 pMember->SetAccessibility( inheritsClassDynamicMember->GetAccessibility() );250 }251 252 dynamicMembers.push_back( pMember );253 }254 255 //メソッドをコピー256 BOOST_FOREACH( const CMethod *pBaseMethod, inheritsClass.methods ){257 CMethod *pMethod = new DynamicMethod( *pBaseMethod );258 259 // アクセシビリティ260 if(pBaseMethod->GetAccessibility() == Prototype::Private){261 pMethod->SetAccessibility( Prototype::None );262 }263 else{264 pMethod->SetAccessibility( pBaseMethod->GetAccessibility() );265 }266 267 //pobj_Inherits268 // ※継承元のClassIndexをセット(入れ子継承を考慮する)269 if(pBaseMethod->GetInheritsClassPtr()==0){270 pMethod->SetInheritsClassPtr( &inheritsClass );271 }272 else{273 pMethod->SetInheritsClassPtr( pBaseMethod->GetInheritsClassPtr() );274 }275 276 methods.push_back( pMethod );277 }278 279 //仮想関数の数280 AddVtblNum( inheritsClass.GetVtblNum() );281 282 //継承先のクラスをメンバとして保持する283 pobj_InheritsClass = &inheritsClass;284 285 return true;286 }287 bool CClass::InheritsInterface( const CClass &inheritsInterface, int nowLine ){288 289 //ループ継承でないかをチェック290 if(pobj_LoopRefCheck->check(inheritsInterface)){291 throw SmoothieException(123,inheritsInterface.GetName(),nowLine);292 return false;293 }294 295 if( !inheritsInterface.IsReady() ){296 //継承先が読み取られていないとき297 pobj_LoopRefCheck->add(this->GetName().c_str());298 Smoothie::meta.GetClasses().GetClass_recur(inheritsInterface.GetName().c_str());299 pobj_LoopRefCheck->del(this->GetName().c_str());300 }301 302 //メソッドをコピー303 BOOST_FOREACH( const CMethod *pBaseMethod, inheritsInterface.methods ){304 CMethod *pMethod = new DynamicMethod( *pBaseMethod );305 306 // アクセシビリティ307 if(pBaseMethod->GetAccessibility() == Prototype::Private){308 pMethod->SetAccessibility( Prototype::None );309 }310 else{311 pMethod->SetAccessibility( pBaseMethod->GetAccessibility() );312 }313 314 //pobj_Inherits315 // ※継承元のClassIndexをセット(入れ子継承を考慮する)316 if(pBaseMethod->GetInheritsClassPtr()==0){317 pMethod->SetInheritsClassPtr( &inheritsInterface );318 }319 else{320 pMethod->SetInheritsClassPtr( pBaseMethod->GetInheritsClassPtr() );321 }322 323 methods.push_back( pMethod );324 }325 326 interfaces.push_back( InheritedInterface( const_cast<CClass *>(&inheritsInterface), vtblNum ) );327 328 //仮想関数の数329 AddVtblNum( inheritsInterface.GetVtblNum() );330 331 return true;332 }333 void CClass::AddMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer ){334 CMember *pMember = new CMember( this, accessibility, isConst, isRef, buffer );335 dynamicMembers.push_back( pMember );336 }337 void CClass::AddStaticMember( Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine ){338 CMember *pMember = new CMember( this, accessibility, isConst, isRef, buffer, nowLine );339 staticMembers.push_back( pMember );340 }*/341 67 BOOL CClass::DupliCheckAll(const char *name){ 342 68 //重複チェック … … 505 231 return n; 506 232 } 507 /* 508 LONG_PTR CClass::GetVtblGlobalOffset(void) const 509 { 510 511 //既に存在する場合はそれを返す 512 if(vtbl_offset!=-1) return vtbl_offset; 513 514 515 516 ////////////////////////////////////// 517 // 存在しないときは新たに生成する 518 ////////////////////////////////////// 519 520 UserProc **ppsi; 521 ppsi=(UserProc **)malloc(GetVtblNum()*sizeof(GlobalProc *)); 522 523 //関数テーブルに値をセット 524 int i2 = 0; 525 BOOST_FOREACH( const CMethod *pMethod, methods ){ 526 if(pMethod->IsVirtual()){ 527 pMethod->pUserProc->Using(); 528 529 if(pMethod->IsAbstract()){ 530 extern int cp; 531 throw SmoothieException(300,NULL,cp); 532 533 ppsi[i2]=0; 534 } 535 else{ 536 ppsi[i2]=pMethod->pUserProc; 537 } 538 i2++; 539 } 540 } 541 542 vtbl_offset=dataTable.AddBinary((void *)ppsi,GetVtblNum()*sizeof(LONG_PTR)); 543 544 for( int i=0; i < GetVtblNum(); i++ ){ 545 pobj_Reloc->AddSchedule_DataSection(vtbl_offset+i*sizeof(LONG_PTR)); 546 } 547 548 free(ppsi); 549 550 return vtbl_offset; 551 } 552 void CClass::ActionVtblSchedule(LONG_PTR ImageBase, LONG_PTR MemPos_CodeSection){ 553 if(vtbl_offset==-1) return; 554 555 LONG_PTR *pVtbl; 556 pVtbl=(LONG_PTR *)((char *)dataTable.GetPtr()+vtbl_offset); 557 558 int i; 559 for(i=0;i<GetVtblNum();i++){ 560 GlobalProc *pUserProc; 561 pUserProc=(GlobalProc *)pVtbl[i]; 562 if(!pUserProc) continue; 563 pVtbl[i]=pUserProc->beginOpAddress+ImageBase+MemPos_CodeSection; 564 } 565 }*/ 233 566 234 bool CClass::IsAbstract() const 567 235 { … … 669 337 iIteNextNum( 0 ) 670 338 { 339 memset( pobj_ClassHash, 0, MAX_CLASS_HASH * sizeof(CClass *) ); 671 340 Clear(); 672 341 } … … 681 350 } 682 351 683 if(ppobj_IteClass) free(ppobj_IteClass); 352 if(ppobj_IteClass) 353 { 354 free(ppobj_IteClass); 355 ppobj_IteClass = NULL; 356 } 684 357 memset( pobj_ClassHash, 0, MAX_CLASS_HASH * sizeof(CClass *) ); 685 358 } … … 728 401 729 402 // TypeDefも見る 730 int index = Smoothie:: meta.typeDefs.GetIndex( namespaceScopes, name );403 int index = Smoothie::GetMeta().typeDefs.GetIndex( namespaceScopes, name ); 731 404 if( index != -1 ){ 732 Type type = Smoothie:: meta.typeDefs[index].GetBaseType();405 Type type = Smoothie::GetMeta().typeDefs[index].GetBaseType(); 733 406 if( type.IsObject() ){ 734 407 return &type.GetClass(); … … 747 420 } 748 421 749 CClass *Classes::Add Class( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine){422 CClass *Classes::Add( const NamespaceScopes &namespaceScopes, const NamespaceScopesCollection &importedNamespaces, const char *name,int nowLine){ 750 423 ////////////////////////////////////////////////////////////////////////// 751 424 // クラスを追加 … … 753 426 ////////////////////////////////////////////////////////////////////////// 754 427 755 CClass *pobj_c; 756 pobj_c=new CClass(namespaceScopes, importedNamespaces, name); 428 CClass *pobj_c = Create(namespaceScopes, importedNamespaces, name); 757 429 758 430 if(lstrcmp(name,"String")==0){ -
trunk/jenga/src/smoothie/Namespace.cpp
r173 r181 37 37 bool NamespaceScopes::IsLiving() const 38 38 { 39 if( IsBelong( *this, Smoothie:: Lexical::liveingNamespaceScopes ) ){39 if( IsBelong( *this, Smoothie::Temp::liveingNamespaceScopes ) ){ 40 40 return true; 41 41 } … … 57 57 string thisStr = ToString(); 58 58 59 NamespaceScopes tempLivingNamespaceScopes = Smoothie:: Lexical::liveingNamespaceScopes;59 NamespaceScopes tempLivingNamespaceScopes = Smoothie::Temp::liveingNamespaceScopes; 60 60 61 61 while( tempLivingNamespaceScopes.size() ){ … … 106 106 bool NamespaceScopesCollection::Imports( const string &namespaceStr ){ 107 107 NamespaceScopes namespaceScopes( namespaceStr ); 108 if( !Smoothie:: meta.namespaceScopesCollection.IsExist( namespaceScopes ) ){108 if( !Smoothie::GetMeta().namespaceScopesCollection.IsExist( namespaceScopes ) ){ 109 109 return false; 110 110 } -
trunk/jenga/src/smoothie/Procedure.cpp
r173 r181 10 10 return GetName(); 11 11 } 12 /*13 bool UserProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine, bool isStatic ){14 int i = 0;15 int i2,i3,sw;16 char temporary[8192],temp2[VN_SIZE];17 18 //ソースコードの位置19 this->codePos = nowLine;20 21 //パラメータ22 if(sourceOfParams[i]!='('){23 throw SmoothieException(1,NULL,nowLine);24 return 0;25 }26 i++;27 if(sourceOfParams[i]!=')'&& this->pParentClass ){28 //クラスのメンバ関数の場合のみ、デストラクタにパラメータがある場合にエラーをだす29 if(this->GetName()[0]=='~'){30 throw SmoothieException(114,NULL,nowLine);31 i=JumpStringInPare(sourceOfParams,i);32 }33 }34 while(1){35 if(sourceOfParams[i]==')') break;36 37 //ByRef38 bool isRef;39 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){40 isRef = false;41 i+=2;42 }43 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){44 isRef = true;45 i+=2;46 }47 else isRef = false;48 49 //パラメータ名50 bool isArray = false;51 int subScripts[MAX_ARRAYDIM];52 char name[VN_SIZE];53 sw=0;54 for(i2=0;;i++,i2++){55 if(sourceOfParams[i]=='('){56 if(!sw) sw=1;57 58 i3=GetStringInPare(name+i2,sourceOfParams+i);59 i2+=i3-1;60 i+=i3-1;61 continue;62 }63 if(sourceOfParams[i]=='['){64 if(!sw) sw=1;65 66 i3=GetStringInBracket(name+i2,sourceOfParams+i);67 i2+=i3-1;68 i+=i3-1;69 continue;70 }71 if(!IsVariableChar(sourceOfParams[i])){72 name[i2]=0;73 break;74 }75 name[i2]=sourceOfParams[i];76 }77 if(sw){78 //配列パラメータ79 if( isRef == false ) throw SmoothieException(29,NULL,nowLine);80 isArray = true;81 82 if((name[i2-2]=='('&&name[i2-1]==')')||83 (name[i2-2]=='['&&name[i2-1]==']')){84 subScripts[0]=LONG_MAX;85 subScripts[1]=-1;86 87 name[i2-2]=0;88 }89 else{90 GetArrange(name,temp2,subScripts);91 lstrcpy(name,temp2);92 }93 94 i2=lstrlen(name);95 }96 97 Type type( DEF_NON );98 char initValue[8192] = "";99 if( sourceOfParams[i] == '=' ){100 i++;101 i = GetOneParameter( sourceOfParams, i, initValue );102 103 //エラー用104 cp = nowLine;105 106 NumOpe_GetType( initValue, Type::String(), type );107 }108 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){109 // As指定110 i+=2;111 112 i2=0;113 while(sourceOfParams[i]=='*'){114 temporary[i2]=sourceOfParams[i];115 i++;116 i2++;117 }118 for(;;i++,i2++){119 if(!IsVariableChar(sourceOfParams[i])){120 if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){121 temporary[i2++]=sourceOfParams[i++];122 temporary[i2]=sourceOfParams[i];123 continue;124 }125 temporary[i2]=0;126 break;127 }128 temporary[i2]=sourceOfParams[i];129 }130 131 Type::StringToType( temporary, type );132 133 if( type.IsNull() ){134 throw SmoothieException(3,temporary,nowLine);135 type.SetBasicType( DEF_PTR_VOID );136 }137 138 if( type.IsObject() ){139 if( type.GetClass().IsBlittableType() ){140 // Blittable型のときは基本型として扱う141 type = type.GetClass().GetBlittableType();142 }143 }144 }145 else{146 type.SetBasicType( Type::GetBasicTypeFromSimpleName(temporary) );147 throw SmoothieException(-103,temporary,nowLine);148 }149 150 Parameter *pParam = new Parameter( name, type, isRef, initValue );151 if( isArray ){152 pParam->SetArray( subScripts );153 }154 155 //パラメータを追加156 this->params.push_back( pParam );157 158 if(sourceOfParams[i]==','){159 i++;160 continue;161 }162 else if(sourceOfParams[i]==')') continue;163 else{164 throw SmoothieException(1,NULL,nowLine);165 break;166 }167 }168 this->secondParmNum = (int)this->params.size();169 i++;170 if(sourceOfParams[i]=='('){171 i++;172 while(1){173 if(sourceOfParams[i]==')') break;174 175 //ByRef176 bool isRef;177 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){178 isRef = false;179 i+=2;180 }181 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){182 isRef = true;183 i+=2;184 }185 else isRef = false;186 187 //パラメータ名188 bool isArray = false;189 int subScripts[MAX_ARRAYDIM];190 char name[VN_SIZE];191 sw=0;192 for(i2=0;;i++,i2++){193 if(sourceOfParams[i]=='('){194 if(!sw) sw=1;195 196 i3=GetStringInPare(name+i2,sourceOfParams+i);197 i2+=i3-1;198 i+=i3-1;199 continue;200 }201 if(sourceOfParams[i]=='['){202 if(!sw) sw=1;203 204 i3=GetStringInBracket(name+i2,sourceOfParams+i);205 i2+=i3-1;206 i+=i3-1;207 continue;208 }209 if(!IsVariableChar(sourceOfParams[i])){210 name[i2]=0;211 break;212 }213 name[i2]=sourceOfParams[i];214 }215 if(sw){216 //配列パラメータ217 if( isRef == false ) throw SmoothieException(29,NULL,nowLine);218 isArray = true;219 220 if((name[i2-2]=='('&&name[i2-1]==')')||221 (name[i2-2]=='['&&name[i2-1]==']')){222 subScripts[0]=LONG_MAX;223 subScripts[1]=-1;224 225 name[i2-2]=0;226 }227 else{228 GetArrange(name,temp2,subScripts);229 lstrcpy(name,temp2);230 }231 232 i2=lstrlen(name);233 }234 235 //型236 Type type( DEF_NON );237 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){238 i+=2;239 240 i2=0;241 while(sourceOfParams[i]=='*'){242 temporary[i2]=sourceOfParams[i];243 i++;244 i2++;245 }246 for(;;i++,i2++){247 if(!IsVariableChar(sourceOfParams[i])){248 if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){249 temporary[i2++]=sourceOfParams[i++];250 temporary[i2]=sourceOfParams[i];251 continue;252 }253 temporary[i2]=0;254 break;255 }256 temporary[i2]=sourceOfParams[i];257 }258 259 Type::StringToType( temporary, type );260 261 if( type.IsNull() ){262 throw SmoothieException(3,temporary,nowLine);263 type.SetBasicType( DEF_PTR_VOID );264 }265 }266 else{267 type.SetBasicType( Type::GetBasicTypeFromSimpleName(temporary) );268 throw SmoothieException(-103,temporary,nowLine);269 }270 271 Parameter *pParam = new Parameter( name, type, isRef );272 if( isArray ){273 pParam->SetArray( subScripts );274 }275 276 //パラメータを追加277 this->params.push_back( pParam );278 279 if(sourceOfParams[i]==','){280 i++;281 continue;282 }283 else if(sourceOfParams[i]==')') continue;284 else{285 throw SmoothieException(1,NULL,nowLine);286 break;287 }288 }289 i++;290 }291 292 if(sourceOfParams[i]){293 ///////////////////294 // 戻り値を取得295 ///////////////////296 297 if( !this->IsFunction() ){298 // Sub/Macroの場合299 throw SmoothieException(38,this->GetName(),nowLine);300 }301 302 if( this->pParentClass ){303 if( this->GetName() == this->pParentClass->GetName() ||304 this->GetName()[0]=='~'){305 //クラスのコンストラクタ、デストラクタがFunction定義の場合はエラーをだす306 throw SmoothieException(115,NULL,nowLine);307 }308 }309 310 311 i2=lstrlen(sourceOfParams)-2;312 313 int sw_as=0;314 for(;i2>0;i2--){315 if(sourceOfParams[i2]==')') break;316 317 if(sourceOfParams[i2]==1&&sourceOfParams[i2+1]==ESC_AS){318 i2+=2;319 i3=0;320 while(sourceOfParams[i2]=='*') temporary[i3++]=sourceOfParams[i2++];321 for(;;i2++,i3++){322 if(!IsVariableChar(sourceOfParams[i2])){323 temporary[i3]=0;324 break;325 }326 temporary[i3]=sourceOfParams[i2];327 }328 Type::StringToType( temporary, this->returnType );329 if( this->returnType.IsNull() ) throw SmoothieException(3,temporary,nowLine);330 331 sw_as=1;332 break;333 }334 }335 336 if(!sw_as){337 throw SmoothieException(-104,this->GetName().c_str(),nowLine);338 339 this->returnType.SetBasicType( DEF_DOUBLE );340 }341 }342 else{343 //戻り値なしのSub定義344 this->returnType.SetNull();345 }346 347 //リアルパラメータ領域を取得(_System_LocalThisを考慮して2つだけ多く確保する場合がある)348 349 if( this->pParentClass && isStatic == false ){350 //オブジェクトメンバの場合は、第一パラメータを_System_LocalThis引き渡し用として利用351 string name = "_System_LocalThis";352 Type type( DEF_PTR_VOID );353 this->realParams.push_back( new Parameter( name, type ) );354 }355 356 if( this->returnType.IsStruct() ){357 //構造体を戻り値として持つ場合358 //※第一パラメータ(Thisポインタありの場合は第二パラメータ)を戻り値用の参照宣言にする359 360 string name = this->GetName();361 if(name[0]==1&&name[1]==ESC_OPERATOR){362 name="_System_ReturnValue";363 }364 Type type( DEF_STRUCT, this->returnType.GetIndex() );365 this->realParams.push_back( new Parameter( name, type, true ) );366 }367 368 //パラメータをコピー369 foreach( Parameter *pParam, params ){370 this->realParams.push_back( new Parameter( *pParam ) );371 }372 373 return true;374 }*/375 12 bool UserProc::IsVirtual() const 376 13 { … … 398 35 throw SmoothieException(); 399 36 return false; 400 }401 402 /*403 GlobalProc *GlobalProc::Create( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine ){404 int i2;405 char temporary[8192];406 407 int i=1;408 409 Procedure::Kind kind = Procedure::Sub;410 bool isMacro = false;411 if(buffer[i]==ESC_FUNCTION) kind = Procedure::Function;412 if(buffer[i]==ESC_MACRO){413 isMacro = true;414 }415 416 i++;417 418 bool isCdecl = false;419 bool isExport = false;420 while(1){421 if(buffer[i]==1&&buffer[i+1]==ESC_CDECL&& isCdecl == false ){422 isCdecl = true;423 424 i+=2;425 }426 else if(buffer[i]==1&&buffer[i+1]==ESC_EXPORT&& isExport == false ){427 isExport = true;428 429 i+=2;430 }431 else break;432 }433 434 i2=0;435 if(buffer[i]==1&&buffer[i+1]==ESC_OPERATOR){436 throw SmoothieException(126,NULL,nowLine);437 return 0;438 }439 else{440 for(;;i++,i2++){441 if(!IsVariableChar(buffer[i])){442 temporary[i2]=0;443 break;444 }445 temporary[i2]=buffer[i];446 }447 }448 449 if( isMacro ){450 //大文字に変換451 CharUpper(temporary);452 453 //マクロ関数の場合は名前リストに追加454 extern char **ppMacroNames;455 extern int MacroNum;456 ppMacroNames=(char **)HeapReAlloc(hHeap,0,ppMacroNames,(MacroNum+1)*sizeof(char *));457 ppMacroNames[MacroNum]=(char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);458 lstrcpy(ppMacroNames[MacroNum],temporary);459 MacroNum++;460 }461 462 //重複チェック463 if(GetDeclareHash(temporary)){464 throw SmoothieException(15,temporary,nowLine);465 return 0;466 }467 468 extern int SubNum;469 SubNum++;470 471 GlobalProc *pGlobalProc = new GlobalProc( namespaceScopes, temporary, kind, isMacro, isCdecl, isExport );472 473 //ID474 static int id_base=0;475 pGlobalProc->id = (id_base++);476 477 if(isExport){478 pGlobalProc->Using();479 }480 481 // パラメータを解析482 // ※第1パラメータにに指定するデータの例:"( s As String ) As String"483 pGlobalProc->SetParamsAndReturnType( buffer + i, nowLine, true );484 485 486 pGlobalProc->_paramStr = buffer + i;487 488 489 490 return pGlobalProc;491 }492 bool GlobalProc::AddGlobalProc( const NamespaceScopes &namespaceScopes, char *buffer,int nowLine ){493 GlobalProc *pGlobalProc = Create( namespaceScopes, buffer, nowLine );494 if( pGlobalProc == NULL ){495 return false;496 }497 498 499 /////////////////////////////////500 // ハッシュデータに追加501 /////////////////////////////////502 503 int key;504 key=hash_default(pGlobalProc->GetName().c_str());505 506 extern GlobalProc **ppSubHash;507 if(ppSubHash[key]){508 GlobalProc *psi2;509 psi2=ppSubHash[key];510 while(1){511 //重複エラーチェックを行う512 if( pGlobalProc->GetName() == psi2->GetName() ){513 if( Parameter::Equals( psi2->Params(), pGlobalProc->Params() ) ){514 throw SmoothieException(15,pGlobalProc->GetName().c_str(),nowLine);515 return 0;516 }517 }518 519 if(psi2->pNextData==0) break;520 psi2=psi2->pNextData;521 }522 psi2->pNextData=pGlobalProc;523 }524 else{525 ppSubHash[key]=pGlobalProc;526 }527 528 return true;529 }*/530 const NamespaceScopes &GlobalProc::GetNamespaceScopes() const531 {532 if( HasParentClass() ){533 return GetParentClassPtr()->GetNamespaceScopes();534 }535 return namespaceScopes;536 }537 bool GlobalProc::IsEqualSymbol( const NamespaceScopes &namespaceScopes, const string &name ) const538 {539 if( GetName() != name ){540 return false;541 }542 543 return NamespaceScopes::IsSameArea( GetNamespaceScopes(), namespaceScopes );544 }545 bool GlobalProc::IsEqualSymbol( const GlobalProc &globalProc ) const546 {547 return IsEqualSymbol( globalProc.GetNamespaceScopes(), globalProc.GetName() );548 }549 bool GlobalProc::IsEqualSymbol( const string &fullName ) const550 {551 char AreaName[VN_SIZE] = ""; //オブジェクト変数552 char NestName[VN_SIZE] = ""; //入れ子メンバ553 bool isNest = CClass::SplitName( fullName.c_str(), AreaName, NestName );554 555 return IsEqualSymbol( NamespaceScopes( AreaName ), NestName );556 37 } 557 38 … … 588 69 } 589 70 590 591 bool DllProc::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){592 int i = 0;593 int i2,i3,sw;594 char temporary[8192],temp2[VN_SIZE];595 596 //ソースコードの位置597 this->codePos = nowLine;598 599 //パラメータ600 if(sourceOfParams[i]!='('){601 throw SmoothieException(1,NULL,nowLine);602 return 0;603 }604 i++;605 606 while(1){607 if(sourceOfParams[i]==')') break;608 609 //ByRef610 bool isRef;611 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){612 isRef = false;613 i+=2;614 }615 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){616 isRef = true;617 i+=2;618 }619 else isRef = false;620 621 //パラメータ名622 bool isArray = false;623 int subScripts[MAX_ARRAYDIM];624 char name[VN_SIZE];625 sw=0;626 for(i2=0;;i++,i2++){627 if(sourceOfParams[i]=='('){628 if(!sw) sw=1;629 630 i3=GetStringInPare(name+i2,sourceOfParams+i);631 i2+=i3-1;632 i+=i3-1;633 continue;634 }635 if(sourceOfParams[i]=='['){636 if(!sw) sw=1;637 638 i3=GetStringInBracket(name+i2,sourceOfParams+i);639 i2+=i3-1;640 i+=i3-1;641 continue;642 }643 if(!IsVariableChar(sourceOfParams[i])){644 name[i2]=0;645 break;646 }647 name[i2]=sourceOfParams[i];648 }649 if(sw){650 //配列パラメータ651 if( isRef == false ) throw SmoothieException(29,NULL,nowLine);652 isArray = true;653 654 if((name[i2-2]=='('&&name[i2-1]==')')||655 (name[i2-2]=='['&&name[i2-1]==']')){656 subScripts[0]=LONG_MAX;657 subScripts[1]=-1;658 659 name[i2-2]=0;660 }661 else{662 GetArrange(name,temp2,subScripts);663 lstrcpy(name,temp2);664 }665 666 i2=lstrlen(name);667 }668 669 //型670 Type type( DEF_NON );671 if(lstrcmp(name,"...")==0) type.SetBasicType( DEF_ELLIPSE );672 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){673 i+=2;674 675 i2=0;676 while(sourceOfParams[i]=='*'){677 temporary[i2]=sourceOfParams[i];678 i++;679 i2++;680 }681 for(;;i++,i2++){682 if(!IsVariableChar(sourceOfParams[i])){683 if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){684 temporary[i2++]=sourceOfParams[i++];685 temporary[i2]=sourceOfParams[i];686 continue;687 }688 temporary[i2]=0;689 break;690 }691 temporary[i2]=sourceOfParams[i];692 }693 694 Type::StringToType( temporary, type );695 696 if( type.IsNull() ){697 throw SmoothieException(3,temporary,nowLine);698 type.SetBasicType( DEF_PTR_VOID );699 }700 }701 else{702 type.SetBasicType( Type::GetBasicTypeFromSimpleName(temporary) );703 throw SmoothieException(-103,temporary,nowLine);704 }705 706 Parameter *pParam = new Parameter( name, type, isRef );707 if( isArray ){708 pParam->SetArray( subScripts );709 }710 711 //パラメータを追加712 this->params.push_back( pParam );713 714 if(sourceOfParams[i]==','){715 i++;716 continue;717 }718 else if(sourceOfParams[i]==')') continue;719 else{720 throw SmoothieException(1,NULL,nowLine);721 break;722 }723 }724 i++;725 726 if(sourceOfParams[i]){727 ///////////////////728 // 戻り値を取得729 ///////////////////730 731 i2=lstrlen(sourceOfParams)-2;732 733 int sw_as=0;734 for(;i2>0;i2--){735 if(sourceOfParams[i2]==')') break;736 737 if(sourceOfParams[i2]==1&&sourceOfParams[i2+1]==ESC_AS){738 i2+=2;739 i3=0;740 while(sourceOfParams[i2]=='*') temporary[i3++]=sourceOfParams[i2++];741 for(;;i2++,i3++){742 if(!IsVariableChar(sourceOfParams[i2])){743 temporary[i3]=0;744 break;745 }746 temporary[i3]=sourceOfParams[i2];747 }748 Type::StringToType( temporary, this->returnType );749 if( this->returnType.IsNull() ) throw SmoothieException(3,temporary,nowLine);750 751 sw_as=1;752 break;753 }754 }755 }756 else{757 //戻り値なしのSub定義758 this->returnType.SetNull();759 }760 761 return true;762 }763 764 bool ProcPointer::SetParamsAndReturnType( const char *sourceOfParams, int nowLine ){765 int i = 0;766 int i2,i3,sw;767 char temporary[8192],temp2[VN_SIZE];768 769 //ソースコードの位置770 this->codePos = nowLine;771 772 //パラメータ773 if(sourceOfParams[i]!='('){774 throw SmoothieException(1,NULL,nowLine);775 return 0;776 }777 i++;778 while(1){779 if(sourceOfParams[i]==')') break;780 781 //ByRef782 bool isRef;783 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYVAL){784 isRef = false;785 i+=2;786 }787 else if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_BYREF){788 isRef = true;789 i+=2;790 }791 else isRef = false;792 793 //パラメータ名794 bool isArray = false;795 int subScripts[MAX_ARRAYDIM];796 char name[VN_SIZE];797 sw=0;798 for(i2=0;;i++,i2++){799 if(sourceOfParams[i]=='('){800 if(!sw) sw=1;801 802 i3=GetStringInPare(name+i2,sourceOfParams+i);803 i2+=i3-1;804 i+=i3-1;805 continue;806 }807 if(sourceOfParams[i]=='['){808 if(!sw) sw=1;809 810 i3=GetStringInBracket(name+i2,sourceOfParams+i);811 i2+=i3-1;812 i+=i3-1;813 continue;814 }815 if(!IsVariableChar(sourceOfParams[i])){816 name[i2]=0;817 break;818 }819 name[i2]=sourceOfParams[i];820 }821 if(sw){822 //配列パラメータ823 if( isRef == false ) throw SmoothieException(29,NULL,nowLine);824 isArray = true;825 826 if((name[i2-2]=='('&&name[i2-1]==')')||827 (name[i2-2]=='['&&name[i2-1]==']')){828 subScripts[0]=LONG_MAX;829 subScripts[1]=-1;830 831 name[i2-2]=0;832 }833 else{834 GetArrange(name,temp2,subScripts);835 lstrcpy(name,temp2);836 }837 838 i2=lstrlen(name);839 }840 841 //型842 Type type( DEF_NON );843 if(sourceOfParams[i]==1&&sourceOfParams[i+1]==ESC_AS){844 i+=2;845 846 i2=0;847 while(sourceOfParams[i]=='*'){848 temporary[i2]=sourceOfParams[i];849 i++;850 i2++;851 }852 for(;;i++,i2++){853 if(!IsVariableChar(sourceOfParams[i])){854 if(sourceOfParams[i]==1&&(sourceOfParams[i+1]==ESC_FUNCTION||sourceOfParams[i+1]==ESC_SUB)){855 temporary[i2++]=sourceOfParams[i++];856 temporary[i2]=sourceOfParams[i];857 continue;858 }859 temporary[i2]=0;860 break;861 }862 temporary[i2]=sourceOfParams[i];863 }864 865 Type::StringToType( temporary, type );866 867 if( type.IsNull() ){868 throw SmoothieException(3,temporary,nowLine);869 type.SetBasicType( DEF_PTR_VOID );870 }871 }872 else{873 type.SetBasicType( Type::GetBasicTypeFromSimpleName(temporary) );874 throw SmoothieException(-103,temporary,nowLine);875 }876 877 Parameter *pParam = new Parameter( name, type, isRef );878 if( isArray ){879 pParam->SetArray( subScripts );880 }881 882 //パラメータを追加883 this->params.push_back( pParam );884 885 if(sourceOfParams[i]==','){886 i++;887 continue;888 }889 else if(sourceOfParams[i]==')') continue;890 else{891 throw SmoothieException(1,NULL,nowLine);892 break;893 }894 }895 i++;896 897 if(sourceOfParams[i]){898 ///////////////////899 // 戻り値を取得900 ///////////////////901 902 i2=lstrlen(sourceOfParams)-2;903 904 int sw_as=0;905 for(;i2>0;i2--){906 if(sourceOfParams[i2]==')') break;907 908 if(sourceOfParams[i2]==1&&sourceOfParams[i2+1]==ESC_AS){909 i2+=2;910 i3=0;911 while(sourceOfParams[i2]=='*') temporary[i3++]=sourceOfParams[i2++];912 for(;;i2++,i3++){913 if(!IsVariableChar(sourceOfParams[i2])){914 temporary[i3]=0;915 break;916 }917 temporary[i3]=sourceOfParams[i2];918 }919 Type::StringToType( temporary, this->returnType );920 if( this->returnType.IsNull() ) throw SmoothieException(3,temporary,nowLine);921 922 sw_as=1;923 break;924 }925 }926 }927 else{928 //戻り値なしのSub定義929 this->returnType.SetNull();930 }931 932 //戻り値のエラーチェック933 if( IsFunction() ){934 // Function定義935 936 if( this->ReturnType().IsNull() ){937 // 戻り値がない938 throw SmoothieException(26,this->GetName(),nowLine);939 }940 }941 else{942 if( !this->ReturnType().IsNull() ){943 // Sub定義なのに、戻り値がある944 throw SmoothieException(38,this->GetName(),nowLine);945 }946 }947 948 return true;949 }950 951 71 UserProc *UserProc::pCompilingUserProc = NULL; -
trunk/jenga/src/smoothie/Smoothie.cpp
r180 r181 1 1 #include <jenga/include/smoothie/Smoothie.h> 2 2 3 bool Smoothie::isUnicode = false; 3 4 BasicSource Smoothie::Lexical::source; 4 NamespaceScopes Smoothie:: Lexical::liveingNamespaceScopes;5 NamespaceScopes Smoothie::Temp::liveingNamespaceScopes; 5 6 6 7 NamespaceScopesCollection Smoothie::Temp::importedNamespaces; 7 8 const CClass *Smoothie::Temp::pCompilingClass = NULL; 8 CLexicalScopes *Smoothie::Temp::pLexicalScopes = NULL;9 9 10 10 bool Smoothie::isFullCompile = false; -
trunk/jenga/src/smoothie/Source.cpp
r173 r181 3 3 #include <jenga/include/common/Directory.h> 4 4 5 #include <jenga/include/smoothie/Smoothie.h> 5 6 #include <jenga/include/smoothie/BasicFixed.h> 6 7 #include <jenga/include/smoothie/Source.h> … … 120 121 } 121 122 122 extern bool isUnicode; 123 if( isUnicode ){ 123 if( Smoothie::IsUnicode() ){ 124 124 add( "UNICODE" ); 125 125 } -
trunk/jenga/src/smoothie/Type.cpp
r180 r181 1 #include <jenga/include/smoothie/Smoothie.h> 1 2 #include <jenga/include/smoothie/Class.h> 2 3 #include <jenga/include/smoothie/SmoothieException.h> … … 61 62 } 62 63 63 /* 64 64 65 bool Type::StringToType( const string &typeName, Type &type ){ 65 66 type.index = -1; … … 70 71 //関数ポインタ(*Function) 71 72 type.basicType = DEF_PTR_PROC; 72 type.index = AddProcPtrInfo( typeName, cp);73 type.index = Smoothie::GetMeta().GetProcPointers().Add( typeName ); 73 74 return true; 74 75 } … … 93 94 // Object型だったとき 94 95 if( typeName == "Object" ){ 95 type.SetType( DEF_OBJECT, Smoothie:: meta.GetClasses().GetObjectClassPtr() );96 type.SetType( DEF_OBJECT, Smoothie::GetMeta().GetClasses().GetObjectClassPtr() ); 96 97 return true; 97 98 } … … 99 100 // String型だったとき 100 101 if( typeName == "String" ){ 101 type.SetType( DEF_OBJECT, Smoothie:: meta.GetClasses().GetStringClassPtr() );102 type.SetType( DEF_OBJECT, Smoothie::GetMeta().GetClasses().GetStringClassPtr() ); 102 103 return true; 103 104 } … … 107 108 // TypeDefされた型 108 109 //////////////////// 109 int i=Smoothie:: meta.typeDefs.GetIndex( typeName );110 int i=Smoothie::GetMeta().typeDefs.GetIndex( typeName ); 110 111 if(i!=-1){ 111 type = Smoothie:: meta.typeDefs[i].GetBaseType();112 type = Smoothie::GetMeta().typeDefs[i].GetBaseType(); 112 113 return true; 113 114 } 114 115 115 116 //クラス 116 const CClass *pobj_c = Smoothie:: meta.GetClasses().Find( typeName );117 const CClass *pobj_c = Smoothie::GetMeta().GetClasses().Find( typeName ); 117 118 if(pobj_c){ 118 119 type.pClass = pobj_c; … … 128 129 129 130 return false; 130 } */131 } 131 132 132 133 int Type::GetBasicSize( int basicType ) … … 487 488 } 488 489 489 /* 490 490 491 const string Type::ToString() const 491 492 { … … 513 514 } 514 515 else{ 515 if( Smoothie:: meta.procPointers[index]->ReturnType().IsNull() ){516 if( Smoothie::GetMeta().GetProcPointers()[index]->ReturnType().IsNull() ){ 516 517 return "*Sub"; 517 518 } … … 532 533 } 533 534 534 extern int cp; 535 SetError(1,NULL,cp); 535 throw SmoothieException( 1 ); 536 536 537 537 return (string)"(null)"; … … 539 539 540 540 Type Type::String(){ 541 return Type( DEF_OBJECT, *Smoothie:: meta.GetClasses().GetStringClassPtr() );542 } */541 return Type( DEF_OBJECT, *Smoothie::GetMeta().GetClasses().GetStringClassPtr() ); 542 } 543 543 544 544 int Type::GetBasicTypeFromSimpleName( const char *variable ){ -
trunk/jenga/src/smoothie/TypeDef.cpp
r173 r181 145 145 146 146 // 名前空間管理 147 NamespaceScopes &namespaceScopes = Smoothie:: Lexical::liveingNamespaceScopes;147 NamespaceScopes &namespaceScopes = Smoothie::Temp::liveingNamespaceScopes; 148 148 namespaceScopes.clear(); 149 149
Note:
See TracChangeset
for help on using the changeset viewer.