source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/Object.cpp@ 767

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

プロジェクトのリネームが完了

File size: 3.1 KB
Line 
1#include "stdafx.h"
2
3#include <Compiler.h>
4
5#include "../BasicCompiler_Common/common.h"
6
7#ifdef _AMD64_
8#include "../compiler_x64/opcode.h"
9#else
10#include "../compiler_x86/opcode.h"
11#endif
12
13extern HANDLE hHeap;
14
15void CallConstructor( const char *ObjectName,const Subscripts &subscripts,const Type &type,const char *Parameter){
16 if( !type.IsObject() ){
17 return;
18 }
19
20 /////////////////////////////////////
21 // クラスオブジェクトの場合
22 // ※コンストラクタの呼び出し
23 /////////////////////////////////////
24
25 const UserProc *pUserProc = GetMethodHash(ObjectName,type.GetClass().GetName().c_str(),Parameter);
26 if(!pUserProc){
27 if(Parameter[0]) compiler.errorMessenger.Output(113,type.GetClass().GetName().c_str(),cp);
28 return;
29 }
30
31
32 char temporary[VN_SIZE];
33
34 if( subscripts.size() > 0 ){
35 int ss[MAX_ARRAYDIM];
36 memset(ss,0,MAX_ARRAYDIM*sizeof(int));
37 while(1){
38 int i3;
39 for(i3=0; i3<(int)subscripts.size(); i3++){
40 if(ss[i3]>subscripts[i3]){
41 ss[i3]=0;
42 ss[i3+1]++;
43 }
44 else break;
45 }
46 if( i3 == subscripts.size() )
47 {
48 break;
49 }
50 sprintf(temporary,"%s[%d",ObjectName,ss[0]);
51 for(i3=1; i3<(int)subscripts.size(); i3++){
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 Type(), // baseTypeはなし
63 dummyType );
64
65 ss[0]++;
66 }
67 }
68 else{
69 Type dummyType;
70 sprintf(temporary,"%s.%s",ObjectName,type.GetClass().GetName().c_str());
71 CallProc( PROC_DEFAULT,
72 pUserProc,
73 temporary,
74 Parameter,
75 Type(), // baseTypeはなし
76 dummyType );
77 }
78}
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 compiler.errorMessenger.Output(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( !compiler.StringToType( typeName, resultType ) ){
117 compiler.errorMessenger.Output(3,typeName,cp);
118 return false;
119 }
120
121 if( !resultType.IsObject() ){
122 ////////////////////////
123 // 通常のデータ型の場合
124 ////////////////////////
125
126 compiler.errorMessenger.Output(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.