Index: BasicCompiler32/CParameter.cpp
===================================================================
--- BasicCompiler32/CParameter.cpp	(revision 75)
+++ BasicCompiler32/CParameter.cpp	(revision 76)
@@ -39,13 +39,12 @@
 		}
 
-		Type DummyTypeInfo;
+		Type dummyType;
 		BOOL bByVal;
 		if(bEllipse){
-			DummyTypeInfo.type=NumOpe_GetType_Old(Parms[i2],NULL,&DummyTypeInfo.u.lpIndex);
+			NumOpe_GetType( Parms[i2], Type(), dummyType );
 			bByVal=1;
 		}
 		else{
-			DummyTypeInfo.type=params[i2]->GetBasicType();
-			DummyTypeInfo.u.lpIndex=params[i2]->GetIndex();
+			dummyType = *params[i2];
 			bByVal = ( params[i2]->IsRef() == false ) ? TRUE:FALSE;
 		}
@@ -59,14 +58,13 @@
 			}
 
-			LONG_PTR lpVarIndex;
-			if( GetVarType( Parms[i2], &lpVarIndex, FALSE ) == -1 ){
+			if( !GetVarType( Parms[i2], Type(), FALSE ) ){
 				//変数ではないとき
-				int reg = REG_RAX;
-				int type = NumOpe( Parms[i2], DummyTypeInfo.type, DummyTypeInfo.u.lpIndex, &lpVarIndex );
+				Type calcType;
+				NumOpe( Parms[i2], dummyType, calcType );
 				//↑ここでスタックに積む
 
 				nCountOfTempObjects++;
 
-				if( type != DEF_STRUCT ){
+				if( !calcType.IsStruct() ){
 					//一時参照を作成
 
@@ -78,8 +76,6 @@
 
 				bool result = CheckDifferentType(
-					DummyTypeInfo.type,
-					DummyTypeInfo.u.lpIndex,
-					type,
-					lpVarIndex,
+					dummyType,
+					calcType,
 					procName.c_str(),
 					i2);
@@ -89,6 +85,5 @@
 					useTempObject = true;
 
-					types[i2].type = type;
-					types[i2].u.lpIndex = lpVarIndex;
+					types[i2] = calcType;
 				}
 			}
@@ -107,5 +102,5 @@
 	for(int i2=ParmsNum-1;i2>=0;i2--){
 		if( useTempParameters[i2] ){
-			if( types[i2].type == DEF_STRUCT ){
+			if( types[i2].IsStruct() ){
 				// 構造体の一時メモリ
 
@@ -117,5 +112,5 @@
 			}
 			else{
-				if( Is64Type( types[i2].type ) ){
+				if( types[i2].Is64() ){
 					//pop ... 参照を消す
 					//pop ... 上位32ビット
@@ -133,6 +128,6 @@
 }
 
-void ParamImpl::SetStructParameter(CClass *pobj_Class,LPSTR Parameter){
-	int object_size = pobj_Class->GetSize();
+void ParamImpl::SetStructParameter( const Type &baseType, const char *expression ){
+	int object_size = baseType.GetClass().GetSize();
 
 	//push object_size
@@ -143,80 +138,19 @@
 	op_call(pSub_calloc);
 
+	//push eax（ここでプッシュされた値が実際にパラメータとして引き渡される）
+	op_push(REG_EAX);
+
 	//push eax
 	op_push(REG_EAX);
 
-
-	Type BaseType={DEF_STRUCT,(LONG_PTR)pobj_Class};
-	Type CalcType;
-	CalcType.type=NumOpe_GetType_Old(Parameter,&BaseType,&CalcType.u.lpIndex);
-
-	/*
-	TODO: 消す
-	if( pobj_Class->GetCopyConstructorMethod()
-		&& CalcType.type==DEF_OBJECT&&CalcType.u.pobj_Class==pobj_Class){
-		////////////////////////////////////
-		// コピーコンストラクタを呼び出す
-		////////////////////////////////////
-
-		//push eax
-		op_push(REG_EAX);
-
-		BOOL bUseHeap;
-		CalcType.type=NumOpe(Parameter,DEF_OBJECT,(LONG_PTR)pobj_Class,&CalcType.u.lpIndex,&bUseHeap);
-
-		//pop ecx
-		op_pop(REG_ECX);
-
-		//pop eax
-		op_pop(REG_EAX);
-
-		if(bUseHeap){
-			//※解放用に退避
-			//mov esi,ecx
-			op_mov_RR(REG_ESI,REG_ECX);
-		}
-
-		//push ecx
-		op_push(REG_ECX);
-
-		//push eax
-		op_push(REG_EAX);
-
-		//call constructor
-		op_call(pobj_Class->GetCopyConstructorMethod()->pUserProc);
-
-
-		if(bUseHeap){
-			FreeTempObject(REG_ESI,pobj_Class);
-		}
-	}
-	else{*/
-
-
-		//push eax
-		op_push(REG_EAX);
-
-/*
-			TODO: 消す
-			if( pobj_Class->GetConstructorMethod() ){
-				////////////////////////////////
-				// コンストラクタを呼び出す
-				////////////////////////////////
-
-				//push this
-				op_push(REG_EAX);
-
-				//call constructor
-				op_call(pobj_Class->GetConstructorMethod()->pUserProc);
-			}
-*/
-
-			BOOL bUseHeap;
-			CalcType.type=NumOpe(Parameter,DEF_STRUCT,(LONG_PTR)pobj_Class,&CalcType.u.lpIndex,&bUseHeap);
-
-
-
-		SetStructVariable((LONG_PTR)pobj_Class,CalcType.type,CalcType.u.lpIndex,bUseHeap);
-	//}
+	Type calcType;
+	BOOL bUseHeap;
+	NumOpe( expression,
+		baseType,
+		calcType,
+		&bUseHeap );
+
+	// ※スタックにある二つのデータ（コピー先、コピー元）の値を必要とする
+	SetStructVariable( baseType, calcType, bUseHeap );
 }
 
@@ -247,7 +181,4 @@
 
 	//パラメータをレジスタとスタックに格納
-	int CalcType;
-	LONG_PTR lpCalcIndex;
-	BOOL bCalcUseHeap;
 	int ParmSize=0;
 	RELATIVE_VAR RelativeVar;
@@ -269,14 +200,13 @@
 		}
 
-		Type DummyTypeInfo;
+		Type dummyType;
 		BOOL bByVal;
 		if(bEllipse){
-			DummyTypeInfo.type=NumOpe_GetType_Old(Parms[i2],NULL,&DummyTypeInfo.u.lpIndex);
+			NumOpe_GetType( Parms[i2], Type(), dummyType );
 			bByVal=1;
 		}
 		else{
-			DummyTypeInfo.type=params[i2]->GetBasicType();
-			DummyTypeInfo.u.lpIndex=params[i2]->GetIndex();
-			bByVal = (params[i2]->IsRef() == false ) ? TRUE:FALSE;
+			dummyType = *params[i2];
+			bByVal = ( params[i2]->IsRef() == false ) ? TRUE:FALSE;
 		}
 
@@ -291,81 +221,100 @@
 			}
 
-			if(DummyTypeInfo.type==DEF_STRUCT){
-				SetStructParameter(DummyTypeInfo.u.pobj_Class,Parms[i2]);
+			if( dummyType.IsStruct() ){
+				SetStructParameter( dummyType, Parms[i2] );
 				goto next;
 			}
 
-
 			extern LONG_PTR ProcPtr_BaseIndex;
-			LONG_PTR back_ProcPtr_BaseIndex;
-			back_ProcPtr_BaseIndex=ProcPtr_BaseIndex;
-			if(DummyTypeInfo.type==DEF_PTR_PROC) ProcPtr_BaseIndex=DummyTypeInfo.u.lpIndex;
-			else ProcPtr_BaseIndex=-1;
-
-			CalcType=NumOpe(Parms[i2],DummyTypeInfo.type,DummyTypeInfo.u.lpIndex,&lpCalcIndex,&bCalcUseHeap);
+			LONG_PTR back_ProcPtr_BaseIndex = ProcPtr_BaseIndex;
+			if( dummyType.IsProcPtr() ){
+				ProcPtr_BaseIndex = dummyType.GetIndex();
+			}
+			else{
+				ProcPtr_BaseIndex=-1;
+			}
+
+			BOOL bCalcUseHeap;
+			Type calcType;
+			if( !NumOpe( Parms[i2], dummyType, calcType, &bCalcUseHeap ) ){
+				break;
+			}
 
 			ProcPtr_BaseIndex=back_ProcPtr_BaseIndex;
 
-			if(CalcType==-1) break;
-
-			if(CalcType==DEF_OBJECT){
-				if( DummyTypeInfo.type != DEF_OBJECT
+			if( calcType.IsObject() ){
+				if( !dummyType.IsObject()
 					||
-					DummyTypeInfo.type == DEF_OBJECT &&
-					!DummyTypeInfo.u.pobj_Class->IsEqualsOrSubClass( (CClass *)lpCalcIndex ) ){
+					dummyType.IsObject() &&
+					!dummyType.GetClass().IsEqualsOrSubClass( &calcType.GetClass() ) ){
 						//キャスト演算子のオーバーロードに対応する
-						CallCastOperatorProc(CalcType,lpCalcIndex,bCalcUseHeap,DummyTypeInfo.type,DummyTypeInfo.u.lpIndex);
+						CallCastOperatorProc( calcType, bCalcUseHeap,dummyType );
 				}
 			}
 
 			if(!bEllipse){
+				//型チェック
+				// TODO: _System_ReturnValueが考慮されていない？
+				if(bHas_System_LocalThis) i3=i2-1;
+				else i3=i2;
+				CheckDifferentType(
+					dummyType,
+					calcType,
+					procName.c_str(),
+					i3);
+			}
+
+			if( dummyType.IsDouble() ){
+				ChangeTypeToDouble( calcType.GetBasicType() );
+				ParmSize+=sizeof(long)*2;
+			}
+			else if( dummyType.IsSingle() ){
+				ChangeTypeToSingle( calcType.GetBasicType() );
+				ParmSize+=sizeof(long);
+			}
+			else if( dummyType.Is64() ){
+				ChangeTypeToInt64( calcType.GetBasicType() );
+				ParmSize+=sizeof(long)*2;
+			}
+			else if( dummyType.IsLong() || dummyType.IsDWord()
+				|| dummyType.IsPointer()
+				|| dummyType.IsObject() || dummyType.IsStruct() ){
+					ChangeTypeToLong( calcType.GetBasicType() );
+					ParmSize+=sizeof(long);
+			}
+			else if( dummyType.IsInteger() || dummyType.IsWord() ){
+				ChangeTypeToInteger( calcType.GetBasicType() );
+				ParmSize+=sizeof(long);
+			}
+			else if( dummyType.IsSByte() || dummyType.IsByte() || dummyType.IsBoolean() ){
+				ChangeTypeToByte( calcType.GetBasicType() );
+				ParmSize+=sizeof(long);
+			}
+			else{
+				SetError(300,NULL,cp);
+			}
+		}
+		else{
+			//ポインタ参照
+			if(Parms[i2][0]==1&&Parms[i2][1]==ESC_BYVAL){
+				//ポインタ指定
+
+				Type calcType;
+				if( !NumOpe( Parms[i2]+2, dummyType, calcType) ){
+					break;
+				}
+
+				ChangeTypeToLong( calcType.GetBasicType() );
+
+				dummyType.PtrLevelUp();
+
 				//型チェック
 				if(bHas_System_LocalThis) i3=i2-1;
 				else i3=i2;
 				CheckDifferentType(
-					DummyTypeInfo.type,
-					DummyTypeInfo.u.lpIndex,
-					CalcType,
-					lpCalcIndex,
+					dummyType,
+					calcType,
 					procName.c_str(),
 					i3);
-			}
-
-			if(DummyTypeInfo.type==DEF_DOUBLE){
-				ChangeTypeToDouble(CalcType);
-				ParmSize+=sizeof(long)*2;
-			}
-			else if(DummyTypeInfo.type==DEF_SINGLE){
-				ChangeTypeToSingle(CalcType);
-				ParmSize+=sizeof(long);
-			}
-			else if(DummyTypeInfo.type==DEF_INT64||DummyTypeInfo.type==DEF_QWORD){
-				ChangeTypeToInt64(CalcType);
-				ParmSize+=sizeof(long)*2;
-			}
-			else if(DummyTypeInfo.type==DEF_LONG||DummyTypeInfo.type==DEF_DWORD||DummyTypeInfo.type==DEF_OBJECT||DummyTypeInfo.type==DEF_STRUCT||
-				(IsPtrType(DummyTypeInfo.type)/*&&DummyTypeInfo.type!=DEF_PTR_VOID&&DummyTypeInfo.type!=DEF_PTR_BYTE*/)){
-				ChangeTypeToLong(CalcType);
-				ParmSize+=sizeof(long);
-			}
-			else if(DummyTypeInfo.type==DEF_INTEGER||DummyTypeInfo.type==DEF_WORD || (isUnicode&&DummyTypeInfo.type==DEF_CHAR)){
-				ChangeTypeToInteger(CalcType);
-				ParmSize+=sizeof(long);
-			}
-			else if(DummyTypeInfo.type==DEF_SBYTE||DummyTypeInfo.type==DEF_BYTE||DummyTypeInfo.type==DEF_BOOLEAN || (isUnicode==false&&DummyTypeInfo.type==DEF_CHAR)){
-				ChangeTypeToByte(CalcType);
-				ParmSize+=sizeof(long);
-			}
-			else{
-				SetError(300,NULL,cp);
-			}
-		}
-		else{
-			//ポインタ参照
-			if(Parms[i2][0]==1&&Parms[i2][1]==ESC_BYVAL){
-				//ポインタ指定
-				i3=NumOpe(Parms[i2]+2,0,0,0);
-
-				ChangeTypeToLong(i3);
 			}
 			else{
@@ -373,5 +322,5 @@
 					//一時オブジェクトをコピー
 
-					if( types[i2].type != DEF_STRUCT ){
+					if( !types[i2].IsStruct() ){
 						// 一時参照のための領域を考慮する
 						nCountOfNowTempObjects++;
@@ -393,28 +342,27 @@
 				else{
 					//変数のアドレスを取得
-					int VarType;
-					LONG_PTR lpVarIndex;
+					Type varType;
 					if(GetVarOffset(
 						false,
 						false,
 						Parms[i2],
-						&VarType,
 						&RelativeVar,
-						&lpVarIndex)){
-							if(DummyTypeInfo.type!=DEF_ANY){
+						varType)){
+							if( !dummyType.IsAny() ){
 								//型チェックを行う
-								if(DummyTypeInfo.type==VarType){
-									if(DummyTypeInfo.type==DEF_OBJECT){
-										if( !DummyTypeInfo.u.pobj_Class->IsEqualsOrSubClass( (CClass *)lpVarIndex ) ){
+								if( dummyType.GetBasicType() == varType.GetBasicType() ){
+									if( dummyType.IsObject() ){
+										if( !dummyType.GetClass().IsEqualsOrSubClass( &varType.GetClass() ) ){
 											SetError(11,Parms[i2],cp);
 										}
 									}
-									else if(DummyTypeInfo.type==DEF_STRUCT){
-										if( !DummyTypeInfo.u.pobj_Class->IsEquals( (CClass *)lpVarIndex ) ){
+									else if( dummyType.IsStruct() ){
+										if( !dummyType.GetClass().IsEquals( &varType.GetClass() ) ){
 											SetError(11,Parms[i2],cp);
 										}
 									}
 								}
-								else if((VarType&FLAG_PTR)&&((int)(VarType^FLAG_PTR)==DummyTypeInfo.type)){
+								else if( (varType.GetBasicType()&FLAG_PTR)
+									&&((varType.GetBasicType()^FLAG_PTR)==dummyType.GetBasicType())){
 									//仮引数がポインタ参照で、実引数が配列の先頭ポインタのとき
 								}
