Changeset 9 in dev
- Timestamp:
- Dec 7, 2006, 3:10:13 AM (18 years ago)
- Location:
- BasicCompiler64
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
BasicCompiler64/Compile_Var.cpp
r3 r9 754 754 LONG_PTR lpCalcIndex; 755 755 756 CalcType=StaticCalculation(true, InitBuf,type,&i64data,&lpCalcIndex); 756 CalcType=StaticCalculation(false, InitBuf,type,&i64data,&lpCalcIndex); 757 if(!CalcType){ 758 //動的データだった場合 759 return 0; 760 } 757 761 if(IsRealNumberType(CalcType)){ 758 762 memcpy(&dbl,&i64data,sizeof(double)); … … 876 880 int CalcType; 877 881 LONG_PTR lpCalcIndex; 878 CalcType=StaticCalculation(true, InitBuf,type,&i64data,&lpCalcIndex); 882 CalcType=StaticCalculation(false, InitBuf,type,&i64data,&lpCalcIndex); 883 if(!CalcType){ 884 //動的データだった場合 885 return 0; 886 } 879 887 if(IsRealNumberType(CalcType)){ 880 888 memcpy(&dbl,&i64data,sizeof(double)); … … 983 991 extern HANDLE hHeap; 984 992 int i2,i3,VarSize; 993 char VarName[VN_SIZE]; 994 995 996 if(dwFlag & DIMFLAG_CONST){ 997 ////////////////////////////////// 998 // 定数変数の場合を考慮 999 ////////////////////////////////// 1000 for(i2=0;;i2++){ 1001 if(Parameter[i2] == '=' || 1002 Parameter[i2] == 1 && Parameter[i2] == ESC_AS || 1003 Parameter[i2] =='('){ 1004 VarName[i2] = 0; 1005 break; 1006 } 1007 VarName[i2] = Parameter[i2]; 1008 } 1009 1010 //定数と2重定義されていないる場合は抜け出す 1011 if(CDBConst::obj.GetType(VarName)){ 1012 return; 1013 } 1014 1015 //定数マクロとして定義されている場合は抜け出す 1016 if(GetConstHash(VarName)){ 1017 return; 1018 } 1019 } 1020 985 1021 986 1022 //構文を解析 987 char VarName[VN_SIZE];988 1023 int SubScripts[MAX_ARRAYDIM]; 989 1024 TYPEINFO TypeInfo; … … 993 1028 return; 994 1029 1030 1031 //定数と2重定義されていないかを調べる 1032 if(CDBConst::obj.GetType(VarName)){ 1033 SetError(15,VarName,cp); 1034 return; 1035 } 1036 1037 //定数マクロとして定義されている場合 1038 if(GetConstHash(VarName)){ 1039 SetError(15,VarName,cp); 1040 return; 1041 } 1042 1043 995 1044 //タイプサイズを取得 996 1045 int TypeSize; 997 1046 TypeSize=GetTypeSize(TypeInfo.type,TypeInfo.u.lpIndex); 998 999 //定数と2重定義されていないかを調べる1000 if(GetConstHash(VarName)){1001 SetError(15,VarName,cp);1002 return;1003 }1004 1047 1005 1048 if(dwFlag&DIMFLAG_STATIC){ … … 1059 1102 if(VarSize%8) VarSize+=8-(VarSize%8); 1060 1103 1104 VARIABLE *pVar = &LocalVar[MaxLocalVarNum]; 1105 1106 MaxLocalVarNum++; 1107 1061 1108 //変数データを追加 1062 lstrcpy(LocalVar[MaxLocalVarNum].name,VarName); 1063 LocalVar[MaxLocalVarNum].fRef=0; 1064 if(SubScripts[0]==-1) LocalVar[MaxLocalVarNum].bArray=0; 1065 else LocalVar[MaxLocalVarNum].bArray=1; 1066 LocalVar[MaxLocalVarNum].type=TypeInfo.type; 1067 LocalVar[MaxLocalVarNum].u.index=TypeInfo.u.lpIndex; 1109 lstrcpy(pVar->name,VarName); 1110 pVar->fRef=0; 1111 if(dwFlag & DIMFLAG_CONST) pVar->bConst = 1; 1112 else pVar->bConst = 0; 1113 if(SubScripts[0]==-1) pVar->bArray=0; 1114 else pVar->bArray=1; 1115 pVar->type=TypeInfo.type; 1116 pVar->u.index=TypeInfo.u.lpIndex; 1068 1117 AllLocalVarSize+=VarSize; 1069 LocalVar[MaxLocalVarNum].offset=AllLocalVarSize;1118 pVar->offset=AllLocalVarSize; 1070 1119 1071 1120 //レキシカルスコープ 1072 LocalVar[MaxLocalVarNum].ScopeLevel=obj_LexScopes.GetNowLevel();1073 LocalVar[MaxLocalVarNum].ScopeStartAddress=obj_LexScopes.GetStartAddress();1074 LocalVar[MaxLocalVarNum].bLiving=TRUE;1121 pVar->ScopeLevel=obj_LexScopes.GetNowLevel(); 1122 pVar->ScopeStartAddress=obj_LexScopes.GetStartAddress(); 1123 pVar->bLiving=TRUE; 1075 1124 1076 1125 if(InitBuf[0]){ 1077 InitLocalVar(-LocalVar[MaxLocalVarNum].offset,1078 LocalVar[MaxLocalVarNum].type,1079 LocalVar[MaxLocalVarNum].u.index,1080 LocalVar[MaxLocalVarNum].SubScripts,1126 int result = InitLocalVar(-pVar->offset, 1127 pVar->type, 1128 pVar->u.index, 1129 pVar->SubScripts, 1081 1130 InitBuf); 1131 1132 if(!result){ 1133 //動的な式だった場合は代入演算を行う 1134 char temporary[8192]; 1135 sprintf(temporary,"%s=%s",VarName,InitBuf); 1136 OpcodeCalc(temporary); 1137 } 1082 1138 } 1083 1139 else{ 1084 1140 //0初期化未完成 1085 1141 } 1086 1087 MaxLocalVarNum++;1088 1142 } 1089 1143 -
BasicCompiler64/NumOpe.cpp
r3 r9 490 490 ////////////// 491 491 492 i3 =GetConstValue(term,&dbl,temporary,&index_stack[sp]);493 if(i3 !=-1){494 type[sp] =i3;492 i3 = CDBConst::obj.GetType(term); 493 if(i3){ 494 type[sp] = i3; 495 495 if(IsRealNumberType(i3)){ 496 496 //実数 497 double dbl = CDBConst::obj.GetDoubleData(term); 497 498 memcpy(&i64data,&dbl,sizeof(double)); 498 499 goto Literal; … … 500 501 else if(IsWholeNumberType(i3)){ 501 502 //整数 502 i64data =(_int64)dbl;503 i64data = CDBConst::obj.GetWholeData(term); 503 504 goto Literal; 504 505 } 505 else if(Is64Type(i3)){ 506 //64ビット整数値 507 memcpy(&i64data,&dbl,sizeof(_int64)); 508 goto Literal; 509 } 510 else if(i3==DEF_STRING){ 506 /*else if(i3==DEF_STRING){ 511 507 //リテラル文字列 512 508 … … 516 512 memcpy(term,temporary,i3); 517 513 goto StrLiteral; 518 } 514 }*/ 519 515 else{ 520 516 SetError(1,NULL,0); … … 522 518 } 523 519 } 520 524 521 525 522 -
BasicCompiler64/Opcode.h
r3 r9 319 319 BOOL GetVarOffset(BOOL bError,char *NameBuffer,int *pType,RELATIVE_VAR *pRelativeVar,LONG_PTR *plpIndex,int *pss=0); 320 320 BOOL SetInitGlobalData(int offset,int type,LONG_PTR lpIndex,int *SubScripts,char *InitBuf); 321 #define DIMFLAG_INITDEBUGVAR 1 322 #define DIMFLAG_NONCALL_CONSTRACTOR 2 323 #define DIMFLAG_STATIC 4 321 #define DIMFLAG_INITDEBUGVAR 1 322 #define DIMFLAG_NONCALL_CONSTRACTOR 2 323 #define DIMFLAG_STATIC 4 324 #define DIMFLAG_CONST 8 324 325 void OpcodeDim(char *Parameter,DWORD dwFlag); 325 326 void SetVarPtrToReg(int reg,RELATIVE_VAR *pRelativeVar);
Note:
See TracChangeset
for help on using the changeset viewer.