00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include <stdlib.h>
00021 #include <stdio.h>
00022 #include <limits.h>
00023
00024 #include <math.h>
00025 #include "../command.h"
00026
00027
00028 long *RaiseError(pExecuteObject pEo);
00029
00030
00031
00032
00033
00034
00035
00036
00049 COMMAND(LET)
00050 #if NOTIMP_LET
00051 NOTIMPLEMENTED;
00052 #else
00053 VARIABLE ExpressionResult,ArrayCopyTo;
00054 LEFTVALUE LetThisVariable;
00055 long refcount;
00056
00057
00058 LetThisVariable = EVALUATELEFTVALUE(PARAMETERNODE);
00059 ASSERTOKE;
00060
00061
00062
00063 DEREFERENCE(LetThisVariable);
00064
00065
00066 NEXTPARAMETER;
00067
00068
00069
00070 ExpressionResult = execute_Evaluate(pEo,PARAMETERNODE,_pThisCommandMortals,&iErrorCode,1);
00071 ASSERTOKE;
00072
00073
00074 if( ExpressionResult == NULL || TYPE(ExpressionResult) != VTYPE_ARRAY ){
00075 memory_ReplaceVariable(pEo->pMo,LetThisVariable,ExpressionResult,_pThisCommandMortals,1);
00076 RETURN;
00077 }
00078
00079
00080
00081 ArrayCopyTo = memory_CopyArray(pEo->pMo,ExpressionResult);
00082 if( ArrayCopyTo == NULL )ERROR(COMMAND_ERROR_MEMORY_LOW);
00083 memory_ReplaceVariable(pEo->pMo,LetThisVariable,ArrayCopyTo,_pThisCommandMortals,0);
00084 #endif
00085 END
00086
00087 COMMAND(LLET)
00088 END
00089
00100 COMMAND(SWAP)
00101 #if NOTIMP_SWAP
00102 NOTIMPLEMENTED;
00103 #else
00104 LEFTVALUE VariableA,VariableB;
00105 pFixSizeMemoryObject VSWAP;
00106 long refcount;
00107
00108
00109 VariableA = EVALUATELEFTVALUE(PARAMETERNODE);
00110 ASSERTOKE;
00111
00112
00113
00114 DEREFERENCE(VariableA);
00115
00116
00117 NEXTPARAMETER;
00118
00119
00120 VariableB = EVALUATELEFTVALUE(PARAMETERNODE);
00121 ASSERTOKE;
00122
00123
00124
00125 DEREFERENCE(VariableB);
00126
00127 VSWAP = *VariableA;
00128 *VariableA = *VariableB;
00129 *VariableB = VSWAP;
00130
00131 #endif
00132 END
00133
00144 COMMAND(REF)
00145 #if NOTIMP_REF
00146 NOTIMPLEMENTED;
00147 #else
00148 LEFTVALUE v1,v2;
00149 VARIABLE NewValue;
00150 long refcount;
00151 int iError;
00152
00153
00154 v1 = EVALUATELEFTVALUE(PARAMETERNODE);
00155 ASSERTOKE;
00156
00157
00158
00159
00160 DEREFERENCE(v1);
00161
00162
00163 NEXTPARAMETER;
00164
00165
00166
00167 v2 = EVALUATELEFTVALUE_A(PARAMETERNODE);
00168 ASSERTOKE;
00169 DEREFERENCE(v2);
00170
00171
00172
00173 if( v1 == v2 )RETURN;
00174
00175 NewValue = memory_NewRef(pEo->pMo);
00176 if( *v1 ){
00177 NewValue->link.rprev = (*v1)->link.rprev;
00178 (*v1)->link.rprev = NULL;
00179 }else{
00180 NewValue->link.rprev = NULL;
00181 }
00182 if( *v1 )memory_ReleaseVariable(pEo->pMo,*v1);
00183
00184 *v1 = NewValue;
00185
00186 iError = memory_SetRef(pEo->pMo,v1,v2);
00187
00188 if( iError )ERROR(iError);
00189 #endif
00190 END
00191
00233 COMMAND(CUNDEF)
00234 #if NOTIMP_CUNDEF
00235 NOTIMPLEMENTED;
00236 #else
00237
00238 NODE nItem;
00239 LEFTVALUE LetThisVariable;
00240
00241 nItem = PARAMETERNODE;
00242 while( nItem ){
00243
00244 LetThisVariable = EVALUATELEFTVALUE_A(CAR(nItem));
00245 ASSERTOKE;
00246
00247 if( *LetThisVariable == NULL ){
00248 nItem = CDR(nItem);
00249 continue;
00250 }
00251
00252 memory_ReleaseVariable(pEo->pMo,*LetThisVariable);
00253 *LetThisVariable = NULL;
00254 nItem = CDR(nItem);
00255 }
00256
00257 #endif
00258 END
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290 COMMAND(CBYVAL)
00291 #if NOTIMP_CBYVAL
00292 NOTIMPLEMENTED;
00293 #else
00294
00295 NODE nItem;
00296 LEFTVALUE LetThisVariable;
00297 VARIABLE NewValue;
00298 unsigned long refcount;
00299
00300 nItem = PARAMETERNODE;
00301 while( nItem ){
00302
00303 LetThisVariable = EVALUATELEFTVALUE_A(CAR(nItem));
00304 ASSERTOKE;
00305
00306 if( *LetThisVariable == NULL || TYPE(*LetThisVariable) != VTYPE_REF ){
00307 nItem = CDR(nItem);
00308 continue;
00309 }
00310 NewValue = *LetThisVariable;
00311 refcount = pEo->pMo->maxderef;
00312 while( NewValue && TYPE(NewValue) == VTYPE_REF ){
00313 NewValue = *(NewValue->Value.aValue);
00314 if( ! refcount-- )ERROR(COMMAND_ERROR_CIRCULAR);
00315 }
00316 if( NewValue ){
00317 NewValue = memory_DupImmortal(pEo->pMo,NewValue,&iErrorCode);
00318 }
00319 if( *LetThisVariable )
00320 memory_ReleaseVariable(pEo->pMo,*LetThisVariable);
00321 *LetThisVariable = NewValue;
00322 nItem = CDR(nItem);
00323 }
00324
00325 #endif
00326 END
00327
00341 COMMAND(LETM)
00342 #if NOTIMP_LETM
00343 NOTIMPLEMENTED;
00344 #else
00345 VARIABLE ExpressionResult;
00346 VARIABLE Op1,Op2;
00347 LEFTVALUE LetThisVariable;
00348 long refcount;
00349 int bResultIsBig;
00350 long Lop2;
00351 double dResult;
00352 long lResult;
00353
00354
00355 LetThisVariable = EVALUATELEFTVALUE(PARAMETERNODE);
00356 ASSERTOKE;
00357
00358
00359
00360 DEREFERENCE(LetThisVariable);
00361
00362
00363 NEXTPARAMETER;
00364
00365
00366
00367 Op2 = execute_Evaluate(pEo,PARAMETERNODE,_pThisCommandMortals,&iErrorCode,0);
00368 ASSERTOKE;
00369
00370 if( memory_Type(*LetThisVariable) == VTYPE_DOUBLE ){
00371 dResult = DOUBLEVALUE(*LetThisVariable) - GETDOUBLEVALUE(Op2);
00372 lResult = (long)dResult;
00373 if( dResult == (double)lResult ){
00374 ExpressionResult = NEWMORTALLONG;
00375 ASSERTNULL(ExpressionResult);
00376 LONGVALUE(ExpressionResult) = lResult;
00377 IMMORTALIZE(ExpressionResult);
00378 if( *LetThisVariable )memory_ReleaseVariable(pEo->pMo,*LetThisVariable);
00379 *LetThisVariable = ExpressionResult;
00380 RETURN;
00381 }
00382 DOUBLEVALUE(*LetThisVariable) = dResult;
00383 RETURN;
00384 }
00385
00386
00387 bResultIsBig = 0;
00388
00389
00390
00391
00392 if( memory_Type(*LetThisVariable) == VTYPE_LONG &&
00393 (memory_Type(Op2) == VTYPE_LONG || (memory_Type(Op2) == VTYPE_STRING && ISSTRINGINTEGER(Op2)) )){
00394 Lop2 = GETLONGVALUE(Op2);
00395 dResult = ((double)LONGVALUE(*LetThisVariable)) - ((double)Lop2);
00396 if( dResult <= ((double)LONG_MAX) && dResult >= ((double)LONG_MIN) ){
00397 LONGVALUE(*LetThisVariable) -= Lop2;
00398 RETURN;
00399 }
00400 bResultIsBig = 1;
00401 }
00402
00403 Op1 = *LetThisVariable;
00404
00405
00406 if( bResultIsBig ||
00407
00408 (memory_Type(Op1) == VTYPE_DOUBLE || memory_Type(Op2) == VTYPE_DOUBLE) ||
00409
00410
00411 ( memory_Type(Op1) == VTYPE_STRING && !ISSTRINGINTEGER(Op1)) ||
00412
00413
00414 ( memory_Type(Op2) == VTYPE_STRING && !ISSTRINGINTEGER(Op2))
00415 ){
00416 dResult = GETDOUBLEVALUE(Op1) - GETDOUBLEVALUE(Op2);
00417 lResult = (long)dResult;
00418 if( dResult == (double)lResult ){
00419 ExpressionResult = NEWMORTALLONG;
00420 ASSERTNULL(ExpressionResult);
00421 LONGVALUE(ExpressionResult) = lResult;
00422 }else{
00423 ExpressionResult = NEWMORTALDOUBLE;
00424 ASSERTNULL(ExpressionResult);
00425 DOUBLEVALUE(ExpressionResult) = dResult;
00426 }
00427 }else{
00428 ExpressionResult = NEWMORTALLONG;
00429 ASSERTNULL(ExpressionResult);
00430 LONGVALUE(ExpressionResult) = GETLONGVALUE(Op1) - GETLONGVALUE(Op2);
00431 }
00432
00433
00434 if( ExpressionResult ){
00435
00436 IMMORTALIZE(ExpressionResult);
00437 }
00438
00439
00440 if( *LetThisVariable )memory_ReleaseVariable(pEo->pMo,*LetThisVariable);
00441
00442
00443 *LetThisVariable = ExpressionResult;
00444
00445 #endif
00446 END
00447
00459 COMMAND(LETP)
00460 #if NOTIMP_LETP
00461 NOTIMPLEMENTED;
00462 #else
00463 VARIABLE ExpressionResult;
00464 VARIABLE Op1,Op2;
00465 LEFTVALUE LetThisVariable;
00466 long refcount;
00467 int bResultIsBig;
00468 long Lop2;
00469 double dResult;
00470 long lResult;
00471
00472
00473 LetThisVariable = EVALUATELEFTVALUE(PARAMETERNODE);
00474 ASSERTOKE;
00475
00476
00477
00478 DEREFERENCE(LetThisVariable);
00479
00480
00481 NEXTPARAMETER;
00482
00483
00484
00485 Op2 = execute_Evaluate(pEo,PARAMETERNODE,_pThisCommandMortals,&iErrorCode,0);
00486 ASSERTOKE;
00487
00488 if( memory_Type(*LetThisVariable) == VTYPE_DOUBLE ){
00489 dResult = DOUBLEVALUE(*LetThisVariable) + GETDOUBLEVALUE(Op2);
00490 lResult = (long)dResult;
00491 if( dResult == (double)lResult ){
00492 ExpressionResult = NEWMORTALLONG;
00493 ASSERTNULL(ExpressionResult);
00494 LONGVALUE(ExpressionResult) = lResult;
00495 IMMORTALIZE(ExpressionResult);
00496 if( *LetThisVariable )memory_ReleaseVariable(pEo->pMo,*LetThisVariable);
00497 *LetThisVariable = ExpressionResult;
00498 RETURN;
00499 }
00500 DOUBLEVALUE(*LetThisVariable) = dResult;
00501 RETURN;
00502 }
00503
00504
00505 bResultIsBig = 0;
00506
00507
00508
00509
00510 if( memory_Type(*LetThisVariable) == VTYPE_LONG &&
00511 (memory_Type(Op2) == VTYPE_LONG || (memory_Type(Op2) == VTYPE_STRING && ISSTRINGINTEGER(Op2)) )){
00512 Lop2 = GETLONGVALUE(Op2);
00513 dResult = ((double)Lop2) + ((double)LONGVALUE(*LetThisVariable));
00514 if( dResult <= ((double)LONG_MAX) && dResult >= ((double)LONG_MIN) ){
00515 LONGVALUE(*LetThisVariable) += Lop2;
00516 RETURN;
00517 }
00518 bResultIsBig = 1;
00519 }
00520 Op1 = *LetThisVariable;
00521
00522
00523 if( bResultIsBig ||
00524
00525 (memory_Type(Op1) == VTYPE_DOUBLE || memory_Type(Op2) == VTYPE_DOUBLE) ||
00526
00527
00528 ( memory_Type(Op1) == VTYPE_STRING && !ISSTRINGINTEGER(Op1)) ||
00529
00530
00531 ( memory_Type(Op2) == VTYPE_STRING && !ISSTRINGINTEGER(Op2))
00532 ){
00533 dResult = GETDOUBLEVALUE(Op1) + GETDOUBLEVALUE(Op2);
00534 lResult = (long)dResult;
00535 if( dResult == (double)lResult ){
00536 ExpressionResult = NEWMORTALLONG;
00537 ASSERTNULL(ExpressionResult);
00538 LONGVALUE(ExpressionResult) = lResult;
00539 }else{
00540 ExpressionResult = NEWMORTALDOUBLE;
00541 ASSERTNULL(ExpressionResult);
00542 DOUBLEVALUE(ExpressionResult) = dResult;
00543 }
00544 }else{
00545 ExpressionResult = NEWMORTALLONG;
00546 ASSERTNULL(ExpressionResult);
00547 LONGVALUE(ExpressionResult) = GETLONGVALUE(Op1) + GETLONGVALUE(Op2);
00548 }
00549
00550
00551 if( ExpressionResult ){
00552
00553 IMMORTALIZE(ExpressionResult);
00554 }
00555
00556
00557 if( *LetThisVariable )memory_ReleaseVariable(pEo->pMo,*LetThisVariable);
00558
00559
00560 *LetThisVariable = ExpressionResult;
00561
00562 #endif
00563 END
00564
00576 COMMAND(LETS)
00577 #if NOTIMP_LETS
00578 NOTIMPLEMENTED;
00579 #else
00580 VARIABLE ExpressionResult;
00581 VARIABLE Op1,Op2;
00582 LEFTVALUE LetThisVariable;
00583 long refcount;
00584 int bResultIsBig;
00585 long Lop2;
00586 double dResult;
00587 long lResult;
00588
00589
00590 LetThisVariable = EVALUATELEFTVALUE(PARAMETERNODE);
00591 ASSERTOKE;
00592
00593
00594
00595 DEREFERENCE(LetThisVariable);
00596
00597
00598 NEXTPARAMETER;
00599
00600
00601
00602 Op2 = execute_Evaluate(pEo,PARAMETERNODE,_pThisCommandMortals,&iErrorCode,0);
00603 ASSERTOKE;
00604
00605
00606
00607
00608
00609 if( memory_Type(*LetThisVariable) == VTYPE_DOUBLE ){
00610 dResult = DOUBLEVALUE(*LetThisVariable) * GETDOUBLEVALUE(Op2);
00611 lResult = (long)dResult;
00612 if( dResult == (double)lResult ){
00613 ExpressionResult = NEWMORTALLONG;
00614 ASSERTNULL(ExpressionResult);
00615 LONGVALUE(ExpressionResult) = lResult;
00616 IMMORTALIZE(ExpressionResult);
00617 if( *LetThisVariable )memory_ReleaseVariable(pEo->pMo,*LetThisVariable);
00618 *LetThisVariable = ExpressionResult;
00619 RETURN;
00620 }
00621 DOUBLEVALUE(*LetThisVariable) = dResult;
00622 RETURN;
00623 }
00624
00625
00626 bResultIsBig = 0;
00627
00628
00629
00630
00631 if( memory_Type(*LetThisVariable) == VTYPE_LONG &&
00632 (memory_Type(Op2) == VTYPE_LONG || (memory_Type(Op2) == VTYPE_STRING && ISSTRINGINTEGER(Op2)) )){
00633 Lop2 = GETLONGVALUE(Op2);
00634 dResult = ((double)Lop2) * ((double)LONGVALUE(*LetThisVariable));
00635 if( dResult <= ((double)LONG_MAX) && dResult >= ((double)LONG_MIN) ){
00636 LONGVALUE(*LetThisVariable) *= Lop2;
00637 RETURN;
00638 }
00639 bResultIsBig = 1;
00640 }
00641
00642 Op1 = *LetThisVariable;
00643
00644
00645 if( bResultIsBig ||
00646
00647 (memory_Type(Op1) == VTYPE_DOUBLE || memory_Type(Op2) == VTYPE_DOUBLE) ||
00648
00649
00650 ( memory_Type(Op1) == VTYPE_STRING && !ISSTRINGINTEGER(Op1)) ||
00651
00652
00653 ( memory_Type(Op2) == VTYPE_STRING && !ISSTRINGINTEGER(Op2))
00654 ){
00655 dResult = GETDOUBLEVALUE(Op1) * GETDOUBLEVALUE(Op2);
00656 lResult = (long)dResult;
00657 if( dResult == (double)lResult ){
00658 ExpressionResult = NEWMORTALLONG;
00659 ASSERTNULL(ExpressionResult);
00660 LONGVALUE(ExpressionResult) = lResult;
00661 }else{
00662 ExpressionResult = NEWMORTALDOUBLE;
00663 ASSERTNULL(ExpressionResult);
00664 DOUBLEVALUE(ExpressionResult) = dResult;
00665 }
00666 }else{
00667 ExpressionResult = NEWMORTALLONG;
00668 ASSERTNULL(ExpressionResult);
00669 LONGVALUE(ExpressionResult) = GETLONGVALUE(Op1) * GETLONGVALUE(Op2);
00670 }
00671
00672
00673 if( ExpressionResult ){
00674
00675 IMMORTALIZE(ExpressionResult);
00676 }
00677
00678
00679 if( *LetThisVariable )memory_ReleaseVariable(pEo->pMo,*LetThisVariable);
00680
00681
00682 *LetThisVariable = ExpressionResult;
00683
00684 #endif
00685 END
00686
00698 COMMAND(LETD)
00699 #if NOTIMP_LETD
00700 NOTIMPLEMENTED;
00701 #else
00702 VARIABLE ExpressionResult;
00703 VARIABLE Op1,Op2;
00704 LEFTVALUE LetThisVariable;
00705 long refcount;
00706 long lop2;
00707 double dResult;
00708 long lResult;
00709
00710
00711 LetThisVariable = EVALUATELEFTVALUE(PARAMETERNODE);
00712 ASSERTOKE;
00713
00714
00715
00716 DEREFERENCE(LetThisVariable);
00717
00718
00719 NEXTPARAMETER;
00720
00721
00722
00723 Op2 = execute_Evaluate(pEo,PARAMETERNODE,_pThisCommandMortals,&iErrorCode,0);
00724 ASSERTOKE;
00725
00726
00727
00728
00729
00730 if( memory_Type(*LetThisVariable) == VTYPE_DOUBLE ){
00731 if( memory_Type(Op2) != VTYPE_DOUBLE )Op2 = CONVERT2DOUBLE(Op2);
00732 if( DOUBLEVALUE(Op2) == 0.0 ){
00733 if( *LetThisVariable )memory_ReleaseVariable(pEo->pMo,*LetThisVariable);
00734 *LetThisVariable = NULL;
00735 if((*RaiseError(pEo))&1 ){
00736 ERROR(COMMAND_ERROR_DIV);
00737 }
00738 RETURN;
00739 }
00740 dResult = DOUBLEVALUE(*LetThisVariable) / DOUBLEVALUE(Op2);
00741 lResult = (long)dResult;
00742
00743 if( dResult == (double)lResult ){
00744 if( *LetThisVariable )memory_ReleaseVariable(pEo->pMo,*LetThisVariable);
00745 *LetThisVariable = NULL;
00746 ExpressionResult = NEWMORTALLONG;
00747 ASSERTNULL(ExpressionResult)
00748 LONGVALUE(ExpressionResult) = lResult;
00749 IMMORTALIZE(ExpressionResult);
00750 *LetThisVariable = ExpressionResult;
00751 RETURN;
00752 }
00753 DOUBLEVALUE(*LetThisVariable) = dResult;
00754 RETURN;
00755 }
00756
00757 if( memory_Type(*LetThisVariable) == VTYPE_LONG &&
00758 (memory_Type(Op2) == VTYPE_LONG || (memory_Type(Op2) == VTYPE_STRING && ISSTRINGINTEGER(Op2)) )){
00759 lop2 = GETLONGVALUE(Op2);
00760 if( lop2 == 0 ){
00761 if( *LetThisVariable )memory_ReleaseVariable(pEo->pMo,*LetThisVariable);
00762 *LetThisVariable = NULL;
00763 if((*RaiseError(pEo))&1 ){
00764 ERROR(COMMAND_ERROR_DIV);
00765 }
00766 RETURN;
00767 }
00768 if( LONGVALUE(*LetThisVariable) % lop2 == 0 ){
00769 LONGVALUE(*LetThisVariable) /= lop2;
00770 RETURN;
00771 }
00772 }
00773
00774 Op1 = *LetThisVariable;
00775
00776
00777 if( (memory_Type(Op1) == VTYPE_DOUBLE || memory_Type(Op2) == VTYPE_DOUBLE) ||
00778
00779
00780 ( memory_Type(Op1) == VTYPE_STRING && !ISSTRINGINTEGER(Op1)) ||
00781
00782
00783 ( memory_Type(Op2) == VTYPE_STRING && !ISSTRINGINTEGER(Op2))
00784 ){
00785 Op1 = CONVERT2DOUBLE(Op1);
00786 Op2 = CONVERT2DOUBLE(Op2);
00787 if( DOUBLEVALUE(Op2) == 0.0 ){
00788 if((*RaiseError(pEo))&1 ){
00789 ERROR(COMMAND_ERROR_DIV);
00790 }
00791 ExpressionResult = NULL;
00792 }else{
00793 ExpressionResult = NEWMORTALDOUBLE;
00794 ASSERTNULL(ExpressionResult);
00795 DOUBLEVALUE(ExpressionResult) = DOUBLEVALUE(Op1) / DOUBLEVALUE(Op2);
00796 }
00797 }else{
00798 Op1 = CONVERT2LONG(Op1);
00799 Op2 = CONVERT2LONG(Op2);
00800 if( LONGVALUE(Op2) == 0 ){
00801 if((*RaiseError(pEo))&1 ){
00802 ERROR(COMMAND_ERROR_DIV);
00803 }
00804 ExpressionResult = NULL;
00805 }else{
00806 if( LONGVALUE(Op1) % LONGVALUE(Op2) ){
00807 ExpressionResult = NEWMORTALDOUBLE;
00808 ASSERTNULL(ExpressionResult)
00809 DOUBLEVALUE(ExpressionResult) = ((double)LONGVALUE(Op1)) / ((double)LONGVALUE(Op2));
00810 }else{
00811 ExpressionResult = NEWMORTALLONG;
00812 ASSERTNULL(ExpressionResult)
00813 LONGVALUE(ExpressionResult) = LONGVALUE(Op1) / LONGVALUE(Op2);
00814 }
00815 }
00816 }
00817
00818
00819 if( ExpressionResult ){
00820
00821 IMMORTALIZE(ExpressionResult);
00822 }
00823
00824
00825 if( *LetThisVariable )memory_ReleaseVariable(pEo->pMo,*LetThisVariable);
00826
00827
00828 *LetThisVariable = ExpressionResult;
00829
00830 #endif
00831 END
00832
00846 COMMAND(LETI)
00847 #if NOTIMP_LETI
00848 NOTIMPLEMENTED;
00849 #else
00850 VARIABLE ExpressionResult;
00851 VARIABLE Op1,Op2;
00852 LEFTVALUE LetThisVariable;
00853 long refcount;
00854 double dResult;
00855 long lResult;
00856
00857
00858 LetThisVariable = EVALUATELEFTVALUE(PARAMETERNODE);
00859 ASSERTOKE;
00860
00861
00862
00863 DEREFERENCE(LetThisVariable);
00864
00865
00866 NEXTPARAMETER;
00867
00868
00869
00870 Op2 = execute_Evaluate(pEo,PARAMETERNODE,_pThisCommandMortals,&iErrorCode,0);
00871 ASSERTOKE;
00872
00873 Op1 = *LetThisVariable;
00874
00875
00876 if( (memory_Type(Op1) == VTYPE_DOUBLE || memory_Type(Op2) == VTYPE_DOUBLE) ||
00877
00878
00879 ( memory_Type(Op1) == VTYPE_STRING && !ISSTRINGINTEGER(Op1)) ||
00880
00881
00882 ( memory_Type(Op2) == VTYPE_STRING && !ISSTRINGINTEGER(Op2))
00883 ){
00884 Op1 = CONVERT2DOUBLE(Op1);
00885 Op2 = CONVERT2DOUBLE(Op2);
00886 if( DOUBLEVALUE(Op2) == 0.0 ){
00887 if((*RaiseError(pEo))&1 ){
00888 ERROR(COMMAND_ERROR_DIV);
00889 }
00890 ExpressionResult = NULL;
00891 }else{
00892 dResult = floor(DOUBLEVALUE(Op1) / DOUBLEVALUE(Op2));
00893 lResult = (long)dResult;
00894 if( dResult == (double)lResult ){
00895 ExpressionResult = NEWMORTALLONG;
00896 ASSERTNULL(ExpressionResult);
00897 LONGVALUE(ExpressionResult) = lResult;
00898 }else{
00899 ExpressionResult = NEWMORTALDOUBLE;
00900 ASSERTNULL(ExpressionResult);
00901 DOUBLEVALUE(ExpressionResult) = dResult;
00902 }
00903 }
00904 }else{
00905 Op1 = CONVERT2LONG(Op1);
00906 Op2 = CONVERT2LONG(Op2);
00907 if( LONGVALUE(Op2) == 0 ){
00908 if((*RaiseError(pEo))&1 ){
00909 ERROR(COMMAND_ERROR_DIV);
00910 }
00911 ExpressionResult = NULL;
00912 }else{
00913 ExpressionResult = NEWMORTALLONG;
00914 ASSERTNULL(ExpressionResult);
00915 LONGVALUE(ExpressionResult) = LONGVALUE(Op1) / LONGVALUE(Op2);
00916 }
00917 }
00918
00919
00920 if( ExpressionResult ){
00921
00922 IMMORTALIZE(ExpressionResult);
00923 }
00924
00925
00926 if( *LetThisVariable )memory_ReleaseVariable(pEo->pMo,*LetThisVariable);
00927
00928
00929 *LetThisVariable = ExpressionResult;
00930
00931 #endif
00932 END
00933
00945 COMMAND(LETC)
00946 #if NOTIMP_LETC
00947 NOTIMPLEMENTED;
00948 #else
00949 VARIABLE ExpressionResult;
00950 VARIABLE Op1,Op2;
00951 LEFTVALUE LetThisVariable;
00952 long refcount;
00953
00954
00955 LetThisVariable = EVALUATELEFTVALUE(PARAMETERNODE);
00956 ASSERTOKE;
00957
00958
00959
00960 DEREFERENCE(LetThisVariable);
00961
00962
00963 NEXTPARAMETER;
00964
00965
00966
00967 Op2 = execute_Evaluate(pEo,PARAMETERNODE,_pThisCommandMortals,&iErrorCode,0);
00968 ASSERTOKE;
00969
00970 Op1 = *LetThisVariable;
00971
00972 Op1 = CONVERT2STRING(Op1);
00973 Op2 = CONVERT2STRING(Op2);
00974
00975 if( STRLEN(Op2) == 0 )RETURN;
00976
00977 ExpressionResult = NEWMORTALSTRING( STRLEN(Op1) + STRLEN(Op2) );
00978 ASSERTNULL(ExpressionResult)
00979 memcpy(STRINGVALUE(ExpressionResult),STRINGVALUE(Op1),STRLEN(Op1));
00980 memcpy(STRINGVALUE(ExpressionResult)+STRLEN(Op1),STRINGVALUE(Op2),STRLEN(Op2));
00981
00982
00983 if( ExpressionResult ){
00984
00985 IMMORTALIZE(ExpressionResult);
00986 }
00987
00988
00989 if( *LetThisVariable )memory_ReleaseVariable(pEo->pMo,*LetThisVariable);
00990
00991
00992 *LetThisVariable = ExpressionResult;
00993
00994 #endif
00995 END