source: dev/trunk/abdev/BasicCompiler_Common/Object.cpp@ 199

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