| 1 | #include "../common.h"
|
|---|
| 2 | #ifdef _AMD64_
|
|---|
| 3 | #include "../../BasicCompiler64/opcode.h"
|
|---|
| 4 | #else
|
|---|
| 5 | #include "../../BasicCompiler32/opcode.h"
|
|---|
| 6 | #endif
|
|---|
| 7 | #include <Member.h>
|
|---|
| 8 |
|
|---|
| 9 | CMember::CMember( CClass *pobj_c, Prototype::Accessibility accessibility, bool isConst, bool isRef, char *buffer, int nowLine )
|
|---|
| 10 | : MemberPrototype( accessibility )
|
|---|
| 11 | {
|
|---|
| 12 | extern int cp;
|
|---|
| 13 |
|
|---|
| 14 | //構文を解析
|
|---|
| 15 | char VarName[VN_SIZE];
|
|---|
| 16 | char init_buf[VN_SIZE];
|
|---|
| 17 | char constract_parameter[VN_SIZE];
|
|---|
| 18 | GetDimentionFormat(buffer,VarName,SubScripts,type,init_buf,constract_parameter);
|
|---|
| 19 |
|
|---|
| 20 | //重複チェック
|
|---|
| 21 | if(pobj_c->DupliCheckAll(VarName)){
|
|---|
| 22 | SetError(15,VarName,cp);
|
|---|
| 23 | }
|
|---|
| 24 |
|
|---|
| 25 | //メンバ名
|
|---|
| 26 | name = VarName;
|
|---|
| 27 |
|
|---|
| 28 | //定数扱いかどうか
|
|---|
| 29 | this->isConst = isConst;
|
|---|
| 30 |
|
|---|
| 31 | //初期データ
|
|---|
| 32 | InitBuf=(char *)HeapAlloc(hHeap,0,lstrlen(init_buf)+1);
|
|---|
| 33 | lstrcpy(InitBuf,init_buf);
|
|---|
| 34 |
|
|---|
| 35 | //コンストラクタ用のパラメータ
|
|---|
| 36 | ConstractParameter=(char *)HeapAlloc(hHeap,0,lstrlen(constract_parameter)+1);
|
|---|
| 37 | lstrcpy(ConstractParameter,constract_parameter);
|
|---|
| 38 |
|
|---|
| 39 | //ソースコードの位置
|
|---|
| 40 | source_code_address=nowLine;
|
|---|
| 41 | }
|
|---|
| 42 | CMember::CMember(CMember &member)
|
|---|
| 43 | : MemberPrototype( member.GetAccessibility() )
|
|---|
| 44 | , name( member.GetName() )
|
|---|
| 45 | , type( member.GetType() )
|
|---|
| 46 | , isConst( member.IsConst() )
|
|---|
| 47 | {
|
|---|
| 48 | //SubScripts
|
|---|
| 49 | memcpy(SubScripts,member.SubScripts,MAX_ARRAYDIM*sizeof(int));
|
|---|
| 50 |
|
|---|
| 51 | //ソースコードの位置
|
|---|
| 52 | source_code_address=member.source_code_address;
|
|---|
| 53 | }
|
|---|
| 54 | CMember::~CMember(){
|
|---|
| 55 | if(InitBuf) HeapDefaultFree(InitBuf);
|
|---|
| 56 | if(ConstractParameter) HeapDefaultFree(ConstractParameter);
|
|---|
| 57 | }
|
|---|
| 58 |
|
|---|
| 59 | void CMember::InitStaticMember(void){
|
|---|
| 60 | //静的メンバをグローバル領域に作成
|
|---|
| 61 |
|
|---|
| 62 | //イテレータをリセット
|
|---|
| 63 | extern CDBClass *pobj_DBClass;
|
|---|
| 64 | pobj_DBClass->Iterator_Reset();
|
|---|
| 65 |
|
|---|
| 66 | int back_cp=cp;
|
|---|
| 67 |
|
|---|
| 68 | while(pobj_DBClass->Iterator_HasNext()){
|
|---|
| 69 | CClass &objClass = *pobj_DBClass->Iterator_GetNext();
|
|---|
| 70 |
|
|---|
| 71 | // 名前空間をセット
|
|---|
| 72 | Smoothie::Lexical::liveingNamespaceScopes = objClass.GetNamespaceScopes();
|
|---|
| 73 |
|
|---|
| 74 | int i=0;
|
|---|
| 75 | foreach( CMember *member, objClass.staticMembers ){
|
|---|
| 76 | char temporary[VN_SIZE];
|
|---|
| 77 | sprintf(temporary,"%s.%s",objClass.GetName().c_str(),member->GetName().c_str());
|
|---|
| 78 | dim(
|
|---|
| 79 | temporary,
|
|---|
| 80 | member->SubScripts,
|
|---|
| 81 | member->GetType(),
|
|---|
| 82 | member->InitBuf,
|
|---|
| 83 | member->ConstractParameter,
|
|---|
| 84 | 0);
|
|---|
| 85 |
|
|---|
| 86 | //ネイティブコードバッファの再確保
|
|---|
| 87 | ReallocNativeCodeBuffer();
|
|---|
| 88 |
|
|---|
| 89 | i++;
|
|---|
| 90 | }
|
|---|
| 91 | }
|
|---|
| 92 |
|
|---|
| 93 | Smoothie::Lexical::liveingNamespaceScopes.clear();
|
|---|
| 94 |
|
|---|
| 95 | cp=back_cp;
|
|---|
| 96 | }
|
|---|