source: dev/BasicCompiler_Common/Object.cpp@ 131

Last change on this file since 131 was 131, checked in by dai_9181, 17 years ago

Prototypeクラスを用意した。

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