source: dev/BasicCompiler_Common/Object.cpp@ 82

Last change on this file since 82 was 75, checked in by dai_9181, 18 years ago

TYPEINFO→Typeへのリファクタリングを実施。64bitはほぼ完了。32bitが全般的に未完成。

File size: 3.0 KB
Line 
1#include "../BasicCompiler_Common/common.h"
2
3#ifdef _AMD64_
4#include "../BasicCompiler64/opcode.h"
5#else
6#include "../BasicCompiler32/opcode.h"
7#endif
8
9extern HANDLE hHeap;
10
11void CallConstructor( const char *ObjectName,const int *SubScripts,const Type &type,const char *Parameter){
12 if( !type.IsObject() ){
13 return;
14 }
15
16 /////////////////////////////////////
17 // クラスオブジェクトの場合
18 // ※コンストラクタの呼び出し
19 /////////////////////////////////////
20
21 UserProc *pUserProc;
22 pUserProc=GetMethodHash(ObjectName,type.GetClass().name,Parameter);
23 if(!pUserProc){
24 if(Parameter[0]) SetError(113,type.GetClass().name,cp);
25 return;
26 }
27
28
29 char temporary[VN_SIZE];
30
31 if(SubScripts[0]!=-1){
32 int ss[MAX_ARRAYDIM];
33 memset(ss,0,MAX_ARRAYDIM*sizeof(int));
34 while(1){
35 int i3;
36 for(i3=0;;i3++){
37 if(SubScripts[i3]==-1) break;
38
39 if(ss[i3]>SubScripts[i3]){
40 ss[i3]=0;
41 ss[i3+1]++;
42 }
43 else break;
44 }
45 if(SubScripts[i3]==-1) break;
46 sprintf(temporary,"%s[%d",ObjectName,ss[0]);
47 for(i3=1;;i3++){
48 if(SubScripts[i3]==-1) break;
49
50 sprintf(temporary+lstrlen(temporary),",%d",ss[i3]);
51 }
52 lstrcat(temporary,"]");
53
54 Type dummyType;
55 sprintf(temporary+lstrlen(temporary),".%s",type.GetClass().name);
56 CallProc( PROC_DEFAULT,
57 pUserProc,
58 temporary,
59 Parameter,
60 dummyType );
61
62 ss[0]++;
63
64
65 //ネイティブコードバッファの再確保
66 extern int obp_AllocSize;
67 if(obp_AllocSize<obp+8192){
68 obp_AllocSize+=8192;
69 OpBuffer=(char *)HeapReAlloc(hHeap,0,OpBuffer,obp_AllocSize); //matea
70 }
71 }
72 }
73 else{
74 Type dummyType;
75 sprintf(temporary,"%s.%s",ObjectName,type.GetClass().name);
76 CallProc( PROC_DEFAULT,
77 pUserProc,
78 temporary,
79 Parameter,
80 dummyType );
81 }
82}
83
84bool Operator_New( const char *expression, const Type &baseType, Type &resultType ){
85 char CreateParameter[VN_SIZE],objectSizeStr[VN_SIZE];
86 int i,i2;
87
88 i=0;
89
90 if(expression[0]=='['){
91 i=GetStringInBracket(objectSizeStr,expression);
92
93 SlideString(objectSizeStr+1,-1);
94 objectSizeStr[i-2]=0;
95 }
96 else objectSizeStr[0]=0;
97
98 char typeName[VN_SIZE];
99 for(i2=0;;i++,i2++){
100 if(expression[i]=='('){
101 typeName[i2]=0;
102
103 //コンストラクタに渡すパラメータを取得
104 i2=GetStringInPare(CreateParameter,expression+i);
105 RemoveStringPare(CreateParameter);
106 i+=i2;
107 if(expression[i]!='\0'){
108 SetError(42,NULL,cp);
109 return false;
110 }
111 break;
112 }
113 typeName[i2]=expression[i];
114 if(expression[i]=='\0'){
115 CreateParameter[0]=0;
116 break;
117 }
118 }
119
120 if( !Type::StringToType( typeName, resultType ) ){
121 SetError(3,typeName,cp);
122 return false;
123 }
124
125 if( !resultType.IsObject() ){
126 ////////////////////////
127 // 通常のデータ型の場合
128 ////////////////////////
129
130 SetError(121,NULL,cp);
131 return false;
132 }
133
134 Operator_New( resultType.GetClass(), objectSizeStr, CreateParameter, baseType );
135
136 if( !baseType.IsObject() ){
137 // オブジェクトポインタ向け
138 resultType.SetBasicType( DEF_PTR_OBJECT );
139 }
140
141 return true;
142}
Note: See TracBrowser for help on using the repository browser.