[206] | 1 | #include "stdafx.h"
|
---|
| 2 |
|
---|
[183] | 3 | #include <jenga/include/smoothie/LexicalAnalysis.h>
|
---|
| 4 |
|
---|
[248] | 5 | #include <LexicalScope.h>
|
---|
[183] | 6 | #include <Compiler.h>
|
---|
| 7 |
|
---|
[3] | 8 | #include "../BasicCompiler_Common/common.h"
|
---|
| 9 | #include "Opcode.h"
|
---|
| 10 |
|
---|
[129] | 11 | void OpcodeOthers( const char *Command ){
|
---|
[3] | 12 | int i,i2;
|
---|
| 13 |
|
---|
[122] | 14 | char leftTerm[8192];
|
---|
| 15 | int lastParePos = 0;
|
---|
[3] | 16 | for(i=0;;i++){
|
---|
[122] | 17 | if(Command[i]=='\"'){
|
---|
| 18 | //ダブルクォートは不正なのでエラー扱い
|
---|
| 19 | leftTerm[i]=0;
|
---|
| 20 | SetError(3,leftTerm,cp);
|
---|
| 21 | return;
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | if(Command[i]=='('){
|
---|
| 25 | lastParePos = i;
|
---|
| 26 | i2=GetStringInPare(leftTerm+i,Command+i);
|
---|
[3] | 27 | i+=i2-1;
|
---|
| 28 | continue;
|
---|
| 29 | }
|
---|
[122] | 30 | if(Command[i]=='['){
|
---|
| 31 | i2=GetStringInBracket(leftTerm+i,Command+i);
|
---|
| 32 | i+=i2-1;
|
---|
[3] | 33 | continue;
|
---|
| 34 | }
|
---|
[122] | 35 | if(Command[i]=='\0'){
|
---|
| 36 | leftTerm[i] = 0;
|
---|
[3] | 37 | break;
|
---|
| 38 | }
|
---|
[122] | 39 |
|
---|
| 40 | if( IsNumCalcMark( Command, i ) ){
|
---|
| 41 | leftTerm[i] = 0;
|
---|
| 42 | break;
|
---|
| 43 | }
|
---|
| 44 |
|
---|
| 45 | leftTerm[i]=Command[i];
|
---|
[3] | 46 | }
|
---|
| 47 | if(!(
|
---|
[122] | 48 | IsVariableTopChar(leftTerm[0])||
|
---|
| 49 | leftTerm[0]=='.'||
|
---|
| 50 | (leftTerm[0]==1&&leftTerm[1]==ESC_PSMEM)
|
---|
[3] | 51 | )){
|
---|
| 52 | SetError(1,NULL,cp);
|
---|
| 53 | return;
|
---|
| 54 | }
|
---|
| 55 |
|
---|
| 56 |
|
---|
[122] | 57 | if(Command[i]=='\0' && lastParePos == 0){
|
---|
[3] | 58 | //////////////////////////////
|
---|
| 59 | // パラメータ無しのマクロ検索
|
---|
| 60 | //////////////////////////////
|
---|
| 61 |
|
---|
[206] | 62 | const UserProc *pUserProc = GetSubHash(Command);
|
---|
[3] | 63 |
|
---|
| 64 | //GetSubHash内でエラー提示が行われた場合
|
---|
[75] | 65 | if(pUserProc==(UserProc *)-1) return;
|
---|
[3] | 66 |
|
---|
[75] | 67 | if(pUserProc==0){
|
---|
[3] | 68 | char temporary[VN_SIZE];
|
---|
| 69 | lstrcpy(temporary,Command);
|
---|
| 70 |
|
---|
| 71 | CharUpper(temporary);
|
---|
[75] | 72 | pUserProc=GetSubHash(temporary);
|
---|
[3] | 73 |
|
---|
| 74 | //GetSubHash内でエラー提示が行われた場合
|
---|
[75] | 75 | if(pUserProc==(UserProc *)-1) return;
|
---|
[3] | 76 | }
|
---|
| 77 |
|
---|
[75] | 78 | if(pUserProc){
|
---|
[122] | 79 | if( !pUserProc->IsMacro() ){
|
---|
| 80 | SetError(10,Command,cp);
|
---|
| 81 | }
|
---|
[3] | 82 |
|
---|
[290] | 83 | Opcode_CallProc("",pUserProc,0,"");
|
---|
[3] | 84 |
|
---|
| 85 | return;
|
---|
| 86 | }
|
---|
| 87 | }
|
---|
| 88 | else if(IsNumCalcMark(Command,i)){
|
---|
| 89 | //代入演算
|
---|
| 90 | OpcodeCalc(Command);
|
---|
| 91 | return;
|
---|
| 92 | }
|
---|
| 93 |
|
---|
[122] | 94 | Type resultType;
|
---|
| 95 | bool isLiteral;
|
---|
| 96 | BOOL bUseHeap;
|
---|
[128] | 97 | bool result = TermOpe( leftTerm, Type(), resultType, isLiteral, &bUseHeap, false, NULL, true );
|
---|
[122] | 98 | if( result ){
|
---|
[3] | 99 |
|
---|
| 100 | /////////////////////
|
---|
| 101 | // 戻り値の処理
|
---|
| 102 | /////////////////////
|
---|
| 103 |
|
---|
[76] | 104 | if( resultType.IsReal() ){
|
---|
[3] | 105 | //fstp st(0)
|
---|
[236] | 106 | compiler.codeGenerator.PutOld(
|
---|
| 107 | (char)0xDD,
|
---|
| 108 | (char)0xD8
|
---|
| 109 | );
|
---|
[3] | 110 | }
|
---|
[76] | 111 | else if( resultType.IsStruct() ){
|
---|
[51] | 112 | //mov ebx,eax
|
---|
[225] | 113 | compiler.codeGenerator.op_mov_RR(REG_EBX,REG_EAX);
|
---|
[3] | 114 |
|
---|
[76] | 115 | FreeTempObject(REG_EBX,&resultType.GetClass());
|
---|
[3] | 116 | }
|
---|
| 117 | }
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | void OpcodeIf(char *Parameter){
|
---|
[241] | 121 | int i,i2;
|
---|
[76] | 122 | Type tempType;
|
---|
[3] | 123 |
|
---|
| 124 | for(i=0;;i++){
|
---|
| 125 | if(Parameter[i]=='\0'){
|
---|
| 126 | SetError(21,NULL,cp);
|
---|
| 127 | return;
|
---|
| 128 | }
|
---|
| 129 | if(Parameter[i]==1&&Parameter[i+1]==ESC_THEN){
|
---|
| 130 | Parameter[i]=0;
|
---|
| 131 | break;
|
---|
| 132 | }
|
---|
| 133 | }
|
---|
| 134 |
|
---|
[248] | 135 | const PertialSchedule *pIfPertialSchedule = NULL;
|
---|
[326] | 136 | if( !NumOpe(Parameter,Type(DEF_BOOLEAN),tempType) ){
|
---|
[3] | 137 | //NumOpe内でエラー
|
---|
| 138 | }
|
---|
[76] | 139 | else if( tempType.IsDouble() ){
|
---|
[3] | 140 | //fld qword ptr[esp]
|
---|
[225] | 141 | compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
|
---|
[3] | 142 |
|
---|
| 143 | //push 0
|
---|
[225] | 144 | compiler.codeGenerator.op_push_V(0);
|
---|
[3] | 145 |
|
---|
| 146 | //fild dword ptr[esp]
|
---|
[225] | 147 | compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
|
---|
[3] | 148 |
|
---|
| 149 | //add esp,sizeof(double)+sizeof(long)
|
---|
[225] | 150 | compiler.codeGenerator.op_add_esp(sizeof(double)+sizeof(long));
|
---|
[3] | 151 |
|
---|
| 152 | //fcompp
|
---|
[225] | 153 | compiler.codeGenerator.op_fcompp();
|
---|
[3] | 154 |
|
---|
| 155 | //fnstsw ax
|
---|
[225] | 156 | compiler.codeGenerator.op_fnstsw_ax();
|
---|
[3] | 157 |
|
---|
| 158 | //test ah,40
|
---|
[225] | 159 | compiler.codeGenerator.op_test_ah( (char)0x40 );
|
---|
[3] | 160 |
|
---|
| 161 | //jne (endif、または else まで)
|
---|
[241] | 162 | pIfPertialSchedule = compiler.codeGenerator.op_jne( 0, sizeof(long), true );
|
---|
[3] | 163 | }
|
---|
[76] | 164 | else if( tempType.IsSingle() ){
|
---|
[3] | 165 | //fld dword ptr[esp]
|
---|
[225] | 166 | compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
|
---|
[3] | 167 |
|
---|
| 168 | //push 0
|
---|
[225] | 169 | compiler.codeGenerator.op_push_V(0);
|
---|
[3] | 170 |
|
---|
| 171 | //fild dword ptr[esp]
|
---|
[225] | 172 | compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
|
---|
[3] | 173 |
|
---|
| 174 | //add esp,sizeof(float)+sizeof(long)
|
---|
[225] | 175 | compiler.codeGenerator.op_add_esp(sizeof(float)+sizeof(long));
|
---|
[3] | 176 |
|
---|
| 177 | //fcompp
|
---|
[225] | 178 | compiler.codeGenerator.op_fcompp();
|
---|
[3] | 179 |
|
---|
| 180 | //fnstsw ax
|
---|
[225] | 181 | compiler.codeGenerator.op_fnstsw_ax();
|
---|
[3] | 182 |
|
---|
| 183 | //test ah,40
|
---|
[225] | 184 | compiler.codeGenerator.op_test_ah( (char)0x40 );
|
---|
[3] | 185 |
|
---|
| 186 | //jne (endif、または else まで)
|
---|
[241] | 187 | pIfPertialSchedule = compiler.codeGenerator.op_jne( 0, sizeof(long), true );
|
---|
[3] | 188 | }
|
---|
[76] | 189 | else if( tempType.Is64() ){
|
---|
[3] | 190 | //64ビット型
|
---|
| 191 |
|
---|
| 192 | //pop eax
|
---|
[225] | 193 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 194 |
|
---|
| 195 | //pop ebx
|
---|
[225] | 196 | compiler.codeGenerator.op_pop(REG_EBX);
|
---|
[3] | 197 |
|
---|
| 198 | //cmp eax,0
|
---|
[236] | 199 | compiler.codeGenerator.op_cmp_value( sizeof(long), REG_EAX, 0 );
|
---|
[3] | 200 |
|
---|
| 201 | //jne
|
---|
[248] | 202 | const PertialSchedule *pTempPertialSchedule1 = compiler.codeGenerator.op_jne( 0, sizeof(char), true );
|
---|
[3] | 203 |
|
---|
| 204 | //cmp ebx,0
|
---|
[236] | 205 | compiler.codeGenerator.op_cmp_value( sizeof(long), REG_EBX, 0 );
|
---|
[3] | 206 |
|
---|
| 207 | //jne
|
---|
[248] | 208 | const PertialSchedule *pTempPertialSchedule2 = compiler.codeGenerator.op_jne( 0, sizeof(char), true );
|
---|
[3] | 209 |
|
---|
| 210 | //jmp (endif、または else までジャンプ)
|
---|
[241] | 211 | pIfPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );
|
---|
[3] | 212 |
|
---|
[241] | 213 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule1 );
|
---|
| 214 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule2 );
|
---|
[3] | 215 | }
|
---|
| 216 | else{
|
---|
| 217 | //32ビット型
|
---|
| 218 |
|
---|
| 219 | //pop eax
|
---|
[225] | 220 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 221 |
|
---|
| 222 | //cmp eax,0
|
---|
[236] | 223 | compiler.codeGenerator.op_cmp_value( sizeof(long), REG_EAX, 0 );
|
---|
[3] | 224 |
|
---|
| 225 | //je (endif、または else まで条件ジャンプ)
|
---|
[241] | 226 | pIfPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true );
|
---|
[3] | 227 | }
|
---|
| 228 |
|
---|
| 229 |
|
---|
| 230 | /////////////////////////
|
---|
| 231 | // If内をコード化
|
---|
| 232 | /////////////////////////
|
---|
| 233 |
|
---|
| 234 | //レキシカルスコープをレベルアップ
|
---|
[276] | 235 | compiler.codeGenerator.lexicalScopes.Start(
|
---|
| 236 | compiler.codeGenerator.GetNativeCodeSize(),
|
---|
| 237 | LexicalScope::SCOPE_TYPE_IF
|
---|
| 238 | );
|
---|
[3] | 239 |
|
---|
| 240 | i2=CompileBuffer(ESC_ENDIF,0);
|
---|
| 241 |
|
---|
| 242 | //レキシカルスコープをレベルダウン
|
---|
[248] | 243 | compiler.codeGenerator.lexicalScopes.End();
|
---|
[3] | 244 |
|
---|
| 245 |
|
---|
[241] | 246 | if( pIfPertialSchedule == NULL ) return;
|
---|
[3] | 247 |
|
---|
| 248 | if(i2==ESC_ELSE){
|
---|
| 249 | //jmp (endifまで)
|
---|
[248] | 250 | const PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );
|
---|
[3] | 251 |
|
---|
[241] | 252 | compiler.codeGenerator.opfix_JmpPertialSchedule( pIfPertialSchedule );
|
---|
[3] | 253 |
|
---|
| 254 |
|
---|
| 255 | /////////////////////////
|
---|
| 256 | // Else内をコード化
|
---|
| 257 | /////////////////////////
|
---|
| 258 |
|
---|
| 259 | //レキシカルスコープをレベルアップ
|
---|
[276] | 260 | compiler.codeGenerator.lexicalScopes.Start(
|
---|
| 261 | compiler.codeGenerator.GetNativeCodeSize(),
|
---|
| 262 | LexicalScope::SCOPE_TYPE_IF
|
---|
| 263 | );
|
---|
[3] | 264 |
|
---|
| 265 | CompileBuffer(ESC_ENDIF,0);
|
---|
| 266 |
|
---|
| 267 | //レキシカルスコープをレベルダウン
|
---|
[248] | 268 | compiler.codeGenerator.lexicalScopes.End();
|
---|
[3] | 269 |
|
---|
| 270 |
|
---|
[241] | 271 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule );
|
---|
[3] | 272 | }
|
---|
| 273 | else{
|
---|
[241] | 274 | compiler.codeGenerator.opfix_JmpPertialSchedule( pIfPertialSchedule );
|
---|
[3] | 275 | }
|
---|
| 276 | }
|
---|
| 277 |
|
---|
| 278 | int GetLabelAddress(char *LabelName,int LineNum){
|
---|
| 279 | if(LabelName){
|
---|
[261] | 280 | BOOST_FOREACH( const GotoLabel &label, compiler.codeGenerator.gotoLabels )
|
---|
[260] | 281 | {
|
---|
| 282 | if( label.name.size() > 0 )
|
---|
| 283 | {
|
---|
| 284 | if( label.name == LabelName )
|
---|
| 285 | {
|
---|
| 286 | return label.address;
|
---|
| 287 | }
|
---|
[3] | 288 | }
|
---|
| 289 | }
|
---|
| 290 | }
|
---|
| 291 | else{
|
---|
[261] | 292 | BOOST_FOREACH( const GotoLabel &label, compiler.codeGenerator.gotoLabels )
|
---|
[260] | 293 | {
|
---|
| 294 | if( label.name.size() == 0 )
|
---|
| 295 | {
|
---|
| 296 | if( label.line == LineNum )
|
---|
| 297 | {
|
---|
| 298 | return label.address;
|
---|
| 299 | }
|
---|
[3] | 300 | }
|
---|
| 301 | }
|
---|
| 302 | }
|
---|
| 303 | return -1;
|
---|
| 304 | }
|
---|
| 305 | void OpcodeGoto(char *Parameter){
|
---|
| 306 | extern HANDLE hHeap;
|
---|
| 307 | int i,LineNum;
|
---|
| 308 |
|
---|
| 309 | if(Parameter[0]=='*'){
|
---|
| 310 | i=GetLabelAddress(Parameter+1,0);
|
---|
| 311 |
|
---|
[246] | 312 | if( i == -1 )
|
---|
| 313 | {
|
---|
| 314 | //jmp ...(schedule)
|
---|
[253] | 315 | compiler.codeGenerator.op_jmp_goto_schedule( (const std::string)(Parameter + 1), 0, cp );
|
---|
[3] | 316 | }
|
---|
[246] | 317 | else
|
---|
| 318 | {
|
---|
| 319 | //jmp ...
|
---|
[276] | 320 | compiler.codeGenerator.op_jmp(
|
---|
| 321 | i-compiler.codeGenerator.GetNativeCodeSize(),
|
---|
| 322 | sizeof(long),
|
---|
| 323 | false,
|
---|
| 324 | true
|
---|
| 325 | );
|
---|
[246] | 326 | }
|
---|
[3] | 327 | }
|
---|
| 328 | else{
|
---|
| 329 | LineNum=atoi(Parameter);
|
---|
| 330 | i=GetLabelAddress(0,LineNum);
|
---|
| 331 |
|
---|
[246] | 332 | if( i == -1 )
|
---|
| 333 | {
|
---|
| 334 | //jmp ...(schedule)
|
---|
[253] | 335 | compiler.codeGenerator.op_jmp_goto_schedule( "", LineNum, cp );
|
---|
[3] | 336 | }
|
---|
[246] | 337 | else
|
---|
| 338 | {
|
---|
| 339 | //jmp ...
|
---|
[276] | 340 | compiler.codeGenerator.op_jmp(
|
---|
| 341 | i-compiler.codeGenerator.GetNativeCodeSize(),
|
---|
| 342 | sizeof(long),
|
---|
| 343 | false,
|
---|
| 344 | true
|
---|
| 345 | );
|
---|
[246] | 346 | }
|
---|
[3] | 347 | }
|
---|
| 348 | }
|
---|
| 349 | void OpcodeWhile(char *Parameter){
|
---|
| 350 | extern HANDLE hHeap;
|
---|
| 351 |
|
---|
| 352 | //Continueアドレスのバックアップとセット
|
---|
[241] | 353 | compiler.codeGenerator.ContinueAreaBegin();
|
---|
[3] | 354 |
|
---|
| 355 | if(!Parameter[0]) SetError(10,"While",cp);
|
---|
| 356 |
|
---|
[248] | 357 | const PertialSchedule *pWhilePertialSchedule = NULL;
|
---|
[76] | 358 | Type tempType;
|
---|
| 359 | if( !NumOpe(Parameter,Type(),tempType) ){
|
---|
| 360 | //ダミー
|
---|
| 361 | }
|
---|
| 362 | else if( tempType.IsDouble() ){
|
---|
[3] | 363 | //fld qword ptr[esp]
|
---|
[225] | 364 | compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
|
---|
[3] | 365 |
|
---|
| 366 | //push 0
|
---|
[225] | 367 | compiler.codeGenerator.op_push_V(0);
|
---|
[3] | 368 |
|
---|
| 369 | //fild dword ptr[esp]
|
---|
[225] | 370 | compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
|
---|
[3] | 371 |
|
---|
| 372 | //add esp,sizeof(double)+sizeof(long)
|
---|
[225] | 373 | compiler.codeGenerator.op_add_esp(sizeof(double)+sizeof(long));
|
---|
[3] | 374 |
|
---|
| 375 | //fcompp
|
---|
[225] | 376 | compiler.codeGenerator.op_fcompp();
|
---|
[3] | 377 |
|
---|
| 378 | //fnstsw ax
|
---|
[225] | 379 | compiler.codeGenerator.op_fnstsw_ax();
|
---|
[3] | 380 |
|
---|
| 381 | //test ah,40
|
---|
[225] | 382 | compiler.codeGenerator.op_test_ah( (char)0x40 );
|
---|
[3] | 383 |
|
---|
| 384 | //jne (Wend まで)
|
---|
[241] | 385 | pWhilePertialSchedule = compiler.codeGenerator.op_jne( 0, sizeof(long), true );
|
---|
[3] | 386 | }
|
---|
[76] | 387 | else if( tempType.IsSingle() ){
|
---|
[3] | 388 | //fld dword ptr[esp]
|
---|
[225] | 389 | compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
|
---|
[3] | 390 |
|
---|
| 391 | //push 0
|
---|
[225] | 392 | compiler.codeGenerator.op_push_V(0);
|
---|
[3] | 393 |
|
---|
| 394 | //fild dword ptr[esp]
|
---|
[225] | 395 | compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
|
---|
[3] | 396 |
|
---|
| 397 | //add esp,sizeof(float)+sizeof(long)
|
---|
[225] | 398 | compiler.codeGenerator.op_add_esp(sizeof(float)+sizeof(long));
|
---|
[3] | 399 |
|
---|
| 400 | //fcompp
|
---|
[225] | 401 | compiler.codeGenerator.op_fcompp();
|
---|
[3] | 402 |
|
---|
| 403 | //fnstsw ax
|
---|
[225] | 404 | compiler.codeGenerator.op_fnstsw_ax();
|
---|
[3] | 405 |
|
---|
[241] | 406 | //test ah,40h
|
---|
[225] | 407 | compiler.codeGenerator.op_test_ah( (char)0x40 );
|
---|
[3] | 408 |
|
---|
| 409 | //jne (Wend まで)
|
---|
[241] | 410 | pWhilePertialSchedule = compiler.codeGenerator.op_jne( 0, sizeof(long), true );
|
---|
[3] | 411 | }
|
---|
[76] | 412 | else if( tempType.Is64() ){
|
---|
[3] | 413 | //64ビット型
|
---|
| 414 |
|
---|
| 415 | //pop eax
|
---|
[225] | 416 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 417 |
|
---|
| 418 | //pop ebx
|
---|
[225] | 419 | compiler.codeGenerator.op_pop(REG_EBX);
|
---|
[3] | 420 |
|
---|
| 421 | //cmp eax,0
|
---|
[236] | 422 | compiler.codeGenerator.op_cmp_value( sizeof(long), REG_EAX, 0 );
|
---|
[3] | 423 |
|
---|
| 424 | //jne
|
---|
[248] | 425 | const PertialSchedule *pTempPertialSchedule1 = compiler.codeGenerator.op_jne( 0, sizeof(char), true );
|
---|
[3] | 426 |
|
---|
| 427 | //cmp ebx,0
|
---|
[236] | 428 | compiler.codeGenerator.op_cmp_value( sizeof(long), REG_EBX, 0 );
|
---|
[3] | 429 |
|
---|
| 430 | //jne
|
---|
[248] | 431 | const PertialSchedule *pTempPertialSchedule2 = compiler.codeGenerator.op_jne( 0, sizeof(char), true );
|
---|
[3] | 432 |
|
---|
[241] | 433 | //jmp (Wendまでジャンプ)
|
---|
| 434 | pWhilePertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );
|
---|
[3] | 435 |
|
---|
[241] | 436 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule1 );
|
---|
| 437 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule2 );
|
---|
[3] | 438 | }
|
---|
| 439 | else{
|
---|
| 440 | //その他整数型
|
---|
| 441 |
|
---|
| 442 | //pop eax
|
---|
[225] | 443 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 444 |
|
---|
| 445 | //cmp eax,0
|
---|
[236] | 446 | compiler.codeGenerator.op_cmp_value( sizeof(long), REG_EAX, 0 );
|
---|
[3] | 447 |
|
---|
| 448 | //je (Wend まで)
|
---|
[241] | 449 | pWhilePertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true );
|
---|
[3] | 450 | }
|
---|
| 451 |
|
---|
| 452 | //レキシカルスコープをレベルアップ
|
---|
[276] | 453 | compiler.codeGenerator.lexicalScopes.Start( compiler.codeGenerator.GetNativeCodeSize(), LexicalScope::SCOPE_TYPE_WHILE );
|
---|
[3] | 454 |
|
---|
| 455 | //While内をコンパイル
|
---|
| 456 | CompileBuffer(0,COM_WEND);
|
---|
| 457 |
|
---|
[248] | 458 | compiler.codeGenerator.lexicalScopes.CallDestructorsOfScopeEnd();
|
---|
[3] | 459 |
|
---|
| 460 | //jmp ...
|
---|
[241] | 461 | compiler.codeGenerator.op_jmp_continue();
|
---|
[3] | 462 |
|
---|
| 463 | //レキシカルスコープをレベルダウン
|
---|
[248] | 464 | compiler.codeGenerator.lexicalScopes.End();
|
---|
[3] | 465 |
|
---|
[241] | 466 | if( pWhilePertialSchedule )
|
---|
| 467 | {
|
---|
| 468 | compiler.codeGenerator.opfix_JmpPertialSchedule( pWhilePertialSchedule );
|
---|
| 469 | }
|
---|
[3] | 470 |
|
---|
[241] | 471 | compiler.codeGenerator.ContinueAreaEnd();
|
---|
[3] | 472 | }
|
---|
| 473 |
|
---|
| 474 | char szNextVariable[VN_SIZE];
|
---|
| 475 | void OpcodeFor(char *Parameter){
|
---|
| 476 | extern HANDLE hHeap;
|
---|
[241] | 477 | int i,i2;
|
---|
[3] | 478 | char temporary[VN_SIZE],variable[VN_SIZE],JudgeNum[VN_SIZE],StepNum[VN_SIZE];
|
---|
| 479 |
|
---|
| 480 | //第1パラメータを取得
|
---|
| 481 | i=GetOneParameter(Parameter,0,temporary);
|
---|
| 482 | if(!Parameter[i]){
|
---|
| 483 | SetError(12,"For",cp);
|
---|
| 484 | goto ErrorStep;
|
---|
| 485 | }
|
---|
| 486 |
|
---|
| 487 | for(i2=0;;i2++){
|
---|
| 488 | if(temporary[i2]=='='){
|
---|
| 489 | variable[i2]=0;
|
---|
| 490 |
|
---|
| 491 | //カウンタ初期化
|
---|
| 492 | OpcodeCalc(temporary);
|
---|
| 493 | break;
|
---|
| 494 | }
|
---|
| 495 | if(temporary[i2]=='\0'){
|
---|
| 496 | SetError(12,"For",cp);
|
---|
| 497 | goto ErrorStep;
|
---|
| 498 | }
|
---|
| 499 | variable[i2]=temporary[i2];
|
---|
| 500 | }
|
---|
| 501 |
|
---|
| 502 | //jmp ...
|
---|
[248] | 503 | const PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );
|
---|
[3] | 504 |
|
---|
| 505 | //Continueアドレスのバックアップとセット
|
---|
[241] | 506 | compiler.codeGenerator.ContinueAreaBegin();
|
---|
[3] | 507 |
|
---|
| 508 | //第2パラメータを取得(to~)
|
---|
| 509 | i=GetOneParameter(Parameter,i,JudgeNum);
|
---|
| 510 |
|
---|
| 511 | //第3パラメータを取得(step~)
|
---|
| 512 | if(Parameter[i]){
|
---|
| 513 | i=GetOneParameter(Parameter,i,StepNum);
|
---|
| 514 | if(Parameter[i]) SetError(12,"For",cp);
|
---|
| 515 | }
|
---|
| 516 | else lstrcpy(StepNum,"1");
|
---|
| 517 |
|
---|
| 518 | //カウンタを増加させる
|
---|
| 519 | sprintf(temporary,"%s=(%s)+(%s)",variable,variable,StepNum);
|
---|
| 520 | OpcodeCalc(temporary);
|
---|
| 521 |
|
---|
[241] | 522 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule );
|
---|
[3] | 523 |
|
---|
| 524 | //増加か減少かを区別する
|
---|
| 525 | sprintf(temporary,"(%s)>=0",StepNum);
|
---|
[76] | 526 | NumOpe(temporary,Type(),Type());
|
---|
[3] | 527 |
|
---|
| 528 | //pop eax
|
---|
[225] | 529 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 530 |
|
---|
| 531 | //cmp eax,0
|
---|
[236] | 532 | compiler.codeGenerator.op_cmp_value( sizeof(long), REG_EAX, 0 );
|
---|
[3] | 533 |
|
---|
| 534 | //je [カウンタ減少の場合の判定]
|
---|
[241] | 535 | pTempPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true );
|
---|
[3] | 536 |
|
---|
| 537 | //判定(カウンタ増加の場合)
|
---|
| 538 | sprintf(temporary,"%s<=(%s)",variable,JudgeNum);
|
---|
[76] | 539 | NumOpe(temporary,Type(),Type());
|
---|
[3] | 540 |
|
---|
| 541 | //pop eax
|
---|
[225] | 542 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 543 |
|
---|
| 544 | //jmp [カウンタ減少の場合の判定を飛び越す]
|
---|
[248] | 545 | const PertialSchedule *pTempPertialSchedule2 = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );
|
---|
[3] | 546 |
|
---|
[241] | 547 | //jeジャンプ先のオフセット値
|
---|
| 548 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule );
|
---|
[3] | 549 |
|
---|
| 550 | //判定(カウンタ減少の場合)
|
---|
| 551 | sprintf(temporary,"%s>=(%s)",variable,JudgeNum);
|
---|
[76] | 552 | NumOpe(temporary,Type(),Type());
|
---|
[3] | 553 |
|
---|
| 554 | //pop eax
|
---|
[225] | 555 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 556 |
|
---|
[241] | 557 | //jmpジャンプ先のオフセット値
|
---|
| 558 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule2 );
|
---|
[3] | 559 |
|
---|
| 560 | //cmp eax,0
|
---|
[236] | 561 | compiler.codeGenerator.op_cmp_value( sizeof(long), REG_EAX, 0 );
|
---|
[3] | 562 |
|
---|
| 563 | ErrorStep:
|
---|
| 564 |
|
---|
| 565 | //je ...
|
---|
[241] | 566 | pTempPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true );
|
---|
[3] | 567 |
|
---|
| 568 | //レキシカルスコープをレベルアップ
|
---|
[276] | 569 | compiler.codeGenerator.lexicalScopes.Start( compiler.codeGenerator.GetNativeCodeSize(), LexicalScope::SCOPE_TYPE_FOR );
|
---|
[3] | 570 |
|
---|
| 571 | //For内をコンパイル
|
---|
| 572 | CompileBuffer(0,COM_NEXT);
|
---|
| 573 |
|
---|
[248] | 574 | compiler.codeGenerator.lexicalScopes.CallDestructorsOfScopeEnd();
|
---|
[3] | 575 |
|
---|
| 576 | if(szNextVariable[0]){
|
---|
| 577 | if(lstrcmp(szNextVariable,variable)!=0){
|
---|
| 578 | SetError(55,szNextVariable,cp);
|
---|
| 579 | }
|
---|
| 580 | }
|
---|
| 581 |
|
---|
| 582 | //jmp ...
|
---|
[241] | 583 | compiler.codeGenerator.op_jmp_continue();
|
---|
[3] | 584 |
|
---|
| 585 | //レキシカルスコープをレベルダウン
|
---|
[248] | 586 | compiler.codeGenerator.lexicalScopes.End();
|
---|
[3] | 587 |
|
---|
[241] | 588 | //jeジャンプ先のオフセット値
|
---|
| 589 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule );
|
---|
[3] | 590 |
|
---|
| 591 | //Continueアドレスを復元
|
---|
[241] | 592 | compiler.codeGenerator.ContinueAreaEnd();
|
---|
[3] | 593 | }
|
---|
| 594 |
|
---|
[372] | 595 | void OpcodeForeach( const char *Parameter )
|
---|
| 596 | {
|
---|
| 597 | Type resultType;
|
---|
| 598 | int i;
|
---|
| 599 | char temporary[VN_SIZE],variable[VN_SIZE],collectionVar[VN_SIZE];
|
---|
| 600 | bool isError = false;
|
---|
| 601 |
|
---|
| 602 | //第1パラメータを取得
|
---|
| 603 | i=GetOneParameter(Parameter,0,temporary);
|
---|
| 604 | if(!Parameter[i]){
|
---|
| 605 | SetError(12,"Foreach",cp);
|
---|
| 606 | isError = true;
|
---|
| 607 | goto ErrorStep;
|
---|
| 608 | }
|
---|
| 609 |
|
---|
| 610 | lstrcpy( variable, temporary );
|
---|
| 611 |
|
---|
| 612 | //第2パラメータを取得(in~)
|
---|
| 613 | i=GetOneParameter(Parameter,i,collectionVar);
|
---|
| 614 |
|
---|
| 615 | // Resetメソッドを呼び出す
|
---|
| 616 | sprintf( temporary, "%s.Reset()", collectionVar );
|
---|
| 617 | Compile( temporary );
|
---|
| 618 |
|
---|
| 619 | //Continueアドレスのバックアップとセット
|
---|
| 620 | compiler.codeGenerator.ContinueAreaBegin();
|
---|
| 621 |
|
---|
| 622 | // MoveNextメソッドを呼び出す
|
---|
| 623 | sprintf( temporary, "%s.MoveNext()", collectionVar );
|
---|
| 624 | NumOpe(temporary,Type(),Type());
|
---|
| 625 |
|
---|
| 626 | //pop eax
|
---|
| 627 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
| 628 |
|
---|
| 629 | //cmp eax,0
|
---|
| 630 | compiler.codeGenerator.op_cmp_value( sizeof(long), REG_EAX, 0 );
|
---|
| 631 |
|
---|
| 632 | ErrorStep:
|
---|
| 633 |
|
---|
| 634 | //je ...
|
---|
| 635 | const PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(long), true );
|
---|
| 636 |
|
---|
| 637 | //レキシカルスコープをレベルアップ
|
---|
| 638 | compiler.codeGenerator.lexicalScopes.Start( compiler.codeGenerator.GetNativeCodeSize(), LexicalScope::SCOPE_TYPE_FOR );
|
---|
| 639 |
|
---|
| 640 | // Currentプロパティから現在の値を取得
|
---|
| 641 | // TODO: 型指定が未完成
|
---|
| 642 | sprintf( temporary, "%s=%s.Current As String", variable, collectionVar );
|
---|
| 643 | Compile( temporary );
|
---|
| 644 |
|
---|
| 645 | //For内をコンパイル
|
---|
| 646 | CompileBuffer(0,COM_NEXT);
|
---|
| 647 |
|
---|
| 648 | compiler.codeGenerator.lexicalScopes.CallDestructorsOfScopeEnd();
|
---|
| 649 |
|
---|
| 650 | if(szNextVariable[0]){
|
---|
| 651 | if(lstrcmp(szNextVariable,variable)!=0){
|
---|
| 652 | SetError(55,szNextVariable,cp);
|
---|
| 653 | }
|
---|
| 654 | }
|
---|
| 655 |
|
---|
| 656 | //jmp ...
|
---|
| 657 | compiler.codeGenerator.op_jmp_continue();
|
---|
| 658 |
|
---|
| 659 | //レキシカルスコープをレベルダウン
|
---|
| 660 | compiler.codeGenerator.lexicalScopes.End();
|
---|
| 661 |
|
---|
| 662 | //jeジャンプ先のオフセット値
|
---|
| 663 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule );
|
---|
| 664 |
|
---|
| 665 | //Continueアドレスを復元
|
---|
| 666 | compiler.codeGenerator.ContinueAreaEnd();
|
---|
| 667 | }
|
---|
| 668 |
|
---|
[3] | 669 | void OpcodeDo(char *Parameter){
|
---|
| 670 | extern HANDLE hHeap;
|
---|
[247] | 671 | int i,i2,i3;
|
---|
[3] | 672 |
|
---|
| 673 | if(Parameter[0]) SetError(10,"Do",cp);
|
---|
| 674 |
|
---|
| 675 | //Continueアドレスのバックアップとセット
|
---|
[241] | 676 | compiler.codeGenerator.ContinueAreaBegin();
|
---|
[3] | 677 |
|
---|
| 678 | //レキシカルスコープをレベルアップ
|
---|
[276] | 679 | compiler.codeGenerator.lexicalScopes.Start( compiler.codeGenerator.GetNativeCodeSize(), LexicalScope::SCOPE_TYPE_DO );
|
---|
[3] | 680 |
|
---|
| 681 | //Do内をコンパイル
|
---|
| 682 | CompileBuffer(0,COM_LOOP);
|
---|
| 683 |
|
---|
[248] | 684 | compiler.codeGenerator.lexicalScopes.CallDestructorsOfScopeEnd();
|
---|
[3] | 685 |
|
---|
[248] | 686 | const PertialSchedule *pDoPertialSchedule = NULL;
|
---|
[241] | 687 |
|
---|
[3] | 688 | extern char *basbuf;
|
---|
| 689 | char temporary[VN_SIZE];
|
---|
| 690 | for(i=cp-1;;i--){
|
---|
| 691 | if(IsCommandDelimitation(basbuf[i])){
|
---|
| 692 | i+=3;
|
---|
| 693 | if(!(basbuf[i]=='0'||basbuf[i]=='1')){
|
---|
| 694 | //無条件ループ
|
---|
| 695 | break;
|
---|
| 696 | }
|
---|
| 697 | i3=i;
|
---|
| 698 |
|
---|
| 699 | for(i+=2,i2=0;;i++,i2++){
|
---|
| 700 | if(IsCommandDelimitation(basbuf[i])){
|
---|
| 701 | temporary[i2]=0;
|
---|
| 702 | break;
|
---|
| 703 | }
|
---|
| 704 | temporary[i2]=basbuf[i];
|
---|
| 705 | }
|
---|
| 706 |
|
---|
[76] | 707 | Type tempType;
|
---|
| 708 | NumOpe(temporary,Type(),tempType);
|
---|
[3] | 709 |
|
---|
[76] | 710 | if( tempType.IsDouble() ){
|
---|
[3] | 711 | //fld qword ptr[esp]
|
---|
[225] | 712 | compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
|
---|
[3] | 713 |
|
---|
| 714 | //push 0
|
---|
[225] | 715 | compiler.codeGenerator.op_push_V(0);
|
---|
[3] | 716 |
|
---|
| 717 | //fild dword ptr[esp]
|
---|
[225] | 718 | compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
|
---|
[3] | 719 |
|
---|
| 720 | //add esp,sizeof(double)+sizeof(long)
|
---|
[225] | 721 | compiler.codeGenerator.op_add_esp(sizeof(double)+sizeof(long));
|
---|
[3] | 722 |
|
---|
| 723 | //fcompp
|
---|
[225] | 724 | compiler.codeGenerator.op_fcompp();
|
---|
[3] | 725 |
|
---|
| 726 | //fnstsw ax
|
---|
[225] | 727 | compiler.codeGenerator.op_fnstsw_ax();
|
---|
[3] | 728 |
|
---|
| 729 | //test ah,40
|
---|
[225] | 730 | compiler.codeGenerator.op_test_ah( (char)0x40 );
|
---|
[3] | 731 |
|
---|
| 732 | if(basbuf[i3]=='0'){
|
---|
| 733 | //While
|
---|
| 734 |
|
---|
| 735 | //jne 5(ループ終了)
|
---|
[241] | 736 | pDoPertialSchedule = compiler.codeGenerator.op_jne( 0, sizeof(char), true );
|
---|
[3] | 737 | }
|
---|
| 738 | else if(basbuf[i3]=='1'){
|
---|
| 739 | //Until
|
---|
| 740 |
|
---|
| 741 | //je 5(ループ終了)
|
---|
[241] | 742 | pDoPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(char), true );
|
---|
[3] | 743 | }
|
---|
| 744 | }
|
---|
[76] | 745 | else if( tempType.IsSingle() ){
|
---|
[3] | 746 | //fld dword ptr[esp]
|
---|
[225] | 747 | compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
|
---|
[3] | 748 |
|
---|
| 749 | //push 0
|
---|
[225] | 750 | compiler.codeGenerator.op_push_V(0);
|
---|
[3] | 751 |
|
---|
| 752 | //fild dword ptr[esp]
|
---|
[225] | 753 | compiler.codeGenerator.op_fld_ptr_esp(DEF_LONG);
|
---|
[3] | 754 |
|
---|
| 755 | //add esp,sizeof(float)+sizeof(long)
|
---|
[225] | 756 | compiler.codeGenerator.op_add_esp(sizeof(float)+sizeof(long));
|
---|
[3] | 757 |
|
---|
| 758 | //fcompp
|
---|
[225] | 759 | compiler.codeGenerator.op_fcompp();
|
---|
[3] | 760 |
|
---|
| 761 | //fnstsw ax
|
---|
[225] | 762 | compiler.codeGenerator.op_fnstsw_ax();
|
---|
[3] | 763 |
|
---|
| 764 | //test ah,40
|
---|
[225] | 765 | compiler.codeGenerator.op_test_ah( (char)0x40 );
|
---|
[3] | 766 |
|
---|
| 767 | if(basbuf[i3]=='0'){
|
---|
| 768 | //While
|
---|
| 769 |
|
---|
| 770 | //jne 5(ループ終了)
|
---|
[241] | 771 | pDoPertialSchedule = compiler.codeGenerator.op_jne( 0, sizeof(char), true );
|
---|
[3] | 772 | }
|
---|
| 773 | else if(basbuf[i3]=='1'){
|
---|
| 774 | //Until
|
---|
| 775 |
|
---|
| 776 | //je 5(ループ終了)
|
---|
[241] | 777 | pDoPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(char), true );
|
---|
[3] | 778 | }
|
---|
| 779 | }
|
---|
[76] | 780 | else if( tempType.Is64() ){
|
---|
[3] | 781 | //64ビット型
|
---|
| 782 |
|
---|
| 783 | //pop eax
|
---|
[225] | 784 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 785 |
|
---|
| 786 | //pop ebx
|
---|
[225] | 787 | compiler.codeGenerator.op_pop(REG_EBX);
|
---|
[3] | 788 |
|
---|
| 789 | //cmp eax,0
|
---|
[236] | 790 | compiler.codeGenerator.op_cmp_value( sizeof(long), REG_EAX, 0 );
|
---|
[3] | 791 |
|
---|
| 792 | //jne
|
---|
[248] | 793 | const PertialSchedule *pTempPertialSchedule1 = compiler.codeGenerator.op_jne( 0, sizeof(char), true );
|
---|
[3] | 794 |
|
---|
| 795 | //cmp ebx,0
|
---|
[236] | 796 | compiler.codeGenerator.op_cmp_value( sizeof(long), REG_EBX, 0 );
|
---|
[3] | 797 |
|
---|
| 798 | //jne
|
---|
[248] | 799 | const PertialSchedule *pTempPertialSchedule2 = compiler.codeGenerator.op_jne( 0, sizeof(char), true );
|
---|
[3] | 800 |
|
---|
| 801 | if(basbuf[i3]=='0'){
|
---|
| 802 | //While
|
---|
| 803 |
|
---|
| 804 | //jmp 5(ループ終了)
|
---|
[241] | 805 | pDoPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(char), true );
|
---|
[3] | 806 |
|
---|
[247] | 807 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule1 );
|
---|
| 808 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule2 );
|
---|
[3] | 809 | }
|
---|
| 810 | else if(basbuf[i3]=='1'){
|
---|
| 811 | //Until
|
---|
| 812 |
|
---|
| 813 | //jmp 2(ループを続ける)
|
---|
[248] | 814 | const PertialSchedule *pTempPertialSchedule3 = compiler.codeGenerator.op_jmp( 0, sizeof(char), true );
|
---|
[3] | 815 |
|
---|
[247] | 816 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule1 );
|
---|
| 817 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule2 );
|
---|
[3] | 818 |
|
---|
| 819 | //jmp 5(ループ終了)
|
---|
[241] | 820 | pDoPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(char), true );
|
---|
[247] | 821 |
|
---|
| 822 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule3 );
|
---|
[3] | 823 | }
|
---|
| 824 | }
|
---|
| 825 | else{
|
---|
| 826 | //pop eax
|
---|
[225] | 827 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 828 |
|
---|
| 829 | //cmp eax,0
|
---|
[236] | 830 | compiler.codeGenerator.op_cmp_value( sizeof(long), REG_EAX, 0 );
|
---|
[3] | 831 |
|
---|
| 832 | if(basbuf[i3]=='0'){
|
---|
| 833 | //While
|
---|
| 834 |
|
---|
| 835 | //je 5(ループ終了)
|
---|
[241] | 836 | pDoPertialSchedule = compiler.codeGenerator.op_je( 0, sizeof(char), true );
|
---|
[3] | 837 | }
|
---|
| 838 | else if(basbuf[i3]=='1'){
|
---|
| 839 | //Until
|
---|
| 840 |
|
---|
| 841 | //jne 5(ループ終了)
|
---|
[241] | 842 | pDoPertialSchedule = compiler.codeGenerator.op_jne( 0, sizeof(char), true );
|
---|
[3] | 843 | }
|
---|
| 844 | }
|
---|
| 845 | break;
|
---|
| 846 | }
|
---|
| 847 | }
|
---|
| 848 |
|
---|
| 849 | //jmp ...
|
---|
[241] | 850 | compiler.codeGenerator.op_jmp_continue();
|
---|
[3] | 851 |
|
---|
[241] | 852 | if( pDoPertialSchedule )
|
---|
| 853 | {
|
---|
| 854 | compiler.codeGenerator.opfix_JmpPertialSchedule( pDoPertialSchedule );
|
---|
| 855 | }
|
---|
| 856 |
|
---|
[3] | 857 | //jmp ...
|
---|
[248] | 858 | const PertialSchedule *pTempPertialSchedule = compiler.codeGenerator.op_jmp( 0, sizeof(long), true );
|
---|
[3] | 859 |
|
---|
| 860 | //レキシカルスコープをレベルダウン
|
---|
[248] | 861 | compiler.codeGenerator.lexicalScopes.End();
|
---|
[3] | 862 |
|
---|
[243] | 863 | //jmpジャンプ先のオフセット値
|
---|
| 864 | compiler.codeGenerator.opfix_JmpPertialSchedule( pTempPertialSchedule );
|
---|
[3] | 865 |
|
---|
| 866 | //Continueアドレスを復元
|
---|
[241] | 867 | compiler.codeGenerator.ContinueAreaEnd();
|
---|
[3] | 868 | }
|
---|
| 869 | void OpcodeContinue(void){
|
---|
| 870 | //jmp ...(Continue addr)
|
---|
[241] | 871 | compiler.codeGenerator.op_jmp_continue();
|
---|
[3] | 872 | }
|
---|
| 873 |
|
---|
| 874 | void OpcodeExitSub(void){
|
---|
[76] | 875 | if( UserProc::IsGlobalAreaCompiling() ){
|
---|
[3] | 876 | SetError(12,"Exit Sub/Function",cp);
|
---|
| 877 | return;
|
---|
| 878 | }
|
---|
| 879 |
|
---|
[34] | 880 | //未解放のローカルオブジェクトのデストラクタを呼び出す
|
---|
[248] | 881 | compiler.codeGenerator.lexicalScopes.CallDestructorsOfReturn();
|
---|
[34] | 882 |
|
---|
[3] | 883 | //jmp ...(End Sub/Function)
|
---|
[247] | 884 | compiler.codeGenerator.op_jmp_exitsub();
|
---|
[3] | 885 | }
|
---|
| 886 |
|
---|
[250] | 887 | //Caseスケジュール
|
---|
| 888 | class SelectSchedule
|
---|
| 889 | {
|
---|
| 890 | public:
|
---|
| 891 | SelectSchedule( int typeSize )
|
---|
| 892 | : typeSize( typeSize )
|
---|
| 893 | , nowCaseSchedule( 0 )
|
---|
| 894 | {
|
---|
| 895 | }
|
---|
[3] | 896 |
|
---|
[250] | 897 | PertialSchedules casePertialSchedules;
|
---|
| 898 | int typeSize;
|
---|
| 899 | int nowCaseSchedule;
|
---|
| 900 | };
|
---|
| 901 | std::vector<SelectSchedule> selectSchedules;
|
---|
[3] | 902 |
|
---|
[76] | 903 | void OpcodeSelect(const char *lpszParms){
|
---|
[3] | 904 | extern HANDLE hHeap;
|
---|
| 905 | extern char *basbuf;
|
---|
[76] | 906 | int i,i2,i3,sw,NowCaseCp;
|
---|
[3] | 907 | char temporary[VN_SIZE];
|
---|
[250] | 908 |
|
---|
[76] | 909 | Type type1;
|
---|
| 910 | if( !NumOpe(lpszParms,Type(), type1 ) ){
|
---|
| 911 | return;
|
---|
[3] | 912 | }
|
---|
| 913 |
|
---|
[250] | 914 | selectSchedules.push_back( SelectSchedule( type1.GetSize() ) );
|
---|
| 915 |
|
---|
| 916 | if( selectSchedules.back().typeSize < sizeof(long) ){
|
---|
| 917 | selectSchedules.back().typeSize = sizeof(long);
|
---|
[76] | 918 | }
|
---|
| 919 |
|
---|
[3] | 920 | for(i=cp,sw=0;;i++){
|
---|
| 921 | if(basbuf[i]=='\0'){
|
---|
[250] | 922 | selectSchedules.pop_back();
|
---|
[3] | 923 | SetError(22,"Select",cp);
|
---|
| 924 | return;
|
---|
| 925 | }
|
---|
| 926 | if(basbuf[i]==1&&basbuf[i+1]==ESC_SELECTCASE){
|
---|
| 927 | for(i2=0;;i++){
|
---|
| 928 | if(basbuf[i]==1&&basbuf[i+1]==ESC_SELECTCASE) i2++;
|
---|
| 929 | if(basbuf[i]==1&&basbuf[i+1]==ESC_ENDSELECT){
|
---|
| 930 | i2--;
|
---|
| 931 | if(i2==0) break;
|
---|
| 932 | }
|
---|
| 933 | }
|
---|
| 934 | continue;
|
---|
| 935 | }
|
---|
| 936 | if(basbuf[i]==1&&basbuf[i+1]==ESC_ENDSELECT){
|
---|
| 937 | if(sw==0){
|
---|
| 938 | //add esp,CaseTypeSize
|
---|
[250] | 939 | compiler.codeGenerator.op_add_esp( selectSchedules.back().typeSize );
|
---|
[3] | 940 | }
|
---|
| 941 | break;
|
---|
| 942 | }
|
---|
| 943 | if(basbuf[i]==1&&basbuf[i+1]==ESC_CASE){
|
---|
| 944 | NowCaseCp=i;
|
---|
| 945 |
|
---|
| 946 | i++;
|
---|
| 947 | while(1){
|
---|
| 948 | for(i++,i2=0;;i++,i2++){
|
---|
| 949 | if(basbuf[i]=='\"'){
|
---|
| 950 | i3=GetStringInQuotation(temporary+i2,basbuf+i);
|
---|
| 951 | i+=i3-1;
|
---|
| 952 | i2+=i3-1;
|
---|
| 953 | continue;
|
---|
| 954 | }
|
---|
| 955 | if(basbuf[i]=='('){
|
---|
| 956 | i3=GetStringInPare(temporary+i2,basbuf+i);
|
---|
| 957 | i+=i3-1;
|
---|
| 958 | i2+=i3-1;
|
---|
| 959 | continue;
|
---|
| 960 | }
|
---|
| 961 | if(basbuf[i]=='['){
|
---|
| 962 | i3=GetStringInBracket(temporary+i2,basbuf+i);
|
---|
| 963 | i+=i3-1;
|
---|
| 964 | i2+=i3-1;
|
---|
| 965 | continue;
|
---|
| 966 | }
|
---|
| 967 |
|
---|
| 968 | if(IsCommandDelimitation(basbuf[i])){
|
---|
| 969 | temporary[i2]=0;
|
---|
| 970 | break;
|
---|
| 971 | }
|
---|
| 972 | if(basbuf[i]==','){
|
---|
| 973 | temporary[i2]=0;
|
---|
| 974 | break;
|
---|
| 975 | }
|
---|
| 976 |
|
---|
| 977 | temporary[i2]=basbuf[i];
|
---|
| 978 | }
|
---|
| 979 |
|
---|
| 980 | //エラー用
|
---|
| 981 | i2=cp;
|
---|
| 982 | cp=NowCaseCp;
|
---|
| 983 |
|
---|
[76] | 984 | Type type2;
|
---|
| 985 | if( !NumOpe(temporary,type1,type2) ){
|
---|
| 986 | return;
|
---|
| 987 | }
|
---|
[3] | 988 |
|
---|
| 989 | cp=i2;
|
---|
| 990 |
|
---|
[76] | 991 | if(type1.IsObject()){
|
---|
[206] | 992 | std::vector<const UserProc *> subs;
|
---|
[342] | 993 | type1.GetClass().GetDynamicMethods().Enum( CALC_EQUAL, subs );
|
---|
[50] | 994 | if( subs.size() == 0 ){
|
---|
[3] | 995 | return;
|
---|
| 996 | }
|
---|
| 997 |
|
---|
[75] | 998 | Parameters params;
|
---|
[76] | 999 | params.push_back( new Parameter( "", Type( type2 ) ) );
|
---|
[3] | 1000 |
|
---|
| 1001 | //オーバーロードを解決
|
---|
[206] | 1002 | const UserProc *pUserProc = OverloadSolution("==",subs, params, NULL);
|
---|
[3] | 1003 |
|
---|
[75] | 1004 | delete params[0];
|
---|
| 1005 |
|
---|
| 1006 | if(!pUserProc){
|
---|
[3] | 1007 | //エラー
|
---|
| 1008 | return;
|
---|
| 1009 | }
|
---|
| 1010 |
|
---|
| 1011 |
|
---|
| 1012 | //pop edx
|
---|
[225] | 1013 | compiler.codeGenerator.op_pop(REG_EDX);
|
---|
[3] | 1014 |
|
---|
| 1015 | //mov ecx,dword ptr[esp]
|
---|
[225] | 1016 | compiler.codeGenerator.op_mov_RM(sizeof(long),REG_ECX,REG_ESP,0,MOD_BASE);
|
---|
[3] | 1017 |
|
---|
| 1018 | //push edx
|
---|
[225] | 1019 | compiler.codeGenerator.op_push(REG_EDX);
|
---|
[3] | 1020 |
|
---|
| 1021 | //push ecx
|
---|
[225] | 1022 | compiler.codeGenerator.op_push(REG_ECX);
|
---|
[3] | 1023 |
|
---|
| 1024 | //call operator_proc ※ ==演算子
|
---|
[225] | 1025 | compiler.codeGenerator.op_call(pUserProc);
|
---|
[3] | 1026 |
|
---|
| 1027 | //test eax,eax
|
---|
[225] | 1028 | compiler.codeGenerator.op_test(REG_EAX,REG_EAX);
|
---|
[3] | 1029 |
|
---|
| 1030 | //jne ...
|
---|
[250] | 1031 | selectSchedules.back().casePertialSchedules.push_back(
|
---|
| 1032 | compiler.codeGenerator.op_jne( 0, sizeof(long), true )
|
---|
| 1033 | );
|
---|
[3] | 1034 | }
|
---|
[76] | 1035 | else if(type1.IsDouble()){
|
---|
| 1036 | ChangeTypeToDouble(type2.GetBasicType());
|
---|
[3] | 1037 |
|
---|
| 1038 | //fld qword ptr[esp]
|
---|
[225] | 1039 | compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
|
---|
[3] | 1040 |
|
---|
| 1041 | //add esp,CaseTypeSize
|
---|
[250] | 1042 | compiler.codeGenerator.op_add_esp(selectSchedules.back().typeSize);
|
---|
[3] | 1043 |
|
---|
| 1044 | //fld qword ptr[esp]
|
---|
[225] | 1045 | compiler.codeGenerator.op_fld_ptr_esp(DEF_DOUBLE);
|
---|
[3] | 1046 |
|
---|
| 1047 | //fcompp
|
---|
[225] | 1048 | compiler.codeGenerator.op_fcompp();
|
---|
[3] | 1049 |
|
---|
| 1050 | //fnstsw ax
|
---|
[225] | 1051 | compiler.codeGenerator.op_fnstsw_ax();
|
---|
[3] | 1052 |
|
---|
| 1053 | //test ah,40
|
---|
[225] | 1054 | compiler.codeGenerator.op_test_ah( (char)0x40 );
|
---|
[3] | 1055 |
|
---|
| 1056 | //jne ...
|
---|
[250] | 1057 | selectSchedules.back().casePertialSchedules.push_back(
|
---|
| 1058 | compiler.codeGenerator.op_jne( 0, sizeof(long), true )
|
---|
| 1059 | );
|
---|
[3] | 1060 | }
|
---|
[76] | 1061 | else if(type1.IsSingle()){
|
---|
| 1062 | ChangeTypeToSingle(type2.GetBasicType());
|
---|
[3] | 1063 |
|
---|
| 1064 | //fld dword ptr[esp]
|
---|
[225] | 1065 | compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
|
---|
[3] | 1066 |
|
---|
| 1067 | //add esp,CaseTypeSize
|
---|
[250] | 1068 | compiler.codeGenerator.op_add_esp(selectSchedules.back().typeSize);
|
---|
[3] | 1069 |
|
---|
| 1070 | //fld dword ptr[esp]
|
---|
[225] | 1071 | compiler.codeGenerator.op_fld_ptr_esp(DEF_SINGLE);
|
---|
[3] | 1072 |
|
---|
| 1073 | //fcompp
|
---|
[225] | 1074 | compiler.codeGenerator.op_fcompp();
|
---|
[3] | 1075 |
|
---|
| 1076 | //fnstsw ax
|
---|
[225] | 1077 | compiler.codeGenerator.op_fnstsw_ax();
|
---|
[3] | 1078 |
|
---|
| 1079 | //test ah,40
|
---|
[225] | 1080 | compiler.codeGenerator.op_test_ah( (char)0x40 );
|
---|
[3] | 1081 |
|
---|
| 1082 | //jne ...
|
---|
[250] | 1083 | selectSchedules.back().casePertialSchedules.push_back(
|
---|
| 1084 | compiler.codeGenerator.op_jne( 0, sizeof(long), true )
|
---|
| 1085 | );
|
---|
[3] | 1086 | }
|
---|
| 1087 | else{
|
---|
| 1088 | //その他整数型
|
---|
| 1089 |
|
---|
| 1090 | //pop ebx
|
---|
[225] | 1091 | compiler.codeGenerator.op_pop(REG_EBX);
|
---|
[3] | 1092 |
|
---|
| 1093 | //mov eax,dword ptr[esp]
|
---|
[236] | 1094 | compiler.codeGenerator.op_mov_RM( sizeof(long), REG_EAX, REG_ESP, 0, MOD_BASE );
|
---|
[3] | 1095 |
|
---|
| 1096 | //cmp eax,ebx
|
---|
[227] | 1097 | compiler.codeGenerator.op_cmp_RR( REG_EAX, REG_EBX );
|
---|
[3] | 1098 |
|
---|
| 1099 | //je ...
|
---|
[250] | 1100 | selectSchedules.back().casePertialSchedules.push_back(
|
---|
| 1101 | compiler.codeGenerator.op_je( 0, sizeof(long), true )
|
---|
| 1102 | );
|
---|
[3] | 1103 | }
|
---|
| 1104 |
|
---|
| 1105 | if(basbuf[i]!=',') break;
|
---|
| 1106 | }
|
---|
| 1107 | }
|
---|
| 1108 | if(basbuf[i]==1&&basbuf[i+1]==ESC_CASEELSE){
|
---|
| 1109 | sw=1;
|
---|
| 1110 |
|
---|
| 1111 | //jmp ...
|
---|
[250] | 1112 | selectSchedules.back().casePertialSchedules.push_back(
|
---|
| 1113 | compiler.codeGenerator.op_jmp( 0, sizeof(long), true )
|
---|
| 1114 | );
|
---|
[3] | 1115 | }
|
---|
| 1116 | }
|
---|
| 1117 |
|
---|
| 1118 | //レキシカルスコープをレベルアップ
|
---|
[276] | 1119 | compiler.codeGenerator.lexicalScopes.Start( compiler.codeGenerator.GetNativeCodeSize(), LexicalScope::SCOPE_TYPE_SELECT );
|
---|
[3] | 1120 |
|
---|
| 1121 | //Select Case内をコンパイル
|
---|
| 1122 | CompileBuffer(ESC_ENDSELECT,0);
|
---|
| 1123 |
|
---|
| 1124 | //jmp EndSelect
|
---|
[250] | 1125 | selectSchedules.back().casePertialSchedules.push_back(
|
---|
| 1126 | compiler.codeGenerator.op_jmp( 0, sizeof(long), true )
|
---|
| 1127 | );
|
---|
[3] | 1128 |
|
---|
| 1129 | //最終スケジュール
|
---|
[250] | 1130 | for(i=selectSchedules.back().nowCaseSchedule;i<(int)selectSchedules.back().casePertialSchedules.size();i++){
|
---|
| 1131 | compiler.codeGenerator.opfix_JmpPertialSchedule( selectSchedules.back().casePertialSchedules[i] );
|
---|
[3] | 1132 | }
|
---|
| 1133 |
|
---|
| 1134 | //レキシカルスコープをレベルダウン
|
---|
[248] | 1135 | compiler.codeGenerator.lexicalScopes.End();
|
---|
[3] | 1136 |
|
---|
[250] | 1137 | selectSchedules.pop_back();
|
---|
[3] | 1138 | }
|
---|
| 1139 | void OpcodeCase(char *Parameter){
|
---|
| 1140 | int i;
|
---|
| 1141 |
|
---|
[250] | 1142 | if(selectSchedules.back().typeSize==-1){
|
---|
[3] | 1143 | SetError(30,"Case",cp);
|
---|
| 1144 | return;
|
---|
| 1145 | }
|
---|
| 1146 |
|
---|
| 1147 | //jmp EndSelect
|
---|
[250] | 1148 | selectSchedules.back().casePertialSchedules.push_back(
|
---|
| 1149 | compiler.codeGenerator.op_jmp( 0, sizeof(long), true )
|
---|
| 1150 | );
|
---|
[3] | 1151 |
|
---|
| 1152 | i=0;
|
---|
| 1153 | while(1){
|
---|
| 1154 | //Caseスケジュール
|
---|
[250] | 1155 | compiler.codeGenerator.opfix_JmpPertialSchedule( selectSchedules.back().casePertialSchedules[selectSchedules.back().nowCaseSchedule] );
|
---|
| 1156 | selectSchedules.back().nowCaseSchedule++;
|
---|
[3] | 1157 |
|
---|
| 1158 | i=JumpOneParameter(Parameter,i);
|
---|
| 1159 | if(Parameter[i]=='\0') break;
|
---|
| 1160 | }
|
---|
| 1161 |
|
---|
| 1162 | //add esp,CaseTypeSize
|
---|
[250] | 1163 | compiler.codeGenerator.op_add_esp(selectSchedules.back().typeSize);
|
---|
[3] | 1164 | }
|
---|
| 1165 |
|
---|
| 1166 | void OpcodeGosub(char *Parameter){
|
---|
| 1167 | extern HANDLE hHeap;
|
---|
| 1168 | int i,LineNum;
|
---|
| 1169 |
|
---|
| 1170 | if(Parameter[0]=='*'){
|
---|
| 1171 | i=GetLabelAddress(Parameter+1,0);
|
---|
| 1172 |
|
---|
[246] | 1173 | if( i == -1 )
|
---|
| 1174 | {
|
---|
| 1175 | //jmp ...(schedule)
|
---|
[253] | 1176 | compiler.codeGenerator.op_jmp_goto_schedule( (const std::string)(Parameter + 1), 0, cp );
|
---|
[3] | 1177 | }
|
---|
[246] | 1178 | else
|
---|
| 1179 | {
|
---|
| 1180 | //jmp ...
|
---|
[276] | 1181 | compiler.codeGenerator.op_jmp(
|
---|
| 1182 | i-compiler.codeGenerator.GetNativeCodeSize(),
|
---|
| 1183 | sizeof(long),
|
---|
| 1184 | false,
|
---|
| 1185 | true
|
---|
| 1186 | );
|
---|
[246] | 1187 | }
|
---|
[3] | 1188 | }
|
---|
| 1189 | else{
|
---|
| 1190 | LineNum=atoi(Parameter);
|
---|
| 1191 | i=GetLabelAddress(0,LineNum);
|
---|
| 1192 |
|
---|
[246] | 1193 | if( i == -1 )
|
---|
| 1194 | {
|
---|
| 1195 | //jmp ...(schedule)
|
---|
[253] | 1196 | compiler.codeGenerator.op_jmp_goto_schedule( "", LineNum, cp );
|
---|
[3] | 1197 | }
|
---|
[246] | 1198 | else
|
---|
| 1199 | {
|
---|
| 1200 | //jmp ...
|
---|
[276] | 1201 | compiler.codeGenerator.op_jmp(
|
---|
| 1202 | i-compiler.codeGenerator.GetNativeCodeSize(),
|
---|
| 1203 | sizeof(long),
|
---|
| 1204 | false,
|
---|
| 1205 | true
|
---|
| 1206 | );
|
---|
[246] | 1207 | }
|
---|
[3] | 1208 | }
|
---|
| 1209 | }
|
---|
| 1210 | void OpcodeReturn(char *Parameter){
|
---|
[76] | 1211 | if( UserProc::IsGlobalAreaCompiling() ){
|
---|
[3] | 1212 | //Gosub~Returnとして扱う
|
---|
| 1213 |
|
---|
| 1214 | //ret
|
---|
[225] | 1215 | compiler.codeGenerator.op_ret();
|
---|
[3] | 1216 | }
|
---|
| 1217 | else{
|
---|
| 1218 | //戻り値をセット
|
---|
| 1219 | if(Parameter[0]){
|
---|
[206] | 1220 | const UserProc &proc = UserProc::CompilingUserProc();
|
---|
[76] | 1221 |
|
---|
[75] | 1222 | const char *temp = "_System_ReturnValue";
|
---|
[76] | 1223 | if(proc.GetName()[0]==1&&proc.GetName()[1]==ESC_OPERATOR)
|
---|
[75] | 1224 | {
|
---|
| 1225 | }
|
---|
[76] | 1226 | else{
|
---|
| 1227 | temp=proc.GetName().c_str();
|
---|
| 1228 | }
|
---|
[3] | 1229 |
|
---|
[75] | 1230 | char temporary[VN_SIZE];
|
---|
| 1231 | sprintf(temporary,"%s=%s",temp,Parameter);
|
---|
| 1232 | OpcodeCalc(temporary);
|
---|
[3] | 1233 | }
|
---|
| 1234 |
|
---|
| 1235 | //プロシージャを抜け出す(C言語のreturnと同様の処理を行う)
|
---|
| 1236 | OpcodeExitSub();
|
---|
| 1237 | }
|
---|
| 1238 | }
|
---|
| 1239 |
|
---|
| 1240 |
|
---|
| 1241 | ////////////
|
---|
| 1242 | // ポインタ
|
---|
| 1243 |
|
---|
| 1244 | void OpcodeSetPtrData(char *Parameter,int type){
|
---|
[76] | 1245 | int i;
|
---|
[3] | 1246 | char temporary[VN_SIZE];
|
---|
| 1247 |
|
---|
| 1248 | if(Parameter[0]=='('){
|
---|
| 1249 | i=JumpStringInPare(Parameter,1);
|
---|
| 1250 | if(Parameter[i+1]=='\0'){
|
---|
| 1251 | for(i=0;;i++){
|
---|
| 1252 | Parameter[i]=Parameter[i+1];
|
---|
| 1253 | if(Parameter[i]=='\0') break;
|
---|
| 1254 | }
|
---|
| 1255 | Parameter[i-1]=0;
|
---|
| 1256 | }
|
---|
| 1257 | }
|
---|
| 1258 |
|
---|
| 1259 | //第1パラメータを取得
|
---|
| 1260 | i=GetOneParameter(Parameter,0,temporary);
|
---|
| 1261 | if(!Parameter[i]){
|
---|
| 1262 | SetError(1,NULL,cp);
|
---|
| 1263 | return;
|
---|
| 1264 | }
|
---|
| 1265 |
|
---|
[76] | 1266 | Type resultType;
|
---|
| 1267 | if( !NumOpe(temporary,Type(),resultType) ){
|
---|
| 1268 | return;
|
---|
| 1269 | }
|
---|
| 1270 | if(!resultType.IsWhole()){
|
---|
| 1271 | SetError(11,Parameter,cp);
|
---|
| 1272 | return;
|
---|
| 1273 | }
|
---|
[3] | 1274 |
|
---|
[76] | 1275 | ChangeTypeToLong( resultType.GetBasicType() );
|
---|
| 1276 |
|
---|
[3] | 1277 | //第2パラメータを取得
|
---|
| 1278 | i=GetOneParameter(Parameter,i,temporary);
|
---|
| 1279 | if(Parameter[i]){
|
---|
| 1280 | SetError(1,NULL,cp);
|
---|
| 1281 | return;
|
---|
| 1282 | }
|
---|
| 1283 |
|
---|
[76] | 1284 | if( !NumOpe(temporary,Type(),resultType) ){
|
---|
| 1285 | return;
|
---|
| 1286 | }
|
---|
| 1287 |
|
---|
[3] | 1288 | if(type==DEF_DOUBLE){
|
---|
[76] | 1289 | ChangeTypeToDouble_ToFpuReg( resultType.GetBasicType() );
|
---|
[3] | 1290 |
|
---|
| 1291 | //pop eax
|
---|
[225] | 1292 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 1293 |
|
---|
| 1294 | //fstp qword ptr[eax]
|
---|
[236] | 1295 | compiler.codeGenerator.PutOld(
|
---|
| 1296 | (char)0xDD,
|
---|
| 1297 | (char)0x18
|
---|
| 1298 | );
|
---|
[3] | 1299 | }
|
---|
| 1300 | else if(type==DEF_SINGLE){
|
---|
[76] | 1301 | ChangeTypeToSingle( resultType.GetBasicType() );
|
---|
[3] | 1302 |
|
---|
| 1303 | //pop ebx
|
---|
[225] | 1304 | compiler.codeGenerator.op_pop(REG_EBX);
|
---|
[3] | 1305 |
|
---|
| 1306 | //pop eax
|
---|
[225] | 1307 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 1308 |
|
---|
| 1309 | //mov dword ptr[eax],ebx
|
---|
[225] | 1310 | compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EBX, REG_EAX, 0, MOD_BASE );
|
---|
[3] | 1311 | }
|
---|
| 1312 | else if(type==DEF_QWORD){
|
---|
[76] | 1313 | ChangeTypeToInt64( resultType.GetBasicType() );
|
---|
[3] | 1314 |
|
---|
| 1315 | //pop ecx
|
---|
[225] | 1316 | compiler.codeGenerator.op_pop(REG_ECX);
|
---|
[3] | 1317 |
|
---|
| 1318 | //pop ebx
|
---|
[225] | 1319 | compiler.codeGenerator.op_pop(REG_EBX);
|
---|
[3] | 1320 |
|
---|
| 1321 | //pop eax
|
---|
[225] | 1322 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 1323 |
|
---|
| 1324 | //mov dword ptr[eax],ecx
|
---|
[225] | 1325 | compiler.codeGenerator.op_mov_MR( sizeof(long), REG_ECX, REG_EAX, 0, MOD_BASE );
|
---|
[3] | 1326 |
|
---|
| 1327 | //mov dword ptr[eax+sizeof(long)],ebx
|
---|
[225] | 1328 | compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EBX, REG_EAX, 0x04, MOD_BASE_DISP8 );
|
---|
[3] | 1329 | }
|
---|
| 1330 | else if(type==DEF_DWORD){
|
---|
[76] | 1331 | ChangeTypeToLong( resultType.GetBasicType() );
|
---|
[3] | 1332 |
|
---|
| 1333 | //pop ebx
|
---|
[225] | 1334 | compiler.codeGenerator.op_pop(REG_EBX);
|
---|
[3] | 1335 |
|
---|
| 1336 | //pop eax
|
---|
[225] | 1337 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 1338 |
|
---|
| 1339 | //mov dword ptr[eax],ebx
|
---|
[225] | 1340 | compiler.codeGenerator.op_mov_MR( sizeof(long), REG_EBX, REG_EAX, 0, MOD_BASE );
|
---|
[3] | 1341 | }
|
---|
| 1342 | else if(type==DEF_WORD){
|
---|
[76] | 1343 | ChangeTypeToLong( resultType.GetBasicType() );
|
---|
[3] | 1344 |
|
---|
| 1345 | //pop ebx
|
---|
[225] | 1346 | compiler.codeGenerator.op_pop(REG_EBX);
|
---|
[3] | 1347 |
|
---|
| 1348 | //pop eax
|
---|
[225] | 1349 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 1350 |
|
---|
| 1351 | //mov word ptr[eax],bx
|
---|
[236] | 1352 | compiler.codeGenerator.op_mov_MR( sizeof(short), REG_EBX, REG_EAX, 0, MOD_BASE );
|
---|
[3] | 1353 | }
|
---|
| 1354 | else if(type==DEF_BYTE){
|
---|
[76] | 1355 | ChangeTypeToLong( resultType.GetBasicType() );
|
---|
[3] | 1356 |
|
---|
| 1357 | //pop ebx
|
---|
[225] | 1358 | compiler.codeGenerator.op_pop(REG_EBX);
|
---|
[3] | 1359 |
|
---|
| 1360 | //pop eax
|
---|
[225] | 1361 | compiler.codeGenerator.op_pop(REG_EAX);
|
---|
[3] | 1362 |
|
---|
| 1363 | //mov byte ptr[eax],bl
|
---|
[236] | 1364 | compiler.codeGenerator.op_mov_MR( sizeof(char), REG_EBX, REG_EAX, 0, MOD_BASE );
|
---|
[3] | 1365 | }
|
---|
| 1366 | }
|
---|