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

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