1// ------------------------------------------------------------- 2// DO NOT EDIT! this file was generated automatically by gomacro 3// Any change will be lost when the file is re-generated 4// ------------------------------------------------------------- 5 6/* 7 * gomacro - A Go interpreter with Lisp-like macros 8 * 9 * Copyright (C) 2017-2019 Massimiliano Ghilardi 10 * 11 * This Source Code Form is subject to the terms of the Mozilla Public 12 * License, v. 2.0. If a copy of the MPL was not distributed with this 13 * file, You can obtain one at http://mozilla.org/MPL/2.0/. 14 * 15 * 16 * place_ops.go 17 * 18 * Created on Apr 25, 2017 19 * Author Massimiliano Ghilardi 20 */ 21 22package fast 23 24import ( 25 "go/token" 26 r "reflect" 27 28 . "github.com/cosmos72/gomacro/base" 29 "github.com/cosmos72/gomacro/base/reflect" 30) 31 32func (c *Comp) placeAddConst(place *Place, val I) Stmt { 33 if isLiteralNumber(val, 0) || val == "" { 34 return c.placeForSideEffects(place) 35 } 36 37 { 38 var ret Stmt 39 lhsfun := place.Fun 40 keyfun := place.MapKey 41 v := r.ValueOf(val) 42 43 if keyfun == nil { 44 switch reflect.Category(place.Type.Kind()) { 45 case r.Int: 46 val := v.Int() 47 48 ret = func(env *Env) (Stmt, *Env) { 49 lhs := lhsfun(env) 50 lhs.SetInt(lhs.Int() + int64(val, 51 ), 52 ) 53 54 env.IP++ 55 return env.Code[env.IP], env 56 } 57 case r.Uint: 58 val := v.Uint() 59 60 ret = func(env *Env) (Stmt, *Env) { 61 lhs := lhsfun(env) 62 lhs.SetUint(lhs.Uint() + uint64(val, 63 ), 64 ) 65 66 env.IP++ 67 return env.Code[env.IP], env 68 } 69 case r.Float64: 70 val := v.Float() 71 72 ret = func(env *Env) (Stmt, *Env) { 73 lhs := lhsfun(env) 74 lhs.SetFloat(lhs.Float() + 75 val, 76 ) 77 78 env.IP++ 79 return env.Code[env.IP], env 80 } 81 case r.Complex128: 82 val := v.Complex() 83 84 ret = func(env *Env) (Stmt, *Env) { 85 lhs := lhsfun(env) 86 lhs.SetComplex(lhs.Complex() + 87 val, 88 ) 89 90 env.IP++ 91 return env.Code[env.IP], env 92 } 93 case r.String: 94 val := v.String() 95 96 ret = func(env *Env) (Stmt, *Env) { 97 lhs := lhsfun(env) 98 lhs.SetString(lhs.String() + 99 val, 100 ) 101 102 env.IP++ 103 return env.Code[env.IP], env 104 } 105 default: 106 c.Errorf(`invalid operator %s= on <%v>`, token.ADD, place.Type) 107 108 } 109 } else { 110 switch place.Type.Kind() { 111 case r.Int: 112 val := int(v.Int()) 113 114 ret = func(env *Env) (Stmt, *Env) { 115 lhs := lhsfun(env) 116 key := keyfun(env) 117 var result int 118 119 if v := lhs.MapIndex(key); v != Nil { 120 result = int(v.Int()) 121 } 122 result += val 123 124 lhs.SetMapIndex(key, r.ValueOf(result)) 125 env.IP++ 126 return env.Code[env.IP], env 127 } 128 case r.Int8: 129 val := int8(v.Int()) 130 131 ret = func(env *Env) (Stmt, *Env) { 132 lhs := lhsfun(env) 133 key := keyfun(env) 134 var result int8 135 136 if v := lhs.MapIndex(key); v != Nil { 137 result = int8(v.Int()) 138 } 139 result += val 140 141 lhs.SetMapIndex(key, r.ValueOf(result)) 142 env.IP++ 143 return env.Code[env.IP], env 144 } 145 case r.Int16: 146 val := int16(v.Int()) 147 148 ret = func(env *Env) (Stmt, *Env) { 149 lhs := lhsfun(env) 150 key := keyfun(env) 151 var result int16 152 153 if v := lhs.MapIndex(key); v != Nil { 154 result = int16(v.Int()) 155 } 156 result += val 157 158 lhs.SetMapIndex(key, r.ValueOf(result)) 159 env.IP++ 160 return env.Code[env.IP], env 161 } 162 case r.Int32: 163 val := int32(v.Int()) 164 165 ret = func(env *Env) (Stmt, *Env) { 166 lhs := lhsfun(env) 167 key := keyfun(env) 168 var result int32 169 170 if v := lhs.MapIndex(key); v != Nil { 171 result = int32(v.Int()) 172 } 173 result += val 174 175 lhs.SetMapIndex(key, r.ValueOf(result)) 176 env.IP++ 177 return env.Code[env.IP], env 178 } 179 case r.Int64: 180 val := int64(v.Int()) 181 182 ret = func(env *Env) (Stmt, *Env) { 183 lhs := lhsfun(env) 184 key := keyfun(env) 185 var result int64 186 187 if v := lhs.MapIndex(key); v != Nil { 188 result = v.Int() 189 } 190 result += val 191 192 lhs.SetMapIndex(key, r.ValueOf(result)) 193 env.IP++ 194 return env.Code[env.IP], env 195 } 196 case r.Uint: 197 val := uint(v.Uint()) 198 199 ret = func(env *Env) (Stmt, *Env) { 200 lhs := lhsfun(env) 201 key := keyfun(env) 202 var result uint 203 204 if v := lhs.MapIndex(key); v != Nil { 205 result = uint(v.Uint()) 206 } 207 result += val 208 209 lhs.SetMapIndex(key, r.ValueOf(result)) 210 env.IP++ 211 return env.Code[env.IP], env 212 } 213 case r.Uint8: 214 val := uint8(v.Uint()) 215 216 ret = func(env *Env) (Stmt, *Env) { 217 lhs := lhsfun(env) 218 key := keyfun(env) 219 var result uint8 220 221 if v := lhs.MapIndex(key); v != Nil { 222 result = uint8(v.Uint()) 223 } 224 result += val 225 226 lhs.SetMapIndex(key, r.ValueOf(result)) 227 env.IP++ 228 return env.Code[env.IP], env 229 } 230 case r.Uint16: 231 val := uint16(v.Uint()) 232 233 ret = func(env *Env) (Stmt, *Env) { 234 lhs := lhsfun(env) 235 key := keyfun(env) 236 var result uint16 237 238 if v := lhs.MapIndex(key); v != Nil { 239 result = uint16(v.Uint()) 240 } 241 result += val 242 243 lhs.SetMapIndex(key, r.ValueOf(result)) 244 env.IP++ 245 return env.Code[env.IP], env 246 } 247 case r.Uint32: 248 val := uint32(v.Uint()) 249 250 ret = func(env *Env) (Stmt, *Env) { 251 lhs := lhsfun(env) 252 key := keyfun(env) 253 var result uint32 254 255 if v := lhs.MapIndex(key); v != Nil { 256 result = uint32(v.Uint()) 257 } 258 result += val 259 260 lhs.SetMapIndex(key, r.ValueOf(result)) 261 env.IP++ 262 return env.Code[env.IP], env 263 } 264 case r.Uint64: 265 val := uint64(v.Uint()) 266 267 ret = func(env *Env) (Stmt, *Env) { 268 lhs := lhsfun(env) 269 key := keyfun(env) 270 var result uint64 271 272 if v := lhs.MapIndex(key); v != Nil { 273 result = v.Uint() 274 } 275 result += val 276 277 lhs.SetMapIndex(key, r.ValueOf(result)) 278 env.IP++ 279 return env.Code[env.IP], env 280 } 281 case r.Uintptr: 282 val := uintptr(v.Uint()) 283 284 ret = func(env *Env) (Stmt, *Env) { 285 lhs := lhsfun(env) 286 key := keyfun(env) 287 var result uintptr 288 289 if v := lhs.MapIndex(key); v != Nil { 290 result = uintptr(v.Uint()) 291 } 292 result += val 293 294 lhs.SetMapIndex(key, r.ValueOf(result)) 295 env.IP++ 296 return env.Code[env.IP], env 297 } 298 case r.Float32: 299 val := float32(v.Float()) 300 301 ret = func(env *Env) (Stmt, *Env) { 302 lhs := lhsfun(env) 303 key := keyfun(env) 304 var result float32 305 306 if v := lhs.MapIndex(key); v != Nil { 307 result = float32(v.Float()) 308 } 309 result += val 310 311 lhs.SetMapIndex(key, r.ValueOf(result)) 312 env.IP++ 313 return env.Code[env.IP], env 314 } 315 case r.Float64: 316 val := float64(v.Float()) 317 318 ret = func(env *Env) (Stmt, *Env) { 319 lhs := lhsfun(env) 320 key := keyfun(env) 321 var result float64 322 323 if v := lhs.MapIndex(key); v != Nil { 324 result = v.Float() 325 } 326 result += val 327 328 lhs.SetMapIndex(key, r.ValueOf(result)) 329 env.IP++ 330 return env.Code[env.IP], env 331 } 332 case r.Complex64: 333 val := complex64(v.Complex()) 334 335 ret = func(env *Env) (Stmt, *Env) { 336 lhs := lhsfun(env) 337 key := keyfun(env) 338 var result complex64 339 340 if v := lhs.MapIndex(key); v != Nil { 341 result = complex64(v.Complex()) 342 } 343 result += val 344 345 lhs.SetMapIndex(key, r.ValueOf(result)) 346 env.IP++ 347 return env.Code[env.IP], env 348 } 349 case r.Complex128: 350 val := complex128(v.Complex()) 351 352 ret = func(env *Env) (Stmt, *Env) { 353 lhs := lhsfun(env) 354 key := keyfun(env) 355 var result complex128 356 357 if v := lhs.MapIndex(key); v != Nil { 358 result = v.Complex() 359 } 360 result += val 361 362 lhs.SetMapIndex(key, r.ValueOf(result)) 363 env.IP++ 364 return env.Code[env.IP], env 365 } 366 case r.String: 367 val := string(v.String()) 368 369 ret = func(env *Env) (Stmt, *Env) { 370 lhs := lhsfun(env) 371 key := keyfun(env) 372 var result string 373 374 if v := lhs.MapIndex(key); v != Nil { 375 result = v.String() 376 } 377 result += val 378 379 lhs.SetMapIndex(key, r.ValueOf(result)) 380 env.IP++ 381 return env.Code[env.IP], env 382 } 383 default: 384 c.Errorf(`invalid operator %s= on <%v>`, token.ADD, place.Type) 385 386 } 387 } 388 return ret 389 } 390} 391func (c *Comp) placeAddExpr(place *Place, fun I) Stmt { 392 var ret Stmt 393 lhsfun := place.Fun 394 keyfun := place.MapKey 395 if keyfun == nil { 396 switch fun := fun.(type) { 397 case func(*Env) int: 398 399 ret = func(env *Env) (Stmt, *Env) { 400 lhs := lhsfun(env) 401 lhs.SetInt(lhs.Int() + int64(fun(env), 402 ), 403 ) 404 405 env.IP++ 406 return env.Code[env.IP], env 407 } 408 case func(*Env) int8: 409 410 ret = func(env *Env) (Stmt, *Env) { 411 lhs := lhsfun(env) 412 lhs.SetInt(lhs.Int() + int64(fun(env), 413 ), 414 ) 415 416 env.IP++ 417 return env.Code[env.IP], env 418 } 419 case func(*Env) int16: 420 421 ret = func(env *Env) (Stmt, *Env) { 422 lhs := lhsfun(env) 423 lhs.SetInt(lhs.Int() + int64(fun(env), 424 ), 425 ) 426 427 env.IP++ 428 return env.Code[env.IP], env 429 } 430 case func(*Env) int32: 431 432 ret = func(env *Env) (Stmt, *Env) { 433 lhs := lhsfun(env) 434 lhs.SetInt(lhs.Int() + int64(fun(env), 435 ), 436 ) 437 438 env.IP++ 439 return env.Code[env.IP], env 440 } 441 case func(*Env) int64: 442 443 ret = func(env *Env) (Stmt, *Env) { 444 lhs := lhsfun(env) 445 lhs.SetInt(lhs.Int() + 446 fun(env), 447 ) 448 449 env.IP++ 450 return env.Code[env.IP], env 451 } 452 case func(*Env) uint: 453 454 ret = func(env *Env) (Stmt, *Env) { 455 lhs := lhsfun(env) 456 lhs.SetUint(lhs.Uint() + uint64(fun(env), 457 ), 458 ) 459 460 env.IP++ 461 return env.Code[env.IP], env 462 } 463 case func(*Env) uint8: 464 465 ret = func(env *Env) (Stmt, *Env) { 466 lhs := lhsfun(env) 467 lhs.SetUint(lhs.Uint() + uint64(fun(env), 468 ), 469 ) 470 471 env.IP++ 472 return env.Code[env.IP], env 473 } 474 case func(*Env) uint16: 475 476 ret = func(env *Env) (Stmt, *Env) { 477 lhs := lhsfun(env) 478 lhs.SetUint(lhs.Uint() + uint64(fun(env), 479 ), 480 ) 481 482 env.IP++ 483 return env.Code[env.IP], env 484 } 485 case func(*Env) uint32: 486 487 ret = func(env *Env) (Stmt, *Env) { 488 lhs := lhsfun(env) 489 lhs.SetUint(lhs.Uint() + uint64(fun(env), 490 ), 491 ) 492 493 env.IP++ 494 return env.Code[env.IP], env 495 } 496 case func(*Env) uint64: 497 498 ret = func(env *Env) (Stmt, *Env) { 499 lhs := lhsfun(env) 500 lhs.SetUint(lhs.Uint() + 501 fun(env), 502 ) 503 504 env.IP++ 505 return env.Code[env.IP], env 506 } 507 case func(*Env) uintptr: 508 509 ret = func(env *Env) (Stmt, *Env) { 510 lhs := lhsfun(env) 511 lhs.SetUint(lhs.Uint() + uint64(fun(env), 512 ), 513 ) 514 515 env.IP++ 516 return env.Code[env.IP], env 517 } 518 case func(*Env) float32: 519 520 ret = func(env *Env) (Stmt, *Env) { 521 lhs := lhsfun(env) 522 lhs.SetFloat(lhs.Float() + float64(fun(env), 523 ), 524 ) 525 526 env.IP++ 527 return env.Code[env.IP], env 528 } 529 case func(*Env) float64: 530 531 ret = func(env *Env) (Stmt, *Env) { 532 lhs := lhsfun(env) 533 lhs.SetFloat(lhs.Float() + 534 fun(env), 535 ) 536 537 env.IP++ 538 return env.Code[env.IP], env 539 } 540 case func(*Env) complex64: 541 542 ret = func(env *Env) (Stmt, *Env) { 543 lhs := lhsfun(env) 544 lhs.SetComplex(lhs.Complex() + complex128(fun(env), 545 ), 546 ) 547 548 env.IP++ 549 return env.Code[env.IP], env 550 } 551 case func(*Env) complex128: 552 553 ret = func(env *Env) (Stmt, *Env) { 554 lhs := lhsfun(env) 555 lhs.SetComplex(lhs.Complex() + 556 fun(env), 557 ) 558 559 env.IP++ 560 return env.Code[env.IP], env 561 } 562 case func(*Env) string: 563 564 ret = func(env *Env) (Stmt, *Env) { 565 lhs := lhsfun(env) 566 lhs.SetString(lhs.String() + 567 fun(env), 568 ) 569 570 env.IP++ 571 return env.Code[env.IP], env 572 } 573 default: 574 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.ADD, place.Type, funTypeOut(fun)) 575 576 } 577 } else { 578 switch fun := fun.(type) { 579 case func(*Env) int: 580 581 ret = func(env *Env) (Stmt, *Env) { 582 lhs := lhsfun(env) 583 key := keyfun(env) 584 var result int 585 586 if v := lhs.MapIndex(key); v != Nil { 587 result = int(v.Int()) 588 } 589 result += fun(env) 590 591 lhs.SetMapIndex(key, r.ValueOf(result)) 592 env.IP++ 593 return env.Code[env.IP], env 594 } 595 case func(*Env) int8: 596 597 ret = func(env *Env) (Stmt, *Env) { 598 lhs := lhsfun(env) 599 key := keyfun(env) 600 var result int8 601 602 if v := lhs.MapIndex(key); v != Nil { 603 result = int8(v.Int()) 604 } 605 result += fun(env) 606 607 lhs.SetMapIndex(key, r.ValueOf(result)) 608 env.IP++ 609 return env.Code[env.IP], env 610 } 611 case func(*Env) int16: 612 613 ret = func(env *Env) (Stmt, *Env) { 614 lhs := lhsfun(env) 615 key := keyfun(env) 616 var result int16 617 618 if v := lhs.MapIndex(key); v != Nil { 619 result = int16(v.Int()) 620 } 621 result += fun(env) 622 623 lhs.SetMapIndex(key, r.ValueOf(result)) 624 env.IP++ 625 return env.Code[env.IP], env 626 } 627 case func(*Env) int32: 628 629 ret = func(env *Env) (Stmt, *Env) { 630 lhs := lhsfun(env) 631 key := keyfun(env) 632 var result int32 633 634 if v := lhs.MapIndex(key); v != Nil { 635 result = int32(v.Int()) 636 } 637 result += fun(env) 638 639 lhs.SetMapIndex(key, r.ValueOf(result)) 640 env.IP++ 641 return env.Code[env.IP], env 642 } 643 case func(*Env) int64: 644 645 ret = func(env *Env) (Stmt, *Env) { 646 lhs := lhsfun(env) 647 key := keyfun(env) 648 var result int64 649 650 if v := lhs.MapIndex(key); v != Nil { 651 result = v.Int() 652 } 653 result += fun(env) 654 655 lhs.SetMapIndex(key, r.ValueOf(result)) 656 env.IP++ 657 return env.Code[env.IP], env 658 } 659 case func(*Env) uint: 660 661 ret = func(env *Env) (Stmt, *Env) { 662 lhs := lhsfun(env) 663 key := keyfun(env) 664 var result uint 665 666 if v := lhs.MapIndex(key); v != Nil { 667 result = uint(v.Uint()) 668 } 669 result += fun(env) 670 671 lhs.SetMapIndex(key, r.ValueOf(result)) 672 env.IP++ 673 return env.Code[env.IP], env 674 } 675 case func(*Env) uint8: 676 677 ret = func(env *Env) (Stmt, *Env) { 678 lhs := lhsfun(env) 679 key := keyfun(env) 680 var result uint8 681 682 if v := lhs.MapIndex(key); v != Nil { 683 result = uint8(v.Uint()) 684 } 685 result += fun(env) 686 687 lhs.SetMapIndex(key, r.ValueOf(result)) 688 env.IP++ 689 return env.Code[env.IP], env 690 } 691 case func(*Env) uint16: 692 693 ret = func(env *Env) (Stmt, *Env) { 694 lhs := lhsfun(env) 695 key := keyfun(env) 696 var result uint16 697 698 if v := lhs.MapIndex(key); v != Nil { 699 result = uint16(v.Uint()) 700 } 701 result += fun(env) 702 703 lhs.SetMapIndex(key, r.ValueOf(result)) 704 env.IP++ 705 return env.Code[env.IP], env 706 } 707 case func(*Env) uint32: 708 709 ret = func(env *Env) (Stmt, *Env) { 710 lhs := lhsfun(env) 711 key := keyfun(env) 712 var result uint32 713 714 if v := lhs.MapIndex(key); v != Nil { 715 result = uint32(v.Uint()) 716 } 717 result += fun(env) 718 719 lhs.SetMapIndex(key, r.ValueOf(result)) 720 env.IP++ 721 return env.Code[env.IP], env 722 } 723 case func(*Env) uint64: 724 725 ret = func(env *Env) (Stmt, *Env) { 726 lhs := lhsfun(env) 727 key := keyfun(env) 728 var result uint64 729 730 if v := lhs.MapIndex(key); v != Nil { 731 result = v.Uint() 732 } 733 result += fun(env) 734 735 lhs.SetMapIndex(key, r.ValueOf(result)) 736 env.IP++ 737 return env.Code[env.IP], env 738 } 739 case func(*Env) uintptr: 740 741 ret = func(env *Env) (Stmt, *Env) { 742 lhs := lhsfun(env) 743 key := keyfun(env) 744 var result uintptr 745 746 if v := lhs.MapIndex(key); v != Nil { 747 result = uintptr(v.Uint()) 748 } 749 result += fun(env) 750 751 lhs.SetMapIndex(key, r.ValueOf(result)) 752 env.IP++ 753 return env.Code[env.IP], env 754 } 755 case func(*Env) float32: 756 757 ret = func(env *Env) (Stmt, *Env) { 758 lhs := lhsfun(env) 759 key := keyfun(env) 760 var result float32 761 762 if v := lhs.MapIndex(key); v != Nil { 763 result = float32(v.Float()) 764 } 765 result += fun(env) 766 767 lhs.SetMapIndex(key, r.ValueOf(result)) 768 env.IP++ 769 return env.Code[env.IP], env 770 } 771 case func(*Env) float64: 772 773 ret = func(env *Env) (Stmt, *Env) { 774 lhs := lhsfun(env) 775 key := keyfun(env) 776 var result float64 777 778 if v := lhs.MapIndex(key); v != Nil { 779 result = v.Float() 780 } 781 result += fun(env) 782 783 lhs.SetMapIndex(key, r.ValueOf(result)) 784 env.IP++ 785 return env.Code[env.IP], env 786 } 787 case func(*Env) complex64: 788 789 ret = func(env *Env) (Stmt, *Env) { 790 lhs := lhsfun(env) 791 key := keyfun(env) 792 var result complex64 793 794 if v := lhs.MapIndex(key); v != Nil { 795 result = complex64(v.Complex()) 796 } 797 result += fun(env) 798 799 lhs.SetMapIndex(key, r.ValueOf(result)) 800 env.IP++ 801 return env.Code[env.IP], env 802 } 803 case func(*Env) complex128: 804 805 ret = func(env *Env) (Stmt, *Env) { 806 lhs := lhsfun(env) 807 key := keyfun(env) 808 var result complex128 809 810 if v := lhs.MapIndex(key); v != Nil { 811 result = v.Complex() 812 } 813 result += fun(env) 814 815 lhs.SetMapIndex(key, r.ValueOf(result)) 816 env.IP++ 817 return env.Code[env.IP], env 818 } 819 case func(*Env) string: 820 821 ret = func(env *Env) (Stmt, *Env) { 822 lhs := lhsfun(env) 823 key := keyfun(env) 824 var result string 825 826 if v := lhs.MapIndex(key); v != Nil { 827 result = v.String() 828 } 829 result += fun(env) 830 831 lhs.SetMapIndex(key, r.ValueOf(result)) 832 env.IP++ 833 return env.Code[env.IP], env 834 } 835 default: 836 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.ADD, place.Type, funTypeOut(fun)) 837 838 } 839 } 840 return ret 841} 842func (c *Comp) placeSubConst(place *Place, val I) Stmt { 843 if isLiteralNumber(val, 0) { 844 return c.placeForSideEffects(place) 845 } 846 847 { 848 var ret Stmt 849 lhsfun := place.Fun 850 keyfun := place.MapKey 851 v := r.ValueOf(val) 852 853 if keyfun == nil { 854 switch reflect.Category(place.Type.Kind()) { 855 case r.Int: 856 val := v.Int() 857 858 ret = func(env *Env) (Stmt, *Env) { 859 lhs := lhsfun(env) 860 lhs.SetInt(lhs.Int() - int64(val, 861 ), 862 ) 863 864 env.IP++ 865 return env.Code[env.IP], env 866 } 867 case r.Uint: 868 val := v.Uint() 869 870 ret = func(env *Env) (Stmt, *Env) { 871 lhs := lhsfun(env) 872 lhs.SetUint(lhs.Uint() - uint64(val, 873 ), 874 ) 875 876 env.IP++ 877 return env.Code[env.IP], env 878 } 879 case r.Float64: 880 val := v.Float() 881 882 ret = func(env *Env) (Stmt, *Env) { 883 lhs := lhsfun(env) 884 lhs.SetFloat(lhs.Float() - 885 val, 886 ) 887 888 env.IP++ 889 return env.Code[env.IP], env 890 } 891 case r.Complex128: 892 val := v.Complex() 893 894 ret = func(env *Env) (Stmt, *Env) { 895 lhs := lhsfun(env) 896 lhs.SetComplex(lhs.Complex() - 897 val, 898 ) 899 900 env.IP++ 901 return env.Code[env.IP], env 902 } 903 default: 904 c.Errorf(`invalid operator %s= on <%v>`, token.SUB, place.Type) 905 906 } 907 } else { 908 switch place.Type.Kind() { 909 case r.Int: 910 val := int(v.Int()) 911 912 ret = func(env *Env) (Stmt, *Env) { 913 lhs := lhsfun(env) 914 key := keyfun(env) 915 var result int 916 917 if v := lhs.MapIndex(key); v != Nil { 918 result = int(v.Int()) 919 } 920 result -= val 921 922 lhs.SetMapIndex(key, r.ValueOf(result)) 923 env.IP++ 924 return env.Code[env.IP], env 925 } 926 case r.Int8: 927 val := int8(v.Int()) 928 929 ret = func(env *Env) (Stmt, *Env) { 930 lhs := lhsfun(env) 931 key := keyfun(env) 932 var result int8 933 934 if v := lhs.MapIndex(key); v != Nil { 935 result = int8(v.Int()) 936 } 937 result -= val 938 939 lhs.SetMapIndex(key, r.ValueOf(result)) 940 env.IP++ 941 return env.Code[env.IP], env 942 } 943 case r.Int16: 944 val := int16(v.Int()) 945 946 ret = func(env *Env) (Stmt, *Env) { 947 lhs := lhsfun(env) 948 key := keyfun(env) 949 var result int16 950 951 if v := lhs.MapIndex(key); v != Nil { 952 result = int16(v.Int()) 953 } 954 result -= val 955 956 lhs.SetMapIndex(key, r.ValueOf(result)) 957 env.IP++ 958 return env.Code[env.IP], env 959 } 960 case r.Int32: 961 val := int32(v.Int()) 962 963 ret = func(env *Env) (Stmt, *Env) { 964 lhs := lhsfun(env) 965 key := keyfun(env) 966 var result int32 967 968 if v := lhs.MapIndex(key); v != Nil { 969 result = int32(v.Int()) 970 } 971 result -= val 972 973 lhs.SetMapIndex(key, r.ValueOf(result)) 974 env.IP++ 975 return env.Code[env.IP], env 976 } 977 case r.Int64: 978 val := int64(v.Int()) 979 980 ret = func(env *Env) (Stmt, *Env) { 981 lhs := lhsfun(env) 982 key := keyfun(env) 983 var result int64 984 985 if v := lhs.MapIndex(key); v != Nil { 986 result = v.Int() 987 } 988 result -= val 989 990 lhs.SetMapIndex(key, r.ValueOf(result)) 991 env.IP++ 992 return env.Code[env.IP], env 993 } 994 case r.Uint: 995 val := uint(v.Uint()) 996 997 ret = func(env *Env) (Stmt, *Env) { 998 lhs := lhsfun(env) 999 key := keyfun(env) 1000 var result uint 1001 1002 if v := lhs.MapIndex(key); v != Nil { 1003 result = uint(v.Uint()) 1004 } 1005 result -= val 1006 1007 lhs.SetMapIndex(key, r.ValueOf(result)) 1008 env.IP++ 1009 return env.Code[env.IP], env 1010 } 1011 case r.Uint8: 1012 val := uint8(v.Uint()) 1013 1014 ret = func(env *Env) (Stmt, *Env) { 1015 lhs := lhsfun(env) 1016 key := keyfun(env) 1017 var result uint8 1018 1019 if v := lhs.MapIndex(key); v != Nil { 1020 result = uint8(v.Uint()) 1021 } 1022 result -= val 1023 1024 lhs.SetMapIndex(key, r.ValueOf(result)) 1025 env.IP++ 1026 return env.Code[env.IP], env 1027 } 1028 case r.Uint16: 1029 val := uint16(v.Uint()) 1030 1031 ret = func(env *Env) (Stmt, *Env) { 1032 lhs := lhsfun(env) 1033 key := keyfun(env) 1034 var result uint16 1035 1036 if v := lhs.MapIndex(key); v != Nil { 1037 result = uint16(v.Uint()) 1038 } 1039 result -= val 1040 1041 lhs.SetMapIndex(key, r.ValueOf(result)) 1042 env.IP++ 1043 return env.Code[env.IP], env 1044 } 1045 case r.Uint32: 1046 val := uint32(v.Uint()) 1047 1048 ret = func(env *Env) (Stmt, *Env) { 1049 lhs := lhsfun(env) 1050 key := keyfun(env) 1051 var result uint32 1052 1053 if v := lhs.MapIndex(key); v != Nil { 1054 result = uint32(v.Uint()) 1055 } 1056 result -= val 1057 1058 lhs.SetMapIndex(key, r.ValueOf(result)) 1059 env.IP++ 1060 return env.Code[env.IP], env 1061 } 1062 case r.Uint64: 1063 val := uint64(v.Uint()) 1064 1065 ret = func(env *Env) (Stmt, *Env) { 1066 lhs := lhsfun(env) 1067 key := keyfun(env) 1068 var result uint64 1069 1070 if v := lhs.MapIndex(key); v != Nil { 1071 result = v.Uint() 1072 } 1073 result -= val 1074 1075 lhs.SetMapIndex(key, r.ValueOf(result)) 1076 env.IP++ 1077 return env.Code[env.IP], env 1078 } 1079 case r.Uintptr: 1080 val := uintptr(v.Uint()) 1081 1082 ret = func(env *Env) (Stmt, *Env) { 1083 lhs := lhsfun(env) 1084 key := keyfun(env) 1085 var result uintptr 1086 1087 if v := lhs.MapIndex(key); v != Nil { 1088 result = uintptr(v.Uint()) 1089 } 1090 result -= val 1091 1092 lhs.SetMapIndex(key, r.ValueOf(result)) 1093 env.IP++ 1094 return env.Code[env.IP], env 1095 } 1096 case r.Float32: 1097 val := float32(v.Float()) 1098 1099 ret = func(env *Env) (Stmt, *Env) { 1100 lhs := lhsfun(env) 1101 key := keyfun(env) 1102 var result float32 1103 1104 if v := lhs.MapIndex(key); v != Nil { 1105 result = float32(v.Float()) 1106 } 1107 result -= val 1108 1109 lhs.SetMapIndex(key, r.ValueOf(result)) 1110 env.IP++ 1111 return env.Code[env.IP], env 1112 } 1113 case r.Float64: 1114 val := float64(v.Float()) 1115 1116 ret = func(env *Env) (Stmt, *Env) { 1117 lhs := lhsfun(env) 1118 key := keyfun(env) 1119 var result float64 1120 1121 if v := lhs.MapIndex(key); v != Nil { 1122 result = v.Float() 1123 } 1124 result -= val 1125 1126 lhs.SetMapIndex(key, r.ValueOf(result)) 1127 env.IP++ 1128 return env.Code[env.IP], env 1129 } 1130 case r.Complex64: 1131 val := complex64(v.Complex()) 1132 1133 ret = func(env *Env) (Stmt, *Env) { 1134 lhs := lhsfun(env) 1135 key := keyfun(env) 1136 var result complex64 1137 1138 if v := lhs.MapIndex(key); v != Nil { 1139 result = complex64(v.Complex()) 1140 } 1141 result -= val 1142 1143 lhs.SetMapIndex(key, r.ValueOf(result)) 1144 env.IP++ 1145 return env.Code[env.IP], env 1146 } 1147 case r.Complex128: 1148 val := complex128(v.Complex()) 1149 1150 ret = func(env *Env) (Stmt, *Env) { 1151 lhs := lhsfun(env) 1152 key := keyfun(env) 1153 var result complex128 1154 1155 if v := lhs.MapIndex(key); v != Nil { 1156 result = v.Complex() 1157 } 1158 result -= val 1159 1160 lhs.SetMapIndex(key, r.ValueOf(result)) 1161 env.IP++ 1162 return env.Code[env.IP], env 1163 } 1164 default: 1165 c.Errorf(`invalid operator %s= on <%v>`, token.SUB, place.Type) 1166 1167 } 1168 } 1169 return ret 1170 } 1171} 1172func (c *Comp) placeSubExpr(place *Place, fun I) Stmt { 1173 var ret Stmt 1174 lhsfun := place.Fun 1175 keyfun := place.MapKey 1176 if keyfun == nil { 1177 switch fun := fun.(type) { 1178 case func(*Env) int: 1179 1180 ret = func(env *Env) (Stmt, *Env) { 1181 lhs := lhsfun(env) 1182 lhs.SetInt(lhs.Int() - int64(fun(env), 1183 ), 1184 ) 1185 1186 env.IP++ 1187 return env.Code[env.IP], env 1188 } 1189 case func(*Env) int8: 1190 1191 ret = func(env *Env) (Stmt, *Env) { 1192 lhs := lhsfun(env) 1193 lhs.SetInt(lhs.Int() - int64(fun(env), 1194 ), 1195 ) 1196 1197 env.IP++ 1198 return env.Code[env.IP], env 1199 } 1200 case func(*Env) int16: 1201 1202 ret = func(env *Env) (Stmt, *Env) { 1203 lhs := lhsfun(env) 1204 lhs.SetInt(lhs.Int() - int64(fun(env), 1205 ), 1206 ) 1207 1208 env.IP++ 1209 return env.Code[env.IP], env 1210 } 1211 case func(*Env) int32: 1212 1213 ret = func(env *Env) (Stmt, *Env) { 1214 lhs := lhsfun(env) 1215 lhs.SetInt(lhs.Int() - int64(fun(env), 1216 ), 1217 ) 1218 1219 env.IP++ 1220 return env.Code[env.IP], env 1221 } 1222 case func(*Env) int64: 1223 1224 ret = func(env *Env) (Stmt, *Env) { 1225 lhs := lhsfun(env) 1226 lhs.SetInt(lhs.Int() - 1227 fun(env), 1228 ) 1229 1230 env.IP++ 1231 return env.Code[env.IP], env 1232 } 1233 case func(*Env) uint: 1234 1235 ret = func(env *Env) (Stmt, *Env) { 1236 lhs := lhsfun(env) 1237 lhs.SetUint(lhs.Uint() - uint64(fun(env), 1238 ), 1239 ) 1240 1241 env.IP++ 1242 return env.Code[env.IP], env 1243 } 1244 case func(*Env) uint8: 1245 1246 ret = func(env *Env) (Stmt, *Env) { 1247 lhs := lhsfun(env) 1248 lhs.SetUint(lhs.Uint() - uint64(fun(env), 1249 ), 1250 ) 1251 1252 env.IP++ 1253 return env.Code[env.IP], env 1254 } 1255 case func(*Env) uint16: 1256 1257 ret = func(env *Env) (Stmt, *Env) { 1258 lhs := lhsfun(env) 1259 lhs.SetUint(lhs.Uint() - uint64(fun(env), 1260 ), 1261 ) 1262 1263 env.IP++ 1264 return env.Code[env.IP], env 1265 } 1266 case func(*Env) uint32: 1267 1268 ret = func(env *Env) (Stmt, *Env) { 1269 lhs := lhsfun(env) 1270 lhs.SetUint(lhs.Uint() - uint64(fun(env), 1271 ), 1272 ) 1273 1274 env.IP++ 1275 return env.Code[env.IP], env 1276 } 1277 case func(*Env) uint64: 1278 1279 ret = func(env *Env) (Stmt, *Env) { 1280 lhs := lhsfun(env) 1281 lhs.SetUint(lhs.Uint() - 1282 fun(env), 1283 ) 1284 1285 env.IP++ 1286 return env.Code[env.IP], env 1287 } 1288 case func(*Env) uintptr: 1289 1290 ret = func(env *Env) (Stmt, *Env) { 1291 lhs := lhsfun(env) 1292 lhs.SetUint(lhs.Uint() - uint64(fun(env), 1293 ), 1294 ) 1295 1296 env.IP++ 1297 return env.Code[env.IP], env 1298 } 1299 case func(*Env) float32: 1300 1301 ret = func(env *Env) (Stmt, *Env) { 1302 lhs := lhsfun(env) 1303 lhs.SetFloat(lhs.Float() - float64(fun(env), 1304 ), 1305 ) 1306 1307 env.IP++ 1308 return env.Code[env.IP], env 1309 } 1310 case func(*Env) float64: 1311 1312 ret = func(env *Env) (Stmt, *Env) { 1313 lhs := lhsfun(env) 1314 lhs.SetFloat(lhs.Float() - 1315 fun(env), 1316 ) 1317 1318 env.IP++ 1319 return env.Code[env.IP], env 1320 } 1321 case func(*Env) complex64: 1322 1323 ret = func(env *Env) (Stmt, *Env) { 1324 lhs := lhsfun(env) 1325 lhs.SetComplex(lhs.Complex() - complex128(fun(env), 1326 ), 1327 ) 1328 1329 env.IP++ 1330 return env.Code[env.IP], env 1331 } 1332 case func(*Env) complex128: 1333 1334 ret = func(env *Env) (Stmt, *Env) { 1335 lhs := lhsfun(env) 1336 lhs.SetComplex(lhs.Complex() - 1337 fun(env), 1338 ) 1339 1340 env.IP++ 1341 return env.Code[env.IP], env 1342 } 1343 default: 1344 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.SUB, place.Type, funTypeOut(fun)) 1345 1346 } 1347 } else { 1348 switch fun := fun.(type) { 1349 case func(*Env) int: 1350 1351 ret = func(env *Env) (Stmt, *Env) { 1352 lhs := lhsfun(env) 1353 key := keyfun(env) 1354 var result int 1355 1356 if v := lhs.MapIndex(key); v != Nil { 1357 result = int(v.Int()) 1358 } 1359 result -= fun(env) 1360 1361 lhs.SetMapIndex(key, r.ValueOf(result)) 1362 env.IP++ 1363 return env.Code[env.IP], env 1364 } 1365 case func(*Env) int8: 1366 1367 ret = func(env *Env) (Stmt, *Env) { 1368 lhs := lhsfun(env) 1369 key := keyfun(env) 1370 var result int8 1371 1372 if v := lhs.MapIndex(key); v != Nil { 1373 result = int8(v.Int()) 1374 } 1375 result -= fun(env) 1376 1377 lhs.SetMapIndex(key, r.ValueOf(result)) 1378 env.IP++ 1379 return env.Code[env.IP], env 1380 } 1381 case func(*Env) int16: 1382 1383 ret = func(env *Env) (Stmt, *Env) { 1384 lhs := lhsfun(env) 1385 key := keyfun(env) 1386 var result int16 1387 1388 if v := lhs.MapIndex(key); v != Nil { 1389 result = int16(v.Int()) 1390 } 1391 result -= fun(env) 1392 1393 lhs.SetMapIndex(key, r.ValueOf(result)) 1394 env.IP++ 1395 return env.Code[env.IP], env 1396 } 1397 case func(*Env) int32: 1398 1399 ret = func(env *Env) (Stmt, *Env) { 1400 lhs := lhsfun(env) 1401 key := keyfun(env) 1402 var result int32 1403 1404 if v := lhs.MapIndex(key); v != Nil { 1405 result = int32(v.Int()) 1406 } 1407 result -= fun(env) 1408 1409 lhs.SetMapIndex(key, r.ValueOf(result)) 1410 env.IP++ 1411 return env.Code[env.IP], env 1412 } 1413 case func(*Env) int64: 1414 1415 ret = func(env *Env) (Stmt, *Env) { 1416 lhs := lhsfun(env) 1417 key := keyfun(env) 1418 var result int64 1419 1420 if v := lhs.MapIndex(key); v != Nil { 1421 result = v.Int() 1422 } 1423 result -= fun(env) 1424 1425 lhs.SetMapIndex(key, r.ValueOf(result)) 1426 env.IP++ 1427 return env.Code[env.IP], env 1428 } 1429 case func(*Env) uint: 1430 1431 ret = func(env *Env) (Stmt, *Env) { 1432 lhs := lhsfun(env) 1433 key := keyfun(env) 1434 var result uint 1435 1436 if v := lhs.MapIndex(key); v != Nil { 1437 result = uint(v.Uint()) 1438 } 1439 result -= fun(env) 1440 1441 lhs.SetMapIndex(key, r.ValueOf(result)) 1442 env.IP++ 1443 return env.Code[env.IP], env 1444 } 1445 case func(*Env) uint8: 1446 1447 ret = func(env *Env) (Stmt, *Env) { 1448 lhs := lhsfun(env) 1449 key := keyfun(env) 1450 var result uint8 1451 1452 if v := lhs.MapIndex(key); v != Nil { 1453 result = uint8(v.Uint()) 1454 } 1455 result -= fun(env) 1456 1457 lhs.SetMapIndex(key, r.ValueOf(result)) 1458 env.IP++ 1459 return env.Code[env.IP], env 1460 } 1461 case func(*Env) uint16: 1462 1463 ret = func(env *Env) (Stmt, *Env) { 1464 lhs := lhsfun(env) 1465 key := keyfun(env) 1466 var result uint16 1467 1468 if v := lhs.MapIndex(key); v != Nil { 1469 result = uint16(v.Uint()) 1470 } 1471 result -= fun(env) 1472 1473 lhs.SetMapIndex(key, r.ValueOf(result)) 1474 env.IP++ 1475 return env.Code[env.IP], env 1476 } 1477 case func(*Env) uint32: 1478 1479 ret = func(env *Env) (Stmt, *Env) { 1480 lhs := lhsfun(env) 1481 key := keyfun(env) 1482 var result uint32 1483 1484 if v := lhs.MapIndex(key); v != Nil { 1485 result = uint32(v.Uint()) 1486 } 1487 result -= fun(env) 1488 1489 lhs.SetMapIndex(key, r.ValueOf(result)) 1490 env.IP++ 1491 return env.Code[env.IP], env 1492 } 1493 case func(*Env) uint64: 1494 1495 ret = func(env *Env) (Stmt, *Env) { 1496 lhs := lhsfun(env) 1497 key := keyfun(env) 1498 var result uint64 1499 1500 if v := lhs.MapIndex(key); v != Nil { 1501 result = v.Uint() 1502 } 1503 result -= fun(env) 1504 1505 lhs.SetMapIndex(key, r.ValueOf(result)) 1506 env.IP++ 1507 return env.Code[env.IP], env 1508 } 1509 case func(*Env) uintptr: 1510 1511 ret = func(env *Env) (Stmt, *Env) { 1512 lhs := lhsfun(env) 1513 key := keyfun(env) 1514 var result uintptr 1515 1516 if v := lhs.MapIndex(key); v != Nil { 1517 result = uintptr(v.Uint()) 1518 } 1519 result -= fun(env) 1520 1521 lhs.SetMapIndex(key, r.ValueOf(result)) 1522 env.IP++ 1523 return env.Code[env.IP], env 1524 } 1525 case func(*Env) float32: 1526 1527 ret = func(env *Env) (Stmt, *Env) { 1528 lhs := lhsfun(env) 1529 key := keyfun(env) 1530 var result float32 1531 1532 if v := lhs.MapIndex(key); v != Nil { 1533 result = float32(v.Float()) 1534 } 1535 result -= fun(env) 1536 1537 lhs.SetMapIndex(key, r.ValueOf(result)) 1538 env.IP++ 1539 return env.Code[env.IP], env 1540 } 1541 case func(*Env) float64: 1542 1543 ret = func(env *Env) (Stmt, *Env) { 1544 lhs := lhsfun(env) 1545 key := keyfun(env) 1546 var result float64 1547 1548 if v := lhs.MapIndex(key); v != Nil { 1549 result = v.Float() 1550 } 1551 result -= fun(env) 1552 1553 lhs.SetMapIndex(key, r.ValueOf(result)) 1554 env.IP++ 1555 return env.Code[env.IP], env 1556 } 1557 case func(*Env) complex64: 1558 1559 ret = func(env *Env) (Stmt, *Env) { 1560 lhs := lhsfun(env) 1561 key := keyfun(env) 1562 var result complex64 1563 1564 if v := lhs.MapIndex(key); v != Nil { 1565 result = complex64(v.Complex()) 1566 } 1567 result -= fun(env) 1568 1569 lhs.SetMapIndex(key, r.ValueOf(result)) 1570 env.IP++ 1571 return env.Code[env.IP], env 1572 } 1573 case func(*Env) complex128: 1574 1575 ret = func(env *Env) (Stmt, *Env) { 1576 lhs := lhsfun(env) 1577 key := keyfun(env) 1578 var result complex128 1579 1580 if v := lhs.MapIndex(key); v != Nil { 1581 result = v.Complex() 1582 } 1583 result -= fun(env) 1584 1585 lhs.SetMapIndex(key, r.ValueOf(result)) 1586 env.IP++ 1587 return env.Code[env.IP], env 1588 } 1589 default: 1590 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.SUB, place.Type, funTypeOut(fun)) 1591 1592 } 1593 } 1594 return ret 1595} 1596func (c *Comp) placeMulConst(place *Place, val I) Stmt { 1597 if isLiteralNumber(val, 0) { 1598 return c.placeSetZero(place) 1599 } else if isLiteralNumber(val, 1) { 1600 return c.placeForSideEffects(place) 1601 } 1602 1603 { 1604 var ret Stmt 1605 lhsfun := place.Fun 1606 keyfun := place.MapKey 1607 v := r.ValueOf(val) 1608 1609 if keyfun == nil { 1610 switch reflect.Category(place.Type.Kind()) { 1611 case r.Int: 1612 val := v.Int() 1613 1614 ret = func(env *Env) (Stmt, *Env) { 1615 lhs := lhsfun(env) 1616 lhs.SetInt(lhs.Int() * int64(val, 1617 ), 1618 ) 1619 1620 env.IP++ 1621 return env.Code[env.IP], env 1622 } 1623 case r.Uint: 1624 val := v.Uint() 1625 1626 ret = func(env *Env) (Stmt, *Env) { 1627 lhs := lhsfun(env) 1628 lhs.SetUint(lhs.Uint() * uint64(val, 1629 ), 1630 ) 1631 1632 env.IP++ 1633 return env.Code[env.IP], env 1634 } 1635 case r.Float64: 1636 val := v.Float() 1637 1638 ret = func(env *Env) (Stmt, *Env) { 1639 lhs := lhsfun(env) 1640 lhs.SetFloat(lhs.Float() * 1641 val, 1642 ) 1643 1644 env.IP++ 1645 return env.Code[env.IP], env 1646 } 1647 case r.Complex128: 1648 val := v.Complex() 1649 1650 ret = func(env *Env) (Stmt, *Env) { 1651 lhs := lhsfun(env) 1652 lhs.SetComplex(lhs.Complex() * 1653 val, 1654 ) 1655 1656 env.IP++ 1657 return env.Code[env.IP], env 1658 } 1659 default: 1660 c.Errorf(`invalid operator %s= on <%v>`, token.MUL, place.Type) 1661 1662 } 1663 } else { 1664 switch place.Type.Kind() { 1665 case r.Int: 1666 val := int(v.Int()) 1667 1668 ret = func(env *Env) (Stmt, *Env) { 1669 lhs := lhsfun(env) 1670 key := keyfun(env) 1671 var result int 1672 1673 if v := lhs.MapIndex(key); v != Nil { 1674 result = int(v.Int()) 1675 } 1676 result *= val 1677 1678 lhs.SetMapIndex(key, r.ValueOf(result)) 1679 env.IP++ 1680 return env.Code[env.IP], env 1681 } 1682 case r.Int8: 1683 val := int8(v.Int()) 1684 1685 ret = func(env *Env) (Stmt, *Env) { 1686 lhs := lhsfun(env) 1687 key := keyfun(env) 1688 var result int8 1689 1690 if v := lhs.MapIndex(key); v != Nil { 1691 result = int8(v.Int()) 1692 } 1693 result *= val 1694 1695 lhs.SetMapIndex(key, r.ValueOf(result)) 1696 env.IP++ 1697 return env.Code[env.IP], env 1698 } 1699 case r.Int16: 1700 val := int16(v.Int()) 1701 1702 ret = func(env *Env) (Stmt, *Env) { 1703 lhs := lhsfun(env) 1704 key := keyfun(env) 1705 var result int16 1706 1707 if v := lhs.MapIndex(key); v != Nil { 1708 result = int16(v.Int()) 1709 } 1710 result *= val 1711 1712 lhs.SetMapIndex(key, r.ValueOf(result)) 1713 env.IP++ 1714 return env.Code[env.IP], env 1715 } 1716 case r.Int32: 1717 val := int32(v.Int()) 1718 1719 ret = func(env *Env) (Stmt, *Env) { 1720 lhs := lhsfun(env) 1721 key := keyfun(env) 1722 var result int32 1723 1724 if v := lhs.MapIndex(key); v != Nil { 1725 result = int32(v.Int()) 1726 } 1727 result *= val 1728 1729 lhs.SetMapIndex(key, r.ValueOf(result)) 1730 env.IP++ 1731 return env.Code[env.IP], env 1732 } 1733 case r.Int64: 1734 val := int64(v.Int()) 1735 1736 ret = func(env *Env) (Stmt, *Env) { 1737 lhs := lhsfun(env) 1738 key := keyfun(env) 1739 var result int64 1740 1741 if v := lhs.MapIndex(key); v != Nil { 1742 result = v.Int() 1743 } 1744 result *= val 1745 1746 lhs.SetMapIndex(key, r.ValueOf(result)) 1747 env.IP++ 1748 return env.Code[env.IP], env 1749 } 1750 case r.Uint: 1751 val := uint(v.Uint()) 1752 1753 ret = func(env *Env) (Stmt, *Env) { 1754 lhs := lhsfun(env) 1755 key := keyfun(env) 1756 var result uint 1757 1758 if v := lhs.MapIndex(key); v != Nil { 1759 result = uint(v.Uint()) 1760 } 1761 result *= val 1762 1763 lhs.SetMapIndex(key, r.ValueOf(result)) 1764 env.IP++ 1765 return env.Code[env.IP], env 1766 } 1767 case r.Uint8: 1768 val := uint8(v.Uint()) 1769 1770 ret = func(env *Env) (Stmt, *Env) { 1771 lhs := lhsfun(env) 1772 key := keyfun(env) 1773 var result uint8 1774 1775 if v := lhs.MapIndex(key); v != Nil { 1776 result = uint8(v.Uint()) 1777 } 1778 result *= val 1779 1780 lhs.SetMapIndex(key, r.ValueOf(result)) 1781 env.IP++ 1782 return env.Code[env.IP], env 1783 } 1784 case r.Uint16: 1785 val := uint16(v.Uint()) 1786 1787 ret = func(env *Env) (Stmt, *Env) { 1788 lhs := lhsfun(env) 1789 key := keyfun(env) 1790 var result uint16 1791 1792 if v := lhs.MapIndex(key); v != Nil { 1793 result = uint16(v.Uint()) 1794 } 1795 result *= val 1796 1797 lhs.SetMapIndex(key, r.ValueOf(result)) 1798 env.IP++ 1799 return env.Code[env.IP], env 1800 } 1801 case r.Uint32: 1802 val := uint32(v.Uint()) 1803 1804 ret = func(env *Env) (Stmt, *Env) { 1805 lhs := lhsfun(env) 1806 key := keyfun(env) 1807 var result uint32 1808 1809 if v := lhs.MapIndex(key); v != Nil { 1810 result = uint32(v.Uint()) 1811 } 1812 result *= val 1813 1814 lhs.SetMapIndex(key, r.ValueOf(result)) 1815 env.IP++ 1816 return env.Code[env.IP], env 1817 } 1818 case r.Uint64: 1819 val := uint64(v.Uint()) 1820 1821 ret = func(env *Env) (Stmt, *Env) { 1822 lhs := lhsfun(env) 1823 key := keyfun(env) 1824 var result uint64 1825 1826 if v := lhs.MapIndex(key); v != Nil { 1827 result = v.Uint() 1828 } 1829 result *= val 1830 1831 lhs.SetMapIndex(key, r.ValueOf(result)) 1832 env.IP++ 1833 return env.Code[env.IP], env 1834 } 1835 case r.Uintptr: 1836 val := uintptr(v.Uint()) 1837 1838 ret = func(env *Env) (Stmt, *Env) { 1839 lhs := lhsfun(env) 1840 key := keyfun(env) 1841 var result uintptr 1842 1843 if v := lhs.MapIndex(key); v != Nil { 1844 result = uintptr(v.Uint()) 1845 } 1846 result *= val 1847 1848 lhs.SetMapIndex(key, r.ValueOf(result)) 1849 env.IP++ 1850 return env.Code[env.IP], env 1851 } 1852 case r.Float32: 1853 val := float32(v.Float()) 1854 1855 ret = func(env *Env) (Stmt, *Env) { 1856 lhs := lhsfun(env) 1857 key := keyfun(env) 1858 var result float32 1859 1860 if v := lhs.MapIndex(key); v != Nil { 1861 result = float32(v.Float()) 1862 } 1863 result *= val 1864 1865 lhs.SetMapIndex(key, r.ValueOf(result)) 1866 env.IP++ 1867 return env.Code[env.IP], env 1868 } 1869 case r.Float64: 1870 val := float64(v.Float()) 1871 1872 ret = func(env *Env) (Stmt, *Env) { 1873 lhs := lhsfun(env) 1874 key := keyfun(env) 1875 var result float64 1876 1877 if v := lhs.MapIndex(key); v != Nil { 1878 result = v.Float() 1879 } 1880 result *= val 1881 1882 lhs.SetMapIndex(key, r.ValueOf(result)) 1883 env.IP++ 1884 return env.Code[env.IP], env 1885 } 1886 case r.Complex64: 1887 val := complex64(v.Complex()) 1888 1889 ret = func(env *Env) (Stmt, *Env) { 1890 lhs := lhsfun(env) 1891 key := keyfun(env) 1892 var result complex64 1893 1894 if v := lhs.MapIndex(key); v != Nil { 1895 result = complex64(v.Complex()) 1896 } 1897 result *= val 1898 1899 lhs.SetMapIndex(key, r.ValueOf(result)) 1900 env.IP++ 1901 return env.Code[env.IP], env 1902 } 1903 case r.Complex128: 1904 val := complex128(v.Complex()) 1905 1906 ret = func(env *Env) (Stmt, *Env) { 1907 lhs := lhsfun(env) 1908 key := keyfun(env) 1909 var result complex128 1910 1911 if v := lhs.MapIndex(key); v != Nil { 1912 result = v.Complex() 1913 } 1914 result *= val 1915 1916 lhs.SetMapIndex(key, r.ValueOf(result)) 1917 env.IP++ 1918 return env.Code[env.IP], env 1919 } 1920 default: 1921 c.Errorf(`invalid operator %s= on <%v>`, token.MUL, place.Type) 1922 1923 } 1924 } 1925 return ret 1926 } 1927} 1928func (c *Comp) placeMulExpr(place *Place, fun I) Stmt { 1929 var ret Stmt 1930 lhsfun := place.Fun 1931 keyfun := place.MapKey 1932 if keyfun == nil { 1933 switch fun := fun.(type) { 1934 case func(*Env) int: 1935 1936 ret = func(env *Env) (Stmt, *Env) { 1937 lhs := lhsfun(env) 1938 lhs.SetInt(lhs.Int() * int64(fun(env), 1939 ), 1940 ) 1941 1942 env.IP++ 1943 return env.Code[env.IP], env 1944 } 1945 case func(*Env) int8: 1946 1947 ret = func(env *Env) (Stmt, *Env) { 1948 lhs := lhsfun(env) 1949 lhs.SetInt(lhs.Int() * int64(fun(env), 1950 ), 1951 ) 1952 1953 env.IP++ 1954 return env.Code[env.IP], env 1955 } 1956 case func(*Env) int16: 1957 1958 ret = func(env *Env) (Stmt, *Env) { 1959 lhs := lhsfun(env) 1960 lhs.SetInt(lhs.Int() * int64(fun(env), 1961 ), 1962 ) 1963 1964 env.IP++ 1965 return env.Code[env.IP], env 1966 } 1967 case func(*Env) int32: 1968 1969 ret = func(env *Env) (Stmt, *Env) { 1970 lhs := lhsfun(env) 1971 lhs.SetInt(lhs.Int() * int64(fun(env), 1972 ), 1973 ) 1974 1975 env.IP++ 1976 return env.Code[env.IP], env 1977 } 1978 case func(*Env) int64: 1979 1980 ret = func(env *Env) (Stmt, *Env) { 1981 lhs := lhsfun(env) 1982 lhs.SetInt(lhs.Int() * 1983 fun(env), 1984 ) 1985 1986 env.IP++ 1987 return env.Code[env.IP], env 1988 } 1989 case func(*Env) uint: 1990 1991 ret = func(env *Env) (Stmt, *Env) { 1992 lhs := lhsfun(env) 1993 lhs.SetUint(lhs.Uint() * uint64(fun(env), 1994 ), 1995 ) 1996 1997 env.IP++ 1998 return env.Code[env.IP], env 1999 } 2000 case func(*Env) uint8: 2001 2002 ret = func(env *Env) (Stmt, *Env) { 2003 lhs := lhsfun(env) 2004 lhs.SetUint(lhs.Uint() * uint64(fun(env), 2005 ), 2006 ) 2007 2008 env.IP++ 2009 return env.Code[env.IP], env 2010 } 2011 case func(*Env) uint16: 2012 2013 ret = func(env *Env) (Stmt, *Env) { 2014 lhs := lhsfun(env) 2015 lhs.SetUint(lhs.Uint() * uint64(fun(env), 2016 ), 2017 ) 2018 2019 env.IP++ 2020 return env.Code[env.IP], env 2021 } 2022 case func(*Env) uint32: 2023 2024 ret = func(env *Env) (Stmt, *Env) { 2025 lhs := lhsfun(env) 2026 lhs.SetUint(lhs.Uint() * uint64(fun(env), 2027 ), 2028 ) 2029 2030 env.IP++ 2031 return env.Code[env.IP], env 2032 } 2033 case func(*Env) uint64: 2034 2035 ret = func(env *Env) (Stmt, *Env) { 2036 lhs := lhsfun(env) 2037 lhs.SetUint(lhs.Uint() * 2038 fun(env), 2039 ) 2040 2041 env.IP++ 2042 return env.Code[env.IP], env 2043 } 2044 case func(*Env) uintptr: 2045 2046 ret = func(env *Env) (Stmt, *Env) { 2047 lhs := lhsfun(env) 2048 lhs.SetUint(lhs.Uint() * uint64(fun(env), 2049 ), 2050 ) 2051 2052 env.IP++ 2053 return env.Code[env.IP], env 2054 } 2055 case func(*Env) float32: 2056 2057 ret = func(env *Env) (Stmt, *Env) { 2058 lhs := lhsfun(env) 2059 lhs.SetFloat(lhs.Float() * float64(fun(env), 2060 ), 2061 ) 2062 2063 env.IP++ 2064 return env.Code[env.IP], env 2065 } 2066 case func(*Env) float64: 2067 2068 ret = func(env *Env) (Stmt, *Env) { 2069 lhs := lhsfun(env) 2070 lhs.SetFloat(lhs.Float() * 2071 fun(env), 2072 ) 2073 2074 env.IP++ 2075 return env.Code[env.IP], env 2076 } 2077 case func(*Env) complex64: 2078 2079 ret = func(env *Env) (Stmt, *Env) { 2080 lhs := lhsfun(env) 2081 lhs.SetComplex(lhs.Complex() * complex128(fun(env), 2082 ), 2083 ) 2084 2085 env.IP++ 2086 return env.Code[env.IP], env 2087 } 2088 case func(*Env) complex128: 2089 2090 ret = func(env *Env) (Stmt, *Env) { 2091 lhs := lhsfun(env) 2092 lhs.SetComplex(lhs.Complex() * 2093 fun(env), 2094 ) 2095 2096 env.IP++ 2097 return env.Code[env.IP], env 2098 } 2099 default: 2100 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.MUL, place.Type, funTypeOut(fun)) 2101 2102 } 2103 } else { 2104 switch fun := fun.(type) { 2105 case func(*Env) int: 2106 2107 ret = func(env *Env) (Stmt, *Env) { 2108 lhs := lhsfun(env) 2109 key := keyfun(env) 2110 var result int 2111 2112 if v := lhs.MapIndex(key); v != Nil { 2113 result = int(v.Int()) 2114 } 2115 result *= fun(env) 2116 2117 lhs.SetMapIndex(key, r.ValueOf(result)) 2118 env.IP++ 2119 return env.Code[env.IP], env 2120 } 2121 case func(*Env) int8: 2122 2123 ret = func(env *Env) (Stmt, *Env) { 2124 lhs := lhsfun(env) 2125 key := keyfun(env) 2126 var result int8 2127 2128 if v := lhs.MapIndex(key); v != Nil { 2129 result = int8(v.Int()) 2130 } 2131 result *= fun(env) 2132 2133 lhs.SetMapIndex(key, r.ValueOf(result)) 2134 env.IP++ 2135 return env.Code[env.IP], env 2136 } 2137 case func(*Env) int16: 2138 2139 ret = func(env *Env) (Stmt, *Env) { 2140 lhs := lhsfun(env) 2141 key := keyfun(env) 2142 var result int16 2143 2144 if v := lhs.MapIndex(key); v != Nil { 2145 result = int16(v.Int()) 2146 } 2147 result *= fun(env) 2148 2149 lhs.SetMapIndex(key, r.ValueOf(result)) 2150 env.IP++ 2151 return env.Code[env.IP], env 2152 } 2153 case func(*Env) int32: 2154 2155 ret = func(env *Env) (Stmt, *Env) { 2156 lhs := lhsfun(env) 2157 key := keyfun(env) 2158 var result int32 2159 2160 if v := lhs.MapIndex(key); v != Nil { 2161 result = int32(v.Int()) 2162 } 2163 result *= fun(env) 2164 2165 lhs.SetMapIndex(key, r.ValueOf(result)) 2166 env.IP++ 2167 return env.Code[env.IP], env 2168 } 2169 case func(*Env) int64: 2170 2171 ret = func(env *Env) (Stmt, *Env) { 2172 lhs := lhsfun(env) 2173 key := keyfun(env) 2174 var result int64 2175 2176 if v := lhs.MapIndex(key); v != Nil { 2177 result = v.Int() 2178 } 2179 result *= fun(env) 2180 2181 lhs.SetMapIndex(key, r.ValueOf(result)) 2182 env.IP++ 2183 return env.Code[env.IP], env 2184 } 2185 case func(*Env) uint: 2186 2187 ret = func(env *Env) (Stmt, *Env) { 2188 lhs := lhsfun(env) 2189 key := keyfun(env) 2190 var result uint 2191 2192 if v := lhs.MapIndex(key); v != Nil { 2193 result = uint(v.Uint()) 2194 } 2195 result *= fun(env) 2196 2197 lhs.SetMapIndex(key, r.ValueOf(result)) 2198 env.IP++ 2199 return env.Code[env.IP], env 2200 } 2201 case func(*Env) uint8: 2202 2203 ret = func(env *Env) (Stmt, *Env) { 2204 lhs := lhsfun(env) 2205 key := keyfun(env) 2206 var result uint8 2207 2208 if v := lhs.MapIndex(key); v != Nil { 2209 result = uint8(v.Uint()) 2210 } 2211 result *= fun(env) 2212 2213 lhs.SetMapIndex(key, r.ValueOf(result)) 2214 env.IP++ 2215 return env.Code[env.IP], env 2216 } 2217 case func(*Env) uint16: 2218 2219 ret = func(env *Env) (Stmt, *Env) { 2220 lhs := lhsfun(env) 2221 key := keyfun(env) 2222 var result uint16 2223 2224 if v := lhs.MapIndex(key); v != Nil { 2225 result = uint16(v.Uint()) 2226 } 2227 result *= fun(env) 2228 2229 lhs.SetMapIndex(key, r.ValueOf(result)) 2230 env.IP++ 2231 return env.Code[env.IP], env 2232 } 2233 case func(*Env) uint32: 2234 2235 ret = func(env *Env) (Stmt, *Env) { 2236 lhs := lhsfun(env) 2237 key := keyfun(env) 2238 var result uint32 2239 2240 if v := lhs.MapIndex(key); v != Nil { 2241 result = uint32(v.Uint()) 2242 } 2243 result *= fun(env) 2244 2245 lhs.SetMapIndex(key, r.ValueOf(result)) 2246 env.IP++ 2247 return env.Code[env.IP], env 2248 } 2249 case func(*Env) uint64: 2250 2251 ret = func(env *Env) (Stmt, *Env) { 2252 lhs := lhsfun(env) 2253 key := keyfun(env) 2254 var result uint64 2255 2256 if v := lhs.MapIndex(key); v != Nil { 2257 result = v.Uint() 2258 } 2259 result *= fun(env) 2260 2261 lhs.SetMapIndex(key, r.ValueOf(result)) 2262 env.IP++ 2263 return env.Code[env.IP], env 2264 } 2265 case func(*Env) uintptr: 2266 2267 ret = func(env *Env) (Stmt, *Env) { 2268 lhs := lhsfun(env) 2269 key := keyfun(env) 2270 var result uintptr 2271 2272 if v := lhs.MapIndex(key); v != Nil { 2273 result = uintptr(v.Uint()) 2274 } 2275 result *= fun(env) 2276 2277 lhs.SetMapIndex(key, r.ValueOf(result)) 2278 env.IP++ 2279 return env.Code[env.IP], env 2280 } 2281 case func(*Env) float32: 2282 2283 ret = func(env *Env) (Stmt, *Env) { 2284 lhs := lhsfun(env) 2285 key := keyfun(env) 2286 var result float32 2287 2288 if v := lhs.MapIndex(key); v != Nil { 2289 result = float32(v.Float()) 2290 } 2291 result *= fun(env) 2292 2293 lhs.SetMapIndex(key, r.ValueOf(result)) 2294 env.IP++ 2295 return env.Code[env.IP], env 2296 } 2297 case func(*Env) float64: 2298 2299 ret = func(env *Env) (Stmt, *Env) { 2300 lhs := lhsfun(env) 2301 key := keyfun(env) 2302 var result float64 2303 2304 if v := lhs.MapIndex(key); v != Nil { 2305 result = v.Float() 2306 } 2307 result *= fun(env) 2308 2309 lhs.SetMapIndex(key, r.ValueOf(result)) 2310 env.IP++ 2311 return env.Code[env.IP], env 2312 } 2313 case func(*Env) complex64: 2314 2315 ret = func(env *Env) (Stmt, *Env) { 2316 lhs := lhsfun(env) 2317 key := keyfun(env) 2318 var result complex64 2319 2320 if v := lhs.MapIndex(key); v != Nil { 2321 result = complex64(v.Complex()) 2322 } 2323 result *= fun(env) 2324 2325 lhs.SetMapIndex(key, r.ValueOf(result)) 2326 env.IP++ 2327 return env.Code[env.IP], env 2328 } 2329 case func(*Env) complex128: 2330 2331 ret = func(env *Env) (Stmt, *Env) { 2332 lhs := lhsfun(env) 2333 key := keyfun(env) 2334 var result complex128 2335 2336 if v := lhs.MapIndex(key); v != Nil { 2337 result = v.Complex() 2338 } 2339 result *= fun(env) 2340 2341 lhs.SetMapIndex(key, r.ValueOf(result)) 2342 env.IP++ 2343 return env.Code[env.IP], env 2344 } 2345 default: 2346 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.MUL, place.Type, funTypeOut(fun)) 2347 2348 } 2349 } 2350 return ret 2351} 2352func (c *Comp) placeQuoConst(place *Place, val I) Stmt { 2353 if isLiteralNumber(val, 0) { 2354 c.Errorf("division by %v <%v>", val, r.TypeOf(val)) 2355 return nil 2356 } else if isLiteralNumber(val, 1) { 2357 return c.placeForSideEffects(place) 2358 } 2359 2360 if stmt := c.placeQuoPow2(place, val); stmt != nil { 2361 return stmt 2362 } 2363 2364 { 2365 var ret Stmt 2366 lhsfun := place.Fun 2367 keyfun := place.MapKey 2368 v := r.ValueOf(val) 2369 2370 if keyfun == nil { 2371 switch reflect.Category(place.Type.Kind()) { 2372 case r.Int: 2373 val := v.Int() 2374 2375 ret = func(env *Env) (Stmt, *Env) { 2376 lhs := lhsfun(env) 2377 lhs.SetInt(lhs.Int() / int64(val, 2378 ), 2379 ) 2380 2381 env.IP++ 2382 return env.Code[env.IP], env 2383 } 2384 case r.Uint: 2385 val := v.Uint() 2386 2387 ret = func(env *Env) (Stmt, *Env) { 2388 lhs := lhsfun(env) 2389 lhs.SetUint(lhs.Uint() / uint64(val, 2390 ), 2391 ) 2392 2393 env.IP++ 2394 return env.Code[env.IP], env 2395 } 2396 case r.Float64: 2397 val := v.Float() 2398 2399 ret = func(env *Env) (Stmt, *Env) { 2400 lhs := lhsfun(env) 2401 lhs.SetFloat(lhs.Float() / 2402 val, 2403 ) 2404 2405 env.IP++ 2406 return env.Code[env.IP], env 2407 } 2408 case r.Complex128: 2409 val := v.Complex() 2410 2411 ret = func(env *Env) (Stmt, *Env) { 2412 lhs := lhsfun(env) 2413 lhs.SetComplex(lhs.Complex() / 2414 val, 2415 ) 2416 2417 env.IP++ 2418 return env.Code[env.IP], env 2419 } 2420 default: 2421 c.Errorf(`invalid operator %s= on <%v>`, token.QUO, place.Type) 2422 2423 } 2424 } else { 2425 switch place.Type.Kind() { 2426 case r.Int: 2427 val := int(v.Int()) 2428 2429 ret = func(env *Env) (Stmt, *Env) { 2430 lhs := lhsfun(env) 2431 key := keyfun(env) 2432 var result int 2433 2434 if v := lhs.MapIndex(key); v != Nil { 2435 result = int(v.Int()) 2436 } 2437 result /= val 2438 2439 lhs.SetMapIndex(key, r.ValueOf(result)) 2440 env.IP++ 2441 return env.Code[env.IP], env 2442 } 2443 case r.Int8: 2444 val := int8(v.Int()) 2445 2446 ret = func(env *Env) (Stmt, *Env) { 2447 lhs := lhsfun(env) 2448 key := keyfun(env) 2449 var result int8 2450 2451 if v := lhs.MapIndex(key); v != Nil { 2452 result = int8(v.Int()) 2453 } 2454 result /= val 2455 2456 lhs.SetMapIndex(key, r.ValueOf(result)) 2457 env.IP++ 2458 return env.Code[env.IP], env 2459 } 2460 case r.Int16: 2461 val := int16(v.Int()) 2462 2463 ret = func(env *Env) (Stmt, *Env) { 2464 lhs := lhsfun(env) 2465 key := keyfun(env) 2466 var result int16 2467 2468 if v := lhs.MapIndex(key); v != Nil { 2469 result = int16(v.Int()) 2470 } 2471 result /= val 2472 2473 lhs.SetMapIndex(key, r.ValueOf(result)) 2474 env.IP++ 2475 return env.Code[env.IP], env 2476 } 2477 case r.Int32: 2478 val := int32(v.Int()) 2479 2480 ret = func(env *Env) (Stmt, *Env) { 2481 lhs := lhsfun(env) 2482 key := keyfun(env) 2483 var result int32 2484 2485 if v := lhs.MapIndex(key); v != Nil { 2486 result = int32(v.Int()) 2487 } 2488 result /= val 2489 2490 lhs.SetMapIndex(key, r.ValueOf(result)) 2491 env.IP++ 2492 return env.Code[env.IP], env 2493 } 2494 case r.Int64: 2495 val := int64(v.Int()) 2496 2497 ret = func(env *Env) (Stmt, *Env) { 2498 lhs := lhsfun(env) 2499 key := keyfun(env) 2500 var result int64 2501 2502 if v := lhs.MapIndex(key); v != Nil { 2503 result = v.Int() 2504 } 2505 result /= val 2506 2507 lhs.SetMapIndex(key, r.ValueOf(result)) 2508 env.IP++ 2509 return env.Code[env.IP], env 2510 } 2511 case r.Uint: 2512 val := uint(v.Uint()) 2513 2514 ret = func(env *Env) (Stmt, *Env) { 2515 lhs := lhsfun(env) 2516 key := keyfun(env) 2517 var result uint 2518 2519 if v := lhs.MapIndex(key); v != Nil { 2520 result = uint(v.Uint()) 2521 } 2522 result /= val 2523 2524 lhs.SetMapIndex(key, r.ValueOf(result)) 2525 env.IP++ 2526 return env.Code[env.IP], env 2527 } 2528 case r.Uint8: 2529 val := uint8(v.Uint()) 2530 2531 ret = func(env *Env) (Stmt, *Env) { 2532 lhs := lhsfun(env) 2533 key := keyfun(env) 2534 var result uint8 2535 2536 if v := lhs.MapIndex(key); v != Nil { 2537 result = uint8(v.Uint()) 2538 } 2539 result /= val 2540 2541 lhs.SetMapIndex(key, r.ValueOf(result)) 2542 env.IP++ 2543 return env.Code[env.IP], env 2544 } 2545 case r.Uint16: 2546 val := uint16(v.Uint()) 2547 2548 ret = func(env *Env) (Stmt, *Env) { 2549 lhs := lhsfun(env) 2550 key := keyfun(env) 2551 var result uint16 2552 2553 if v := lhs.MapIndex(key); v != Nil { 2554 result = uint16(v.Uint()) 2555 } 2556 result /= val 2557 2558 lhs.SetMapIndex(key, r.ValueOf(result)) 2559 env.IP++ 2560 return env.Code[env.IP], env 2561 } 2562 case r.Uint32: 2563 val := uint32(v.Uint()) 2564 2565 ret = func(env *Env) (Stmt, *Env) { 2566 lhs := lhsfun(env) 2567 key := keyfun(env) 2568 var result uint32 2569 2570 if v := lhs.MapIndex(key); v != Nil { 2571 result = uint32(v.Uint()) 2572 } 2573 result /= val 2574 2575 lhs.SetMapIndex(key, r.ValueOf(result)) 2576 env.IP++ 2577 return env.Code[env.IP], env 2578 } 2579 case r.Uint64: 2580 val := uint64(v.Uint()) 2581 2582 ret = func(env *Env) (Stmt, *Env) { 2583 lhs := lhsfun(env) 2584 key := keyfun(env) 2585 var result uint64 2586 2587 if v := lhs.MapIndex(key); v != Nil { 2588 result = v.Uint() 2589 } 2590 result /= val 2591 2592 lhs.SetMapIndex(key, r.ValueOf(result)) 2593 env.IP++ 2594 return env.Code[env.IP], env 2595 } 2596 case r.Uintptr: 2597 val := uintptr(v.Uint()) 2598 2599 ret = func(env *Env) (Stmt, *Env) { 2600 lhs := lhsfun(env) 2601 key := keyfun(env) 2602 var result uintptr 2603 2604 if v := lhs.MapIndex(key); v != Nil { 2605 result = uintptr(v.Uint()) 2606 } 2607 result /= val 2608 2609 lhs.SetMapIndex(key, r.ValueOf(result)) 2610 env.IP++ 2611 return env.Code[env.IP], env 2612 } 2613 case r.Float32: 2614 val := float32(v.Float()) 2615 2616 ret = func(env *Env) (Stmt, *Env) { 2617 lhs := lhsfun(env) 2618 key := keyfun(env) 2619 var result float32 2620 2621 if v := lhs.MapIndex(key); v != Nil { 2622 result = float32(v.Float()) 2623 } 2624 result /= val 2625 2626 lhs.SetMapIndex(key, r.ValueOf(result)) 2627 env.IP++ 2628 return env.Code[env.IP], env 2629 } 2630 case r.Float64: 2631 val := float64(v.Float()) 2632 2633 ret = func(env *Env) (Stmt, *Env) { 2634 lhs := lhsfun(env) 2635 key := keyfun(env) 2636 var result float64 2637 2638 if v := lhs.MapIndex(key); v != Nil { 2639 result = v.Float() 2640 } 2641 result /= val 2642 2643 lhs.SetMapIndex(key, r.ValueOf(result)) 2644 env.IP++ 2645 return env.Code[env.IP], env 2646 } 2647 case r.Complex64: 2648 val := complex64(v.Complex()) 2649 2650 ret = func(env *Env) (Stmt, *Env) { 2651 lhs := lhsfun(env) 2652 key := keyfun(env) 2653 var result complex64 2654 2655 if v := lhs.MapIndex(key); v != Nil { 2656 result = complex64(v.Complex()) 2657 } 2658 result /= val 2659 2660 lhs.SetMapIndex(key, r.ValueOf(result)) 2661 env.IP++ 2662 return env.Code[env.IP], env 2663 } 2664 case r.Complex128: 2665 val := complex128(v.Complex()) 2666 2667 ret = func(env *Env) (Stmt, *Env) { 2668 lhs := lhsfun(env) 2669 key := keyfun(env) 2670 var result complex128 2671 2672 if v := lhs.MapIndex(key); v != Nil { 2673 result = v.Complex() 2674 } 2675 result /= val 2676 2677 lhs.SetMapIndex(key, r.ValueOf(result)) 2678 env.IP++ 2679 return env.Code[env.IP], env 2680 } 2681 default: 2682 c.Errorf(`invalid operator %s= on <%v>`, token.QUO, place.Type) 2683 2684 } 2685 } 2686 return ret 2687 } 2688} 2689func (c *Comp) placeQuoExpr(place *Place, fun I) Stmt { 2690 var ret Stmt 2691 lhsfun := place.Fun 2692 keyfun := place.MapKey 2693 if keyfun == nil { 2694 switch fun := fun.(type) { 2695 case func(*Env) int: 2696 2697 ret = func(env *Env) (Stmt, *Env) { 2698 lhs := lhsfun(env) 2699 lhs.SetInt(lhs.Int() / int64(fun(env), 2700 ), 2701 ) 2702 2703 env.IP++ 2704 return env.Code[env.IP], env 2705 } 2706 case func(*Env) int8: 2707 2708 ret = func(env *Env) (Stmt, *Env) { 2709 lhs := lhsfun(env) 2710 lhs.SetInt(lhs.Int() / int64(fun(env), 2711 ), 2712 ) 2713 2714 env.IP++ 2715 return env.Code[env.IP], env 2716 } 2717 case func(*Env) int16: 2718 2719 ret = func(env *Env) (Stmt, *Env) { 2720 lhs := lhsfun(env) 2721 lhs.SetInt(lhs.Int() / int64(fun(env), 2722 ), 2723 ) 2724 2725 env.IP++ 2726 return env.Code[env.IP], env 2727 } 2728 case func(*Env) int32: 2729 2730 ret = func(env *Env) (Stmt, *Env) { 2731 lhs := lhsfun(env) 2732 lhs.SetInt(lhs.Int() / int64(fun(env), 2733 ), 2734 ) 2735 2736 env.IP++ 2737 return env.Code[env.IP], env 2738 } 2739 case func(*Env) int64: 2740 2741 ret = func(env *Env) (Stmt, *Env) { 2742 lhs := lhsfun(env) 2743 lhs.SetInt(lhs.Int() / 2744 fun(env), 2745 ) 2746 2747 env.IP++ 2748 return env.Code[env.IP], env 2749 } 2750 case func(*Env) uint: 2751 2752 ret = func(env *Env) (Stmt, *Env) { 2753 lhs := lhsfun(env) 2754 lhs.SetUint(lhs.Uint() / uint64(fun(env), 2755 ), 2756 ) 2757 2758 env.IP++ 2759 return env.Code[env.IP], env 2760 } 2761 case func(*Env) uint8: 2762 2763 ret = func(env *Env) (Stmt, *Env) { 2764 lhs := lhsfun(env) 2765 lhs.SetUint(lhs.Uint() / uint64(fun(env), 2766 ), 2767 ) 2768 2769 env.IP++ 2770 return env.Code[env.IP], env 2771 } 2772 case func(*Env) uint16: 2773 2774 ret = func(env *Env) (Stmt, *Env) { 2775 lhs := lhsfun(env) 2776 lhs.SetUint(lhs.Uint() / uint64(fun(env), 2777 ), 2778 ) 2779 2780 env.IP++ 2781 return env.Code[env.IP], env 2782 } 2783 case func(*Env) uint32: 2784 2785 ret = func(env *Env) (Stmt, *Env) { 2786 lhs := lhsfun(env) 2787 lhs.SetUint(lhs.Uint() / uint64(fun(env), 2788 ), 2789 ) 2790 2791 env.IP++ 2792 return env.Code[env.IP], env 2793 } 2794 case func(*Env) uint64: 2795 2796 ret = func(env *Env) (Stmt, *Env) { 2797 lhs := lhsfun(env) 2798 lhs.SetUint(lhs.Uint() / 2799 fun(env), 2800 ) 2801 2802 env.IP++ 2803 return env.Code[env.IP], env 2804 } 2805 case func(*Env) uintptr: 2806 2807 ret = func(env *Env) (Stmt, *Env) { 2808 lhs := lhsfun(env) 2809 lhs.SetUint(lhs.Uint() / uint64(fun(env), 2810 ), 2811 ) 2812 2813 env.IP++ 2814 return env.Code[env.IP], env 2815 } 2816 case func(*Env) float32: 2817 2818 ret = func(env *Env) (Stmt, *Env) { 2819 lhs := lhsfun(env) 2820 lhs.SetFloat(lhs.Float() / float64(fun(env), 2821 ), 2822 ) 2823 2824 env.IP++ 2825 return env.Code[env.IP], env 2826 } 2827 case func(*Env) float64: 2828 2829 ret = func(env *Env) (Stmt, *Env) { 2830 lhs := lhsfun(env) 2831 lhs.SetFloat(lhs.Float() / 2832 fun(env), 2833 ) 2834 2835 env.IP++ 2836 return env.Code[env.IP], env 2837 } 2838 case func(*Env) complex64: 2839 2840 ret = func(env *Env) (Stmt, *Env) { 2841 lhs := lhsfun(env) 2842 lhs.SetComplex(lhs.Complex() / complex128(fun(env), 2843 ), 2844 ) 2845 2846 env.IP++ 2847 return env.Code[env.IP], env 2848 } 2849 case func(*Env) complex128: 2850 2851 ret = func(env *Env) (Stmt, *Env) { 2852 lhs := lhsfun(env) 2853 lhs.SetComplex(lhs.Complex() / 2854 fun(env), 2855 ) 2856 2857 env.IP++ 2858 return env.Code[env.IP], env 2859 } 2860 default: 2861 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.QUO, place.Type, funTypeOut(fun)) 2862 2863 } 2864 } else { 2865 switch fun := fun.(type) { 2866 case func(*Env) int: 2867 2868 ret = func(env *Env) (Stmt, *Env) { 2869 lhs := lhsfun(env) 2870 key := keyfun(env) 2871 var result int 2872 2873 if v := lhs.MapIndex(key); v != Nil { 2874 result = int(v.Int()) 2875 } 2876 result /= fun(env) 2877 2878 lhs.SetMapIndex(key, r.ValueOf(result)) 2879 env.IP++ 2880 return env.Code[env.IP], env 2881 } 2882 case func(*Env) int8: 2883 2884 ret = func(env *Env) (Stmt, *Env) { 2885 lhs := lhsfun(env) 2886 key := keyfun(env) 2887 var result int8 2888 2889 if v := lhs.MapIndex(key); v != Nil { 2890 result = int8(v.Int()) 2891 } 2892 result /= fun(env) 2893 2894 lhs.SetMapIndex(key, r.ValueOf(result)) 2895 env.IP++ 2896 return env.Code[env.IP], env 2897 } 2898 case func(*Env) int16: 2899 2900 ret = func(env *Env) (Stmt, *Env) { 2901 lhs := lhsfun(env) 2902 key := keyfun(env) 2903 var result int16 2904 2905 if v := lhs.MapIndex(key); v != Nil { 2906 result = int16(v.Int()) 2907 } 2908 result /= fun(env) 2909 2910 lhs.SetMapIndex(key, r.ValueOf(result)) 2911 env.IP++ 2912 return env.Code[env.IP], env 2913 } 2914 case func(*Env) int32: 2915 2916 ret = func(env *Env) (Stmt, *Env) { 2917 lhs := lhsfun(env) 2918 key := keyfun(env) 2919 var result int32 2920 2921 if v := lhs.MapIndex(key); v != Nil { 2922 result = int32(v.Int()) 2923 } 2924 result /= fun(env) 2925 2926 lhs.SetMapIndex(key, r.ValueOf(result)) 2927 env.IP++ 2928 return env.Code[env.IP], env 2929 } 2930 case func(*Env) int64: 2931 2932 ret = func(env *Env) (Stmt, *Env) { 2933 lhs := lhsfun(env) 2934 key := keyfun(env) 2935 var result int64 2936 2937 if v := lhs.MapIndex(key); v != Nil { 2938 result = v.Int() 2939 } 2940 result /= fun(env) 2941 2942 lhs.SetMapIndex(key, r.ValueOf(result)) 2943 env.IP++ 2944 return env.Code[env.IP], env 2945 } 2946 case func(*Env) uint: 2947 2948 ret = func(env *Env) (Stmt, *Env) { 2949 lhs := lhsfun(env) 2950 key := keyfun(env) 2951 var result uint 2952 2953 if v := lhs.MapIndex(key); v != Nil { 2954 result = uint(v.Uint()) 2955 } 2956 result /= fun(env) 2957 2958 lhs.SetMapIndex(key, r.ValueOf(result)) 2959 env.IP++ 2960 return env.Code[env.IP], env 2961 } 2962 case func(*Env) uint8: 2963 2964 ret = func(env *Env) (Stmt, *Env) { 2965 lhs := lhsfun(env) 2966 key := keyfun(env) 2967 var result uint8 2968 2969 if v := lhs.MapIndex(key); v != Nil { 2970 result = uint8(v.Uint()) 2971 } 2972 result /= fun(env) 2973 2974 lhs.SetMapIndex(key, r.ValueOf(result)) 2975 env.IP++ 2976 return env.Code[env.IP], env 2977 } 2978 case func(*Env) uint16: 2979 2980 ret = func(env *Env) (Stmt, *Env) { 2981 lhs := lhsfun(env) 2982 key := keyfun(env) 2983 var result uint16 2984 2985 if v := lhs.MapIndex(key); v != Nil { 2986 result = uint16(v.Uint()) 2987 } 2988 result /= fun(env) 2989 2990 lhs.SetMapIndex(key, r.ValueOf(result)) 2991 env.IP++ 2992 return env.Code[env.IP], env 2993 } 2994 case func(*Env) uint32: 2995 2996 ret = func(env *Env) (Stmt, *Env) { 2997 lhs := lhsfun(env) 2998 key := keyfun(env) 2999 var result uint32 3000 3001 if v := lhs.MapIndex(key); v != Nil { 3002 result = uint32(v.Uint()) 3003 } 3004 result /= fun(env) 3005 3006 lhs.SetMapIndex(key, r.ValueOf(result)) 3007 env.IP++ 3008 return env.Code[env.IP], env 3009 } 3010 case func(*Env) uint64: 3011 3012 ret = func(env *Env) (Stmt, *Env) { 3013 lhs := lhsfun(env) 3014 key := keyfun(env) 3015 var result uint64 3016 3017 if v := lhs.MapIndex(key); v != Nil { 3018 result = v.Uint() 3019 } 3020 result /= fun(env) 3021 3022 lhs.SetMapIndex(key, r.ValueOf(result)) 3023 env.IP++ 3024 return env.Code[env.IP], env 3025 } 3026 case func(*Env) uintptr: 3027 3028 ret = func(env *Env) (Stmt, *Env) { 3029 lhs := lhsfun(env) 3030 key := keyfun(env) 3031 var result uintptr 3032 3033 if v := lhs.MapIndex(key); v != Nil { 3034 result = uintptr(v.Uint()) 3035 } 3036 result /= fun(env) 3037 3038 lhs.SetMapIndex(key, r.ValueOf(result)) 3039 env.IP++ 3040 return env.Code[env.IP], env 3041 } 3042 case func(*Env) float32: 3043 3044 ret = func(env *Env) (Stmt, *Env) { 3045 lhs := lhsfun(env) 3046 key := keyfun(env) 3047 var result float32 3048 3049 if v := lhs.MapIndex(key); v != Nil { 3050 result = float32(v.Float()) 3051 } 3052 result /= fun(env) 3053 3054 lhs.SetMapIndex(key, r.ValueOf(result)) 3055 env.IP++ 3056 return env.Code[env.IP], env 3057 } 3058 case func(*Env) float64: 3059 3060 ret = func(env *Env) (Stmt, *Env) { 3061 lhs := lhsfun(env) 3062 key := keyfun(env) 3063 var result float64 3064 3065 if v := lhs.MapIndex(key); v != Nil { 3066 result = v.Float() 3067 } 3068 result /= fun(env) 3069 3070 lhs.SetMapIndex(key, r.ValueOf(result)) 3071 env.IP++ 3072 return env.Code[env.IP], env 3073 } 3074 case func(*Env) complex64: 3075 3076 ret = func(env *Env) (Stmt, *Env) { 3077 lhs := lhsfun(env) 3078 key := keyfun(env) 3079 var result complex64 3080 3081 if v := lhs.MapIndex(key); v != Nil { 3082 result = complex64(v.Complex()) 3083 } 3084 result /= fun(env) 3085 3086 lhs.SetMapIndex(key, r.ValueOf(result)) 3087 env.IP++ 3088 return env.Code[env.IP], env 3089 } 3090 case func(*Env) complex128: 3091 3092 ret = func(env *Env) (Stmt, *Env) { 3093 lhs := lhsfun(env) 3094 key := keyfun(env) 3095 var result complex128 3096 3097 if v := lhs.MapIndex(key); v != Nil { 3098 result = v.Complex() 3099 } 3100 result /= fun(env) 3101 3102 lhs.SetMapIndex(key, r.ValueOf(result)) 3103 env.IP++ 3104 return env.Code[env.IP], env 3105 } 3106 default: 3107 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.QUO, place.Type, funTypeOut(fun)) 3108 3109 } 3110 } 3111 return ret 3112} 3113func (c *Comp) placeRemConst(place *Place, val I) Stmt { 3114 if reflect.IsCategory(place.Type.Kind(), r.Int, r.Uint) { 3115 if isLiteralNumber(val, 0) { 3116 c.Errorf("division by %v <%v>", val, place.Type) 3117 return nil 3118 } else if isLiteralNumber(val, 1) { 3119 return c.placeSetZero(place) 3120 } 3121 } 3122 3123 { 3124 var ret Stmt 3125 lhsfun := place.Fun 3126 keyfun := place.MapKey 3127 v := r.ValueOf(val) 3128 3129 if keyfun == nil { 3130 switch reflect.Category(place.Type.Kind()) { 3131 case r.Int: 3132 val := v.Int() 3133 3134 ret = func(env *Env) (Stmt, *Env) { 3135 lhs := lhsfun(env) 3136 lhs.SetInt(lhs.Int() % int64(val, 3137 ), 3138 ) 3139 3140 env.IP++ 3141 return env.Code[env.IP], env 3142 } 3143 case r.Uint: 3144 val := v.Uint() 3145 3146 ret = func(env *Env) (Stmt, *Env) { 3147 lhs := lhsfun(env) 3148 lhs.SetUint(lhs.Uint() % uint64(val, 3149 ), 3150 ) 3151 3152 env.IP++ 3153 return env.Code[env.IP], env 3154 } 3155 default: 3156 c.Errorf(`invalid operator %s= on <%v>`, token.REM, place.Type) 3157 3158 } 3159 } else { 3160 switch place.Type.Kind() { 3161 case r.Int: 3162 val := int(v.Int()) 3163 3164 ret = func(env *Env) (Stmt, *Env) { 3165 lhs := lhsfun(env) 3166 key := keyfun(env) 3167 var result int 3168 3169 if v := lhs.MapIndex(key); v != Nil { 3170 result = int(v.Int()) 3171 } 3172 result %= val 3173 3174 lhs.SetMapIndex(key, r.ValueOf(result)) 3175 env.IP++ 3176 return env.Code[env.IP], env 3177 } 3178 case r.Int8: 3179 val := int8(v.Int()) 3180 3181 ret = func(env *Env) (Stmt, *Env) { 3182 lhs := lhsfun(env) 3183 key := keyfun(env) 3184 var result int8 3185 3186 if v := lhs.MapIndex(key); v != Nil { 3187 result = int8(v.Int()) 3188 } 3189 result %= val 3190 3191 lhs.SetMapIndex(key, r.ValueOf(result)) 3192 env.IP++ 3193 return env.Code[env.IP], env 3194 } 3195 case r.Int16: 3196 val := int16(v.Int()) 3197 3198 ret = func(env *Env) (Stmt, *Env) { 3199 lhs := lhsfun(env) 3200 key := keyfun(env) 3201 var result int16 3202 3203 if v := lhs.MapIndex(key); v != Nil { 3204 result = int16(v.Int()) 3205 } 3206 result %= val 3207 3208 lhs.SetMapIndex(key, r.ValueOf(result)) 3209 env.IP++ 3210 return env.Code[env.IP], env 3211 } 3212 case r.Int32: 3213 val := int32(v.Int()) 3214 3215 ret = func(env *Env) (Stmt, *Env) { 3216 lhs := lhsfun(env) 3217 key := keyfun(env) 3218 var result int32 3219 3220 if v := lhs.MapIndex(key); v != Nil { 3221 result = int32(v.Int()) 3222 } 3223 result %= val 3224 3225 lhs.SetMapIndex(key, r.ValueOf(result)) 3226 env.IP++ 3227 return env.Code[env.IP], env 3228 } 3229 case r.Int64: 3230 val := int64(v.Int()) 3231 3232 ret = func(env *Env) (Stmt, *Env) { 3233 lhs := lhsfun(env) 3234 key := keyfun(env) 3235 var result int64 3236 3237 if v := lhs.MapIndex(key); v != Nil { 3238 result = v.Int() 3239 } 3240 result %= val 3241 3242 lhs.SetMapIndex(key, r.ValueOf(result)) 3243 env.IP++ 3244 return env.Code[env.IP], env 3245 } 3246 case r.Uint: 3247 val := uint(v.Uint()) 3248 3249 ret = func(env *Env) (Stmt, *Env) { 3250 lhs := lhsfun(env) 3251 key := keyfun(env) 3252 var result uint 3253 3254 if v := lhs.MapIndex(key); v != Nil { 3255 result = uint(v.Uint()) 3256 } 3257 result %= val 3258 3259 lhs.SetMapIndex(key, r.ValueOf(result)) 3260 env.IP++ 3261 return env.Code[env.IP], env 3262 } 3263 case r.Uint8: 3264 val := uint8(v.Uint()) 3265 3266 ret = func(env *Env) (Stmt, *Env) { 3267 lhs := lhsfun(env) 3268 key := keyfun(env) 3269 var result uint8 3270 3271 if v := lhs.MapIndex(key); v != Nil { 3272 result = uint8(v.Uint()) 3273 } 3274 result %= val 3275 3276 lhs.SetMapIndex(key, r.ValueOf(result)) 3277 env.IP++ 3278 return env.Code[env.IP], env 3279 } 3280 case r.Uint16: 3281 val := uint16(v.Uint()) 3282 3283 ret = func(env *Env) (Stmt, *Env) { 3284 lhs := lhsfun(env) 3285 key := keyfun(env) 3286 var result uint16 3287 3288 if v := lhs.MapIndex(key); v != Nil { 3289 result = uint16(v.Uint()) 3290 } 3291 result %= val 3292 3293 lhs.SetMapIndex(key, r.ValueOf(result)) 3294 env.IP++ 3295 return env.Code[env.IP], env 3296 } 3297 case r.Uint32: 3298 val := uint32(v.Uint()) 3299 3300 ret = func(env *Env) (Stmt, *Env) { 3301 lhs := lhsfun(env) 3302 key := keyfun(env) 3303 var result uint32 3304 3305 if v := lhs.MapIndex(key); v != Nil { 3306 result = uint32(v.Uint()) 3307 } 3308 result %= val 3309 3310 lhs.SetMapIndex(key, r.ValueOf(result)) 3311 env.IP++ 3312 return env.Code[env.IP], env 3313 } 3314 case r.Uint64: 3315 val := uint64(v.Uint()) 3316 3317 ret = func(env *Env) (Stmt, *Env) { 3318 lhs := lhsfun(env) 3319 key := keyfun(env) 3320 var result uint64 3321 3322 if v := lhs.MapIndex(key); v != Nil { 3323 result = v.Uint() 3324 } 3325 result %= val 3326 3327 lhs.SetMapIndex(key, r.ValueOf(result)) 3328 env.IP++ 3329 return env.Code[env.IP], env 3330 } 3331 case r.Uintptr: 3332 val := uintptr(v.Uint()) 3333 3334 ret = func(env *Env) (Stmt, *Env) { 3335 lhs := lhsfun(env) 3336 key := keyfun(env) 3337 var result uintptr 3338 3339 if v := lhs.MapIndex(key); v != Nil { 3340 result = uintptr(v.Uint()) 3341 } 3342 result %= val 3343 3344 lhs.SetMapIndex(key, r.ValueOf(result)) 3345 env.IP++ 3346 return env.Code[env.IP], env 3347 } 3348 default: 3349 c.Errorf(`invalid operator %s= on <%v>`, token.REM, place.Type) 3350 3351 } 3352 } 3353 return ret 3354 } 3355} 3356func (c *Comp) placeRemExpr(place *Place, fun I) Stmt { 3357 var ret Stmt 3358 lhsfun := place.Fun 3359 keyfun := place.MapKey 3360 if keyfun == nil { 3361 switch fun := fun.(type) { 3362 case func(*Env) int: 3363 3364 ret = func(env *Env) (Stmt, *Env) { 3365 lhs := lhsfun(env) 3366 lhs.SetInt(lhs.Int() % int64(fun(env), 3367 ), 3368 ) 3369 3370 env.IP++ 3371 return env.Code[env.IP], env 3372 } 3373 case func(*Env) int8: 3374 3375 ret = func(env *Env) (Stmt, *Env) { 3376 lhs := lhsfun(env) 3377 lhs.SetInt(lhs.Int() % int64(fun(env), 3378 ), 3379 ) 3380 3381 env.IP++ 3382 return env.Code[env.IP], env 3383 } 3384 case func(*Env) int16: 3385 3386 ret = func(env *Env) (Stmt, *Env) { 3387 lhs := lhsfun(env) 3388 lhs.SetInt(lhs.Int() % int64(fun(env), 3389 ), 3390 ) 3391 3392 env.IP++ 3393 return env.Code[env.IP], env 3394 } 3395 case func(*Env) int32: 3396 3397 ret = func(env *Env) (Stmt, *Env) { 3398 lhs := lhsfun(env) 3399 lhs.SetInt(lhs.Int() % int64(fun(env), 3400 ), 3401 ) 3402 3403 env.IP++ 3404 return env.Code[env.IP], env 3405 } 3406 case func(*Env) int64: 3407 3408 ret = func(env *Env) (Stmt, *Env) { 3409 lhs := lhsfun(env) 3410 lhs.SetInt(lhs.Int() % 3411 fun(env), 3412 ) 3413 3414 env.IP++ 3415 return env.Code[env.IP], env 3416 } 3417 case func(*Env) uint: 3418 3419 ret = func(env *Env) (Stmt, *Env) { 3420 lhs := lhsfun(env) 3421 lhs.SetUint(lhs.Uint() % uint64(fun(env), 3422 ), 3423 ) 3424 3425 env.IP++ 3426 return env.Code[env.IP], env 3427 } 3428 case func(*Env) uint8: 3429 3430 ret = func(env *Env) (Stmt, *Env) { 3431 lhs := lhsfun(env) 3432 lhs.SetUint(lhs.Uint() % uint64(fun(env), 3433 ), 3434 ) 3435 3436 env.IP++ 3437 return env.Code[env.IP], env 3438 } 3439 case func(*Env) uint16: 3440 3441 ret = func(env *Env) (Stmt, *Env) { 3442 lhs := lhsfun(env) 3443 lhs.SetUint(lhs.Uint() % uint64(fun(env), 3444 ), 3445 ) 3446 3447 env.IP++ 3448 return env.Code[env.IP], env 3449 } 3450 case func(*Env) uint32: 3451 3452 ret = func(env *Env) (Stmt, *Env) { 3453 lhs := lhsfun(env) 3454 lhs.SetUint(lhs.Uint() % uint64(fun(env), 3455 ), 3456 ) 3457 3458 env.IP++ 3459 return env.Code[env.IP], env 3460 } 3461 case func(*Env) uint64: 3462 3463 ret = func(env *Env) (Stmt, *Env) { 3464 lhs := lhsfun(env) 3465 lhs.SetUint(lhs.Uint() % 3466 fun(env), 3467 ) 3468 3469 env.IP++ 3470 return env.Code[env.IP], env 3471 } 3472 case func(*Env) uintptr: 3473 3474 ret = func(env *Env) (Stmt, *Env) { 3475 lhs := lhsfun(env) 3476 lhs.SetUint(lhs.Uint() % uint64(fun(env), 3477 ), 3478 ) 3479 3480 env.IP++ 3481 return env.Code[env.IP], env 3482 } 3483 default: 3484 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.REM, place.Type, funTypeOut(fun)) 3485 3486 } 3487 } else { 3488 switch fun := fun.(type) { 3489 case func(*Env) int: 3490 3491 ret = func(env *Env) (Stmt, *Env) { 3492 lhs := lhsfun(env) 3493 key := keyfun(env) 3494 var result int 3495 3496 if v := lhs.MapIndex(key); v != Nil { 3497 result = int(v.Int()) 3498 } 3499 result %= fun(env) 3500 3501 lhs.SetMapIndex(key, r.ValueOf(result)) 3502 env.IP++ 3503 return env.Code[env.IP], env 3504 } 3505 case func(*Env) int8: 3506 3507 ret = func(env *Env) (Stmt, *Env) { 3508 lhs := lhsfun(env) 3509 key := keyfun(env) 3510 var result int8 3511 3512 if v := lhs.MapIndex(key); v != Nil { 3513 result = int8(v.Int()) 3514 } 3515 result %= fun(env) 3516 3517 lhs.SetMapIndex(key, r.ValueOf(result)) 3518 env.IP++ 3519 return env.Code[env.IP], env 3520 } 3521 case func(*Env) int16: 3522 3523 ret = func(env *Env) (Stmt, *Env) { 3524 lhs := lhsfun(env) 3525 key := keyfun(env) 3526 var result int16 3527 3528 if v := lhs.MapIndex(key); v != Nil { 3529 result = int16(v.Int()) 3530 } 3531 result %= fun(env) 3532 3533 lhs.SetMapIndex(key, r.ValueOf(result)) 3534 env.IP++ 3535 return env.Code[env.IP], env 3536 } 3537 case func(*Env) int32: 3538 3539 ret = func(env *Env) (Stmt, *Env) { 3540 lhs := lhsfun(env) 3541 key := keyfun(env) 3542 var result int32 3543 3544 if v := lhs.MapIndex(key); v != Nil { 3545 result = int32(v.Int()) 3546 } 3547 result %= fun(env) 3548 3549 lhs.SetMapIndex(key, r.ValueOf(result)) 3550 env.IP++ 3551 return env.Code[env.IP], env 3552 } 3553 case func(*Env) int64: 3554 3555 ret = func(env *Env) (Stmt, *Env) { 3556 lhs := lhsfun(env) 3557 key := keyfun(env) 3558 var result int64 3559 3560 if v := lhs.MapIndex(key); v != Nil { 3561 result = v.Int() 3562 } 3563 result %= fun(env) 3564 3565 lhs.SetMapIndex(key, r.ValueOf(result)) 3566 env.IP++ 3567 return env.Code[env.IP], env 3568 } 3569 case func(*Env) uint: 3570 3571 ret = func(env *Env) (Stmt, *Env) { 3572 lhs := lhsfun(env) 3573 key := keyfun(env) 3574 var result uint 3575 3576 if v := lhs.MapIndex(key); v != Nil { 3577 result = uint(v.Uint()) 3578 } 3579 result %= fun(env) 3580 3581 lhs.SetMapIndex(key, r.ValueOf(result)) 3582 env.IP++ 3583 return env.Code[env.IP], env 3584 } 3585 case func(*Env) uint8: 3586 3587 ret = func(env *Env) (Stmt, *Env) { 3588 lhs := lhsfun(env) 3589 key := keyfun(env) 3590 var result uint8 3591 3592 if v := lhs.MapIndex(key); v != Nil { 3593 result = uint8(v.Uint()) 3594 } 3595 result %= fun(env) 3596 3597 lhs.SetMapIndex(key, r.ValueOf(result)) 3598 env.IP++ 3599 return env.Code[env.IP], env 3600 } 3601 case func(*Env) uint16: 3602 3603 ret = func(env *Env) (Stmt, *Env) { 3604 lhs := lhsfun(env) 3605 key := keyfun(env) 3606 var result uint16 3607 3608 if v := lhs.MapIndex(key); v != Nil { 3609 result = uint16(v.Uint()) 3610 } 3611 result %= fun(env) 3612 3613 lhs.SetMapIndex(key, r.ValueOf(result)) 3614 env.IP++ 3615 return env.Code[env.IP], env 3616 } 3617 case func(*Env) uint32: 3618 3619 ret = func(env *Env) (Stmt, *Env) { 3620 lhs := lhsfun(env) 3621 key := keyfun(env) 3622 var result uint32 3623 3624 if v := lhs.MapIndex(key); v != Nil { 3625 result = uint32(v.Uint()) 3626 } 3627 result %= fun(env) 3628 3629 lhs.SetMapIndex(key, r.ValueOf(result)) 3630 env.IP++ 3631 return env.Code[env.IP], env 3632 } 3633 case func(*Env) uint64: 3634 3635 ret = func(env *Env) (Stmt, *Env) { 3636 lhs := lhsfun(env) 3637 key := keyfun(env) 3638 var result uint64 3639 3640 if v := lhs.MapIndex(key); v != Nil { 3641 result = v.Uint() 3642 } 3643 result %= fun(env) 3644 3645 lhs.SetMapIndex(key, r.ValueOf(result)) 3646 env.IP++ 3647 return env.Code[env.IP], env 3648 } 3649 case func(*Env) uintptr: 3650 3651 ret = func(env *Env) (Stmt, *Env) { 3652 lhs := lhsfun(env) 3653 key := keyfun(env) 3654 var result uintptr 3655 3656 if v := lhs.MapIndex(key); v != Nil { 3657 result = uintptr(v.Uint()) 3658 } 3659 result %= fun(env) 3660 3661 lhs.SetMapIndex(key, r.ValueOf(result)) 3662 env.IP++ 3663 return env.Code[env.IP], env 3664 } 3665 default: 3666 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.REM, place.Type, funTypeOut(fun)) 3667 3668 } 3669 } 3670 return ret 3671} 3672func (c *Comp) placeAndConst(place *Place, val I) Stmt { 3673 if reflect.IsCategory(place.Type.Kind(), r.Int, r.Uint) { 3674 if isLiteralNumber(val, -1) { 3675 return c.placeForSideEffects(place) 3676 } else if isLiteralNumber(val, 0) { 3677 return c.placeSetZero(place) 3678 } 3679 } 3680 3681 { 3682 var ret Stmt 3683 lhsfun := place.Fun 3684 keyfun := place.MapKey 3685 v := r.ValueOf(val) 3686 3687 if keyfun == nil { 3688 switch reflect.Category(place.Type.Kind()) { 3689 case r.Int: 3690 val := v.Int() 3691 3692 ret = func(env *Env) (Stmt, *Env) { 3693 lhs := lhsfun(env) 3694 lhs.SetInt(lhs.Int() & int64(val, 3695 ), 3696 ) 3697 3698 env.IP++ 3699 return env.Code[env.IP], env 3700 } 3701 case r.Uint: 3702 val := v.Uint() 3703 3704 ret = func(env *Env) (Stmt, *Env) { 3705 lhs := lhsfun(env) 3706 lhs.SetUint(lhs.Uint() & uint64(val, 3707 ), 3708 ) 3709 3710 env.IP++ 3711 return env.Code[env.IP], env 3712 } 3713 default: 3714 c.Errorf(`invalid operator %s= on <%v>`, token.AND, place.Type) 3715 3716 } 3717 } else { 3718 switch place.Type.Kind() { 3719 case r.Int: 3720 val := int(v.Int()) 3721 3722 ret = func(env *Env) (Stmt, *Env) { 3723 lhs := lhsfun(env) 3724 key := keyfun(env) 3725 var result int 3726 3727 if v := lhs.MapIndex(key); v != Nil { 3728 result = int(v.Int()) 3729 } 3730 result &= val 3731 3732 lhs.SetMapIndex(key, r.ValueOf(result)) 3733 env.IP++ 3734 return env.Code[env.IP], env 3735 } 3736 case r.Int8: 3737 val := int8(v.Int()) 3738 3739 ret = func(env *Env) (Stmt, *Env) { 3740 lhs := lhsfun(env) 3741 key := keyfun(env) 3742 var result int8 3743 3744 if v := lhs.MapIndex(key); v != Nil { 3745 result = int8(v.Int()) 3746 } 3747 result &= val 3748 3749 lhs.SetMapIndex(key, r.ValueOf(result)) 3750 env.IP++ 3751 return env.Code[env.IP], env 3752 } 3753 case r.Int16: 3754 val := int16(v.Int()) 3755 3756 ret = func(env *Env) (Stmt, *Env) { 3757 lhs := lhsfun(env) 3758 key := keyfun(env) 3759 var result int16 3760 3761 if v := lhs.MapIndex(key); v != Nil { 3762 result = int16(v.Int()) 3763 } 3764 result &= val 3765 3766 lhs.SetMapIndex(key, r.ValueOf(result)) 3767 env.IP++ 3768 return env.Code[env.IP], env 3769 } 3770 case r.Int32: 3771 val := int32(v.Int()) 3772 3773 ret = func(env *Env) (Stmt, *Env) { 3774 lhs := lhsfun(env) 3775 key := keyfun(env) 3776 var result int32 3777 3778 if v := lhs.MapIndex(key); v != Nil { 3779 result = int32(v.Int()) 3780 } 3781 result &= val 3782 3783 lhs.SetMapIndex(key, r.ValueOf(result)) 3784 env.IP++ 3785 return env.Code[env.IP], env 3786 } 3787 case r.Int64: 3788 val := int64(v.Int()) 3789 3790 ret = func(env *Env) (Stmt, *Env) { 3791 lhs := lhsfun(env) 3792 key := keyfun(env) 3793 var result int64 3794 3795 if v := lhs.MapIndex(key); v != Nil { 3796 result = v.Int() 3797 } 3798 result &= val 3799 3800 lhs.SetMapIndex(key, r.ValueOf(result)) 3801 env.IP++ 3802 return env.Code[env.IP], env 3803 } 3804 case r.Uint: 3805 val := uint(v.Uint()) 3806 3807 ret = func(env *Env) (Stmt, *Env) { 3808 lhs := lhsfun(env) 3809 key := keyfun(env) 3810 var result uint 3811 3812 if v := lhs.MapIndex(key); v != Nil { 3813 result = uint(v.Uint()) 3814 } 3815 result &= val 3816 3817 lhs.SetMapIndex(key, r.ValueOf(result)) 3818 env.IP++ 3819 return env.Code[env.IP], env 3820 } 3821 case r.Uint8: 3822 val := uint8(v.Uint()) 3823 3824 ret = func(env *Env) (Stmt, *Env) { 3825 lhs := lhsfun(env) 3826 key := keyfun(env) 3827 var result uint8 3828 3829 if v := lhs.MapIndex(key); v != Nil { 3830 result = uint8(v.Uint()) 3831 } 3832 result &= val 3833 3834 lhs.SetMapIndex(key, r.ValueOf(result)) 3835 env.IP++ 3836 return env.Code[env.IP], env 3837 } 3838 case r.Uint16: 3839 val := uint16(v.Uint()) 3840 3841 ret = func(env *Env) (Stmt, *Env) { 3842 lhs := lhsfun(env) 3843 key := keyfun(env) 3844 var result uint16 3845 3846 if v := lhs.MapIndex(key); v != Nil { 3847 result = uint16(v.Uint()) 3848 } 3849 result &= val 3850 3851 lhs.SetMapIndex(key, r.ValueOf(result)) 3852 env.IP++ 3853 return env.Code[env.IP], env 3854 } 3855 case r.Uint32: 3856 val := uint32(v.Uint()) 3857 3858 ret = func(env *Env) (Stmt, *Env) { 3859 lhs := lhsfun(env) 3860 key := keyfun(env) 3861 var result uint32 3862 3863 if v := lhs.MapIndex(key); v != Nil { 3864 result = uint32(v.Uint()) 3865 } 3866 result &= val 3867 3868 lhs.SetMapIndex(key, r.ValueOf(result)) 3869 env.IP++ 3870 return env.Code[env.IP], env 3871 } 3872 case r.Uint64: 3873 val := uint64(v.Uint()) 3874 3875 ret = func(env *Env) (Stmt, *Env) { 3876 lhs := lhsfun(env) 3877 key := keyfun(env) 3878 var result uint64 3879 3880 if v := lhs.MapIndex(key); v != Nil { 3881 result = v.Uint() 3882 } 3883 result &= val 3884 3885 lhs.SetMapIndex(key, r.ValueOf(result)) 3886 env.IP++ 3887 return env.Code[env.IP], env 3888 } 3889 case r.Uintptr: 3890 val := uintptr(v.Uint()) 3891 3892 ret = func(env *Env) (Stmt, *Env) { 3893 lhs := lhsfun(env) 3894 key := keyfun(env) 3895 var result uintptr 3896 3897 if v := lhs.MapIndex(key); v != Nil { 3898 result = uintptr(v.Uint()) 3899 } 3900 result &= val 3901 3902 lhs.SetMapIndex(key, r.ValueOf(result)) 3903 env.IP++ 3904 return env.Code[env.IP], env 3905 } 3906 default: 3907 c.Errorf(`invalid operator %s= on <%v>`, token.AND, place.Type) 3908 3909 } 3910 } 3911 return ret 3912 } 3913} 3914func (c *Comp) placeAndExpr(place *Place, fun I) Stmt { 3915 var ret Stmt 3916 lhsfun := place.Fun 3917 keyfun := place.MapKey 3918 if keyfun == nil { 3919 switch fun := fun.(type) { 3920 case func(*Env) int: 3921 3922 ret = func(env *Env) (Stmt, *Env) { 3923 lhs := lhsfun(env) 3924 lhs.SetInt(lhs.Int() & int64(fun(env), 3925 ), 3926 ) 3927 3928 env.IP++ 3929 return env.Code[env.IP], env 3930 } 3931 case func(*Env) int8: 3932 3933 ret = func(env *Env) (Stmt, *Env) { 3934 lhs := lhsfun(env) 3935 lhs.SetInt(lhs.Int() & int64(fun(env), 3936 ), 3937 ) 3938 3939 env.IP++ 3940 return env.Code[env.IP], env 3941 } 3942 case func(*Env) int16: 3943 3944 ret = func(env *Env) (Stmt, *Env) { 3945 lhs := lhsfun(env) 3946 lhs.SetInt(lhs.Int() & int64(fun(env), 3947 ), 3948 ) 3949 3950 env.IP++ 3951 return env.Code[env.IP], env 3952 } 3953 case func(*Env) int32: 3954 3955 ret = func(env *Env) (Stmt, *Env) { 3956 lhs := lhsfun(env) 3957 lhs.SetInt(lhs.Int() & int64(fun(env), 3958 ), 3959 ) 3960 3961 env.IP++ 3962 return env.Code[env.IP], env 3963 } 3964 case func(*Env) int64: 3965 3966 ret = func(env *Env) (Stmt, *Env) { 3967 lhs := lhsfun(env) 3968 lhs.SetInt(lhs.Int() & 3969 fun(env), 3970 ) 3971 3972 env.IP++ 3973 return env.Code[env.IP], env 3974 } 3975 case func(*Env) uint: 3976 3977 ret = func(env *Env) (Stmt, *Env) { 3978 lhs := lhsfun(env) 3979 lhs.SetUint(lhs.Uint() & uint64(fun(env), 3980 ), 3981 ) 3982 3983 env.IP++ 3984 return env.Code[env.IP], env 3985 } 3986 case func(*Env) uint8: 3987 3988 ret = func(env *Env) (Stmt, *Env) { 3989 lhs := lhsfun(env) 3990 lhs.SetUint(lhs.Uint() & uint64(fun(env), 3991 ), 3992 ) 3993 3994 env.IP++ 3995 return env.Code[env.IP], env 3996 } 3997 case func(*Env) uint16: 3998 3999 ret = func(env *Env) (Stmt, *Env) { 4000 lhs := lhsfun(env) 4001 lhs.SetUint(lhs.Uint() & uint64(fun(env), 4002 ), 4003 ) 4004 4005 env.IP++ 4006 return env.Code[env.IP], env 4007 } 4008 case func(*Env) uint32: 4009 4010 ret = func(env *Env) (Stmt, *Env) { 4011 lhs := lhsfun(env) 4012 lhs.SetUint(lhs.Uint() & uint64(fun(env), 4013 ), 4014 ) 4015 4016 env.IP++ 4017 return env.Code[env.IP], env 4018 } 4019 case func(*Env) uint64: 4020 4021 ret = func(env *Env) (Stmt, *Env) { 4022 lhs := lhsfun(env) 4023 lhs.SetUint(lhs.Uint() & 4024 fun(env), 4025 ) 4026 4027 env.IP++ 4028 return env.Code[env.IP], env 4029 } 4030 case func(*Env) uintptr: 4031 4032 ret = func(env *Env) (Stmt, *Env) { 4033 lhs := lhsfun(env) 4034 lhs.SetUint(lhs.Uint() & uint64(fun(env), 4035 ), 4036 ) 4037 4038 env.IP++ 4039 return env.Code[env.IP], env 4040 } 4041 default: 4042 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.AND, place.Type, funTypeOut(fun)) 4043 4044 } 4045 } else { 4046 switch fun := fun.(type) { 4047 case func(*Env) int: 4048 4049 ret = func(env *Env) (Stmt, *Env) { 4050 lhs := lhsfun(env) 4051 key := keyfun(env) 4052 var result int 4053 4054 if v := lhs.MapIndex(key); v != Nil { 4055 result = int(v.Int()) 4056 } 4057 result &= fun(env) 4058 4059 lhs.SetMapIndex(key, r.ValueOf(result)) 4060 env.IP++ 4061 return env.Code[env.IP], env 4062 } 4063 case func(*Env) int8: 4064 4065 ret = func(env *Env) (Stmt, *Env) { 4066 lhs := lhsfun(env) 4067 key := keyfun(env) 4068 var result int8 4069 4070 if v := lhs.MapIndex(key); v != Nil { 4071 result = int8(v.Int()) 4072 } 4073 result &= fun(env) 4074 4075 lhs.SetMapIndex(key, r.ValueOf(result)) 4076 env.IP++ 4077 return env.Code[env.IP], env 4078 } 4079 case func(*Env) int16: 4080 4081 ret = func(env *Env) (Stmt, *Env) { 4082 lhs := lhsfun(env) 4083 key := keyfun(env) 4084 var result int16 4085 4086 if v := lhs.MapIndex(key); v != Nil { 4087 result = int16(v.Int()) 4088 } 4089 result &= fun(env) 4090 4091 lhs.SetMapIndex(key, r.ValueOf(result)) 4092 env.IP++ 4093 return env.Code[env.IP], env 4094 } 4095 case func(*Env) int32: 4096 4097 ret = func(env *Env) (Stmt, *Env) { 4098 lhs := lhsfun(env) 4099 key := keyfun(env) 4100 var result int32 4101 4102 if v := lhs.MapIndex(key); v != Nil { 4103 result = int32(v.Int()) 4104 } 4105 result &= fun(env) 4106 4107 lhs.SetMapIndex(key, r.ValueOf(result)) 4108 env.IP++ 4109 return env.Code[env.IP], env 4110 } 4111 case func(*Env) int64: 4112 4113 ret = func(env *Env) (Stmt, *Env) { 4114 lhs := lhsfun(env) 4115 key := keyfun(env) 4116 var result int64 4117 4118 if v := lhs.MapIndex(key); v != Nil { 4119 result = v.Int() 4120 } 4121 result &= fun(env) 4122 4123 lhs.SetMapIndex(key, r.ValueOf(result)) 4124 env.IP++ 4125 return env.Code[env.IP], env 4126 } 4127 case func(*Env) uint: 4128 4129 ret = func(env *Env) (Stmt, *Env) { 4130 lhs := lhsfun(env) 4131 key := keyfun(env) 4132 var result uint 4133 4134 if v := lhs.MapIndex(key); v != Nil { 4135 result = uint(v.Uint()) 4136 } 4137 result &= fun(env) 4138 4139 lhs.SetMapIndex(key, r.ValueOf(result)) 4140 env.IP++ 4141 return env.Code[env.IP], env 4142 } 4143 case func(*Env) uint8: 4144 4145 ret = func(env *Env) (Stmt, *Env) { 4146 lhs := lhsfun(env) 4147 key := keyfun(env) 4148 var result uint8 4149 4150 if v := lhs.MapIndex(key); v != Nil { 4151 result = uint8(v.Uint()) 4152 } 4153 result &= fun(env) 4154 4155 lhs.SetMapIndex(key, r.ValueOf(result)) 4156 env.IP++ 4157 return env.Code[env.IP], env 4158 } 4159 case func(*Env) uint16: 4160 4161 ret = func(env *Env) (Stmt, *Env) { 4162 lhs := lhsfun(env) 4163 key := keyfun(env) 4164 var result uint16 4165 4166 if v := lhs.MapIndex(key); v != Nil { 4167 result = uint16(v.Uint()) 4168 } 4169 result &= fun(env) 4170 4171 lhs.SetMapIndex(key, r.ValueOf(result)) 4172 env.IP++ 4173 return env.Code[env.IP], env 4174 } 4175 case func(*Env) uint32: 4176 4177 ret = func(env *Env) (Stmt, *Env) { 4178 lhs := lhsfun(env) 4179 key := keyfun(env) 4180 var result uint32 4181 4182 if v := lhs.MapIndex(key); v != Nil { 4183 result = uint32(v.Uint()) 4184 } 4185 result &= fun(env) 4186 4187 lhs.SetMapIndex(key, r.ValueOf(result)) 4188 env.IP++ 4189 return env.Code[env.IP], env 4190 } 4191 case func(*Env) uint64: 4192 4193 ret = func(env *Env) (Stmt, *Env) { 4194 lhs := lhsfun(env) 4195 key := keyfun(env) 4196 var result uint64 4197 4198 if v := lhs.MapIndex(key); v != Nil { 4199 result = v.Uint() 4200 } 4201 result &= fun(env) 4202 4203 lhs.SetMapIndex(key, r.ValueOf(result)) 4204 env.IP++ 4205 return env.Code[env.IP], env 4206 } 4207 case func(*Env) uintptr: 4208 4209 ret = func(env *Env) (Stmt, *Env) { 4210 lhs := lhsfun(env) 4211 key := keyfun(env) 4212 var result uintptr 4213 4214 if v := lhs.MapIndex(key); v != Nil { 4215 result = uintptr(v.Uint()) 4216 } 4217 result &= fun(env) 4218 4219 lhs.SetMapIndex(key, r.ValueOf(result)) 4220 env.IP++ 4221 return env.Code[env.IP], env 4222 } 4223 default: 4224 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.AND, place.Type, funTypeOut(fun)) 4225 4226 } 4227 } 4228 return ret 4229} 4230func (c *Comp) placeOrConst(place *Place, val I) Stmt { 4231 if reflect.IsCategory(place.Type.Kind(), r.Int, r.Uint) && isLiteralNumber(val, 0) { 4232 return c.placeForSideEffects(place) 4233 } 4234 4235 { 4236 var ret Stmt 4237 lhsfun := place.Fun 4238 keyfun := place.MapKey 4239 v := r.ValueOf(val) 4240 4241 if keyfun == nil { 4242 switch reflect.Category(place.Type.Kind()) { 4243 case r.Int: 4244 val := v.Int() 4245 4246 ret = func(env *Env) (Stmt, *Env) { 4247 lhs := lhsfun(env) 4248 lhs.SetInt(lhs.Int() | int64(val, 4249 ), 4250 ) 4251 4252 env.IP++ 4253 return env.Code[env.IP], env 4254 } 4255 case r.Uint: 4256 val := v.Uint() 4257 4258 ret = func(env *Env) (Stmt, *Env) { 4259 lhs := lhsfun(env) 4260 lhs.SetUint(lhs.Uint() | uint64(val, 4261 ), 4262 ) 4263 4264 env.IP++ 4265 return env.Code[env.IP], env 4266 } 4267 default: 4268 c.Errorf(`invalid operator %s= on <%v>`, token.OR, place.Type) 4269 4270 } 4271 } else { 4272 switch place.Type.Kind() { 4273 case r.Int: 4274 val := int(v.Int()) 4275 4276 ret = func(env *Env) (Stmt, *Env) { 4277 lhs := lhsfun(env) 4278 key := keyfun(env) 4279 var result int 4280 4281 if v := lhs.MapIndex(key); v != Nil { 4282 result = int(v.Int()) 4283 } 4284 result |= val 4285 4286 lhs.SetMapIndex(key, r.ValueOf(result)) 4287 env.IP++ 4288 return env.Code[env.IP], env 4289 } 4290 case r.Int8: 4291 val := int8(v.Int()) 4292 4293 ret = func(env *Env) (Stmt, *Env) { 4294 lhs := lhsfun(env) 4295 key := keyfun(env) 4296 var result int8 4297 4298 if v := lhs.MapIndex(key); v != Nil { 4299 result = int8(v.Int()) 4300 } 4301 result |= val 4302 4303 lhs.SetMapIndex(key, r.ValueOf(result)) 4304 env.IP++ 4305 return env.Code[env.IP], env 4306 } 4307 case r.Int16: 4308 val := int16(v.Int()) 4309 4310 ret = func(env *Env) (Stmt, *Env) { 4311 lhs := lhsfun(env) 4312 key := keyfun(env) 4313 var result int16 4314 4315 if v := lhs.MapIndex(key); v != Nil { 4316 result = int16(v.Int()) 4317 } 4318 result |= val 4319 4320 lhs.SetMapIndex(key, r.ValueOf(result)) 4321 env.IP++ 4322 return env.Code[env.IP], env 4323 } 4324 case r.Int32: 4325 val := int32(v.Int()) 4326 4327 ret = func(env *Env) (Stmt, *Env) { 4328 lhs := lhsfun(env) 4329 key := keyfun(env) 4330 var result int32 4331 4332 if v := lhs.MapIndex(key); v != Nil { 4333 result = int32(v.Int()) 4334 } 4335 result |= val 4336 4337 lhs.SetMapIndex(key, r.ValueOf(result)) 4338 env.IP++ 4339 return env.Code[env.IP], env 4340 } 4341 case r.Int64: 4342 val := int64(v.Int()) 4343 4344 ret = func(env *Env) (Stmt, *Env) { 4345 lhs := lhsfun(env) 4346 key := keyfun(env) 4347 var result int64 4348 4349 if v := lhs.MapIndex(key); v != Nil { 4350 result = v.Int() 4351 } 4352 result |= val 4353 4354 lhs.SetMapIndex(key, r.ValueOf(result)) 4355 env.IP++ 4356 return env.Code[env.IP], env 4357 } 4358 case r.Uint: 4359 val := uint(v.Uint()) 4360 4361 ret = func(env *Env) (Stmt, *Env) { 4362 lhs := lhsfun(env) 4363 key := keyfun(env) 4364 var result uint 4365 4366 if v := lhs.MapIndex(key); v != Nil { 4367 result = uint(v.Uint()) 4368 } 4369 result |= val 4370 4371 lhs.SetMapIndex(key, r.ValueOf(result)) 4372 env.IP++ 4373 return env.Code[env.IP], env 4374 } 4375 case r.Uint8: 4376 val := uint8(v.Uint()) 4377 4378 ret = func(env *Env) (Stmt, *Env) { 4379 lhs := lhsfun(env) 4380 key := keyfun(env) 4381 var result uint8 4382 4383 if v := lhs.MapIndex(key); v != Nil { 4384 result = uint8(v.Uint()) 4385 } 4386 result |= val 4387 4388 lhs.SetMapIndex(key, r.ValueOf(result)) 4389 env.IP++ 4390 return env.Code[env.IP], env 4391 } 4392 case r.Uint16: 4393 val := uint16(v.Uint()) 4394 4395 ret = func(env *Env) (Stmt, *Env) { 4396 lhs := lhsfun(env) 4397 key := keyfun(env) 4398 var result uint16 4399 4400 if v := lhs.MapIndex(key); v != Nil { 4401 result = uint16(v.Uint()) 4402 } 4403 result |= val 4404 4405 lhs.SetMapIndex(key, r.ValueOf(result)) 4406 env.IP++ 4407 return env.Code[env.IP], env 4408 } 4409 case r.Uint32: 4410 val := uint32(v.Uint()) 4411 4412 ret = func(env *Env) (Stmt, *Env) { 4413 lhs := lhsfun(env) 4414 key := keyfun(env) 4415 var result uint32 4416 4417 if v := lhs.MapIndex(key); v != Nil { 4418 result = uint32(v.Uint()) 4419 } 4420 result |= val 4421 4422 lhs.SetMapIndex(key, r.ValueOf(result)) 4423 env.IP++ 4424 return env.Code[env.IP], env 4425 } 4426 case r.Uint64: 4427 val := uint64(v.Uint()) 4428 4429 ret = func(env *Env) (Stmt, *Env) { 4430 lhs := lhsfun(env) 4431 key := keyfun(env) 4432 var result uint64 4433 4434 if v := lhs.MapIndex(key); v != Nil { 4435 result = v.Uint() 4436 } 4437 result |= val 4438 4439 lhs.SetMapIndex(key, r.ValueOf(result)) 4440 env.IP++ 4441 return env.Code[env.IP], env 4442 } 4443 case r.Uintptr: 4444 val := uintptr(v.Uint()) 4445 4446 ret = func(env *Env) (Stmt, *Env) { 4447 lhs := lhsfun(env) 4448 key := keyfun(env) 4449 var result uintptr 4450 4451 if v := lhs.MapIndex(key); v != Nil { 4452 result = uintptr(v.Uint()) 4453 } 4454 result |= val 4455 4456 lhs.SetMapIndex(key, r.ValueOf(result)) 4457 env.IP++ 4458 return env.Code[env.IP], env 4459 } 4460 default: 4461 c.Errorf(`invalid operator %s= on <%v>`, token.OR, place.Type) 4462 4463 } 4464 } 4465 return ret 4466 } 4467} 4468func (c *Comp) placeOrExpr(place *Place, fun I) Stmt { 4469 var ret Stmt 4470 lhsfun := place.Fun 4471 keyfun := place.MapKey 4472 if keyfun == nil { 4473 switch fun := fun.(type) { 4474 case func(*Env) int: 4475 4476 ret = func(env *Env) (Stmt, *Env) { 4477 lhs := lhsfun(env) 4478 lhs.SetInt(lhs.Int() | int64(fun(env), 4479 ), 4480 ) 4481 4482 env.IP++ 4483 return env.Code[env.IP], env 4484 } 4485 case func(*Env) int8: 4486 4487 ret = func(env *Env) (Stmt, *Env) { 4488 lhs := lhsfun(env) 4489 lhs.SetInt(lhs.Int() | int64(fun(env), 4490 ), 4491 ) 4492 4493 env.IP++ 4494 return env.Code[env.IP], env 4495 } 4496 case func(*Env) int16: 4497 4498 ret = func(env *Env) (Stmt, *Env) { 4499 lhs := lhsfun(env) 4500 lhs.SetInt(lhs.Int() | int64(fun(env), 4501 ), 4502 ) 4503 4504 env.IP++ 4505 return env.Code[env.IP], env 4506 } 4507 case func(*Env) int32: 4508 4509 ret = func(env *Env) (Stmt, *Env) { 4510 lhs := lhsfun(env) 4511 lhs.SetInt(lhs.Int() | int64(fun(env), 4512 ), 4513 ) 4514 4515 env.IP++ 4516 return env.Code[env.IP], env 4517 } 4518 case func(*Env) int64: 4519 4520 ret = func(env *Env) (Stmt, *Env) { 4521 lhs := lhsfun(env) 4522 lhs.SetInt(lhs.Int() | 4523 fun(env), 4524 ) 4525 4526 env.IP++ 4527 return env.Code[env.IP], env 4528 } 4529 case func(*Env) uint: 4530 4531 ret = func(env *Env) (Stmt, *Env) { 4532 lhs := lhsfun(env) 4533 lhs.SetUint(lhs.Uint() | uint64(fun(env), 4534 ), 4535 ) 4536 4537 env.IP++ 4538 return env.Code[env.IP], env 4539 } 4540 case func(*Env) uint8: 4541 4542 ret = func(env *Env) (Stmt, *Env) { 4543 lhs := lhsfun(env) 4544 lhs.SetUint(lhs.Uint() | uint64(fun(env), 4545 ), 4546 ) 4547 4548 env.IP++ 4549 return env.Code[env.IP], env 4550 } 4551 case func(*Env) uint16: 4552 4553 ret = func(env *Env) (Stmt, *Env) { 4554 lhs := lhsfun(env) 4555 lhs.SetUint(lhs.Uint() | uint64(fun(env), 4556 ), 4557 ) 4558 4559 env.IP++ 4560 return env.Code[env.IP], env 4561 } 4562 case func(*Env) uint32: 4563 4564 ret = func(env *Env) (Stmt, *Env) { 4565 lhs := lhsfun(env) 4566 lhs.SetUint(lhs.Uint() | uint64(fun(env), 4567 ), 4568 ) 4569 4570 env.IP++ 4571 return env.Code[env.IP], env 4572 } 4573 case func(*Env) uint64: 4574 4575 ret = func(env *Env) (Stmt, *Env) { 4576 lhs := lhsfun(env) 4577 lhs.SetUint(lhs.Uint() | 4578 fun(env), 4579 ) 4580 4581 env.IP++ 4582 return env.Code[env.IP], env 4583 } 4584 case func(*Env) uintptr: 4585 4586 ret = func(env *Env) (Stmt, *Env) { 4587 lhs := lhsfun(env) 4588 lhs.SetUint(lhs.Uint() | uint64(fun(env), 4589 ), 4590 ) 4591 4592 env.IP++ 4593 return env.Code[env.IP], env 4594 } 4595 default: 4596 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.OR, place.Type, funTypeOut(fun)) 4597 4598 } 4599 } else { 4600 switch fun := fun.(type) { 4601 case func(*Env) int: 4602 4603 ret = func(env *Env) (Stmt, *Env) { 4604 lhs := lhsfun(env) 4605 key := keyfun(env) 4606 var result int 4607 4608 if v := lhs.MapIndex(key); v != Nil { 4609 result = int(v.Int()) 4610 } 4611 result |= fun(env) 4612 4613 lhs.SetMapIndex(key, r.ValueOf(result)) 4614 env.IP++ 4615 return env.Code[env.IP], env 4616 } 4617 case func(*Env) int8: 4618 4619 ret = func(env *Env) (Stmt, *Env) { 4620 lhs := lhsfun(env) 4621 key := keyfun(env) 4622 var result int8 4623 4624 if v := lhs.MapIndex(key); v != Nil { 4625 result = int8(v.Int()) 4626 } 4627 result |= fun(env) 4628 4629 lhs.SetMapIndex(key, r.ValueOf(result)) 4630 env.IP++ 4631 return env.Code[env.IP], env 4632 } 4633 case func(*Env) int16: 4634 4635 ret = func(env *Env) (Stmt, *Env) { 4636 lhs := lhsfun(env) 4637 key := keyfun(env) 4638 var result int16 4639 4640 if v := lhs.MapIndex(key); v != Nil { 4641 result = int16(v.Int()) 4642 } 4643 result |= fun(env) 4644 4645 lhs.SetMapIndex(key, r.ValueOf(result)) 4646 env.IP++ 4647 return env.Code[env.IP], env 4648 } 4649 case func(*Env) int32: 4650 4651 ret = func(env *Env) (Stmt, *Env) { 4652 lhs := lhsfun(env) 4653 key := keyfun(env) 4654 var result int32 4655 4656 if v := lhs.MapIndex(key); v != Nil { 4657 result = int32(v.Int()) 4658 } 4659 result |= fun(env) 4660 4661 lhs.SetMapIndex(key, r.ValueOf(result)) 4662 env.IP++ 4663 return env.Code[env.IP], env 4664 } 4665 case func(*Env) int64: 4666 4667 ret = func(env *Env) (Stmt, *Env) { 4668 lhs := lhsfun(env) 4669 key := keyfun(env) 4670 var result int64 4671 4672 if v := lhs.MapIndex(key); v != Nil { 4673 result = v.Int() 4674 } 4675 result |= fun(env) 4676 4677 lhs.SetMapIndex(key, r.ValueOf(result)) 4678 env.IP++ 4679 return env.Code[env.IP], env 4680 } 4681 case func(*Env) uint: 4682 4683 ret = func(env *Env) (Stmt, *Env) { 4684 lhs := lhsfun(env) 4685 key := keyfun(env) 4686 var result uint 4687 4688 if v := lhs.MapIndex(key); v != Nil { 4689 result = uint(v.Uint()) 4690 } 4691 result |= fun(env) 4692 4693 lhs.SetMapIndex(key, r.ValueOf(result)) 4694 env.IP++ 4695 return env.Code[env.IP], env 4696 } 4697 case func(*Env) uint8: 4698 4699 ret = func(env *Env) (Stmt, *Env) { 4700 lhs := lhsfun(env) 4701 key := keyfun(env) 4702 var result uint8 4703 4704 if v := lhs.MapIndex(key); v != Nil { 4705 result = uint8(v.Uint()) 4706 } 4707 result |= fun(env) 4708 4709 lhs.SetMapIndex(key, r.ValueOf(result)) 4710 env.IP++ 4711 return env.Code[env.IP], env 4712 } 4713 case func(*Env) uint16: 4714 4715 ret = func(env *Env) (Stmt, *Env) { 4716 lhs := lhsfun(env) 4717 key := keyfun(env) 4718 var result uint16 4719 4720 if v := lhs.MapIndex(key); v != Nil { 4721 result = uint16(v.Uint()) 4722 } 4723 result |= fun(env) 4724 4725 lhs.SetMapIndex(key, r.ValueOf(result)) 4726 env.IP++ 4727 return env.Code[env.IP], env 4728 } 4729 case func(*Env) uint32: 4730 4731 ret = func(env *Env) (Stmt, *Env) { 4732 lhs := lhsfun(env) 4733 key := keyfun(env) 4734 var result uint32 4735 4736 if v := lhs.MapIndex(key); v != Nil { 4737 result = uint32(v.Uint()) 4738 } 4739 result |= fun(env) 4740 4741 lhs.SetMapIndex(key, r.ValueOf(result)) 4742 env.IP++ 4743 return env.Code[env.IP], env 4744 } 4745 case func(*Env) uint64: 4746 4747 ret = func(env *Env) (Stmt, *Env) { 4748 lhs := lhsfun(env) 4749 key := keyfun(env) 4750 var result uint64 4751 4752 if v := lhs.MapIndex(key); v != Nil { 4753 result = v.Uint() 4754 } 4755 result |= fun(env) 4756 4757 lhs.SetMapIndex(key, r.ValueOf(result)) 4758 env.IP++ 4759 return env.Code[env.IP], env 4760 } 4761 case func(*Env) uintptr: 4762 4763 ret = func(env *Env) (Stmt, *Env) { 4764 lhs := lhsfun(env) 4765 key := keyfun(env) 4766 var result uintptr 4767 4768 if v := lhs.MapIndex(key); v != Nil { 4769 result = uintptr(v.Uint()) 4770 } 4771 result |= fun(env) 4772 4773 lhs.SetMapIndex(key, r.ValueOf(result)) 4774 env.IP++ 4775 return env.Code[env.IP], env 4776 } 4777 default: 4778 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.OR, place.Type, funTypeOut(fun)) 4779 4780 } 4781 } 4782 return ret 4783} 4784func (c *Comp) placeXorConst(place *Place, val I) Stmt { 4785 if reflect.IsCategory(place.Type.Kind(), r.Int, r.Uint) && isLiteralNumber(val, 0) { 4786 return c.placeForSideEffects(place) 4787 } 4788 4789 { 4790 var ret Stmt 4791 lhsfun := place.Fun 4792 keyfun := place.MapKey 4793 v := r.ValueOf(val) 4794 4795 if keyfun == nil { 4796 switch reflect.Category(place.Type.Kind()) { 4797 case r.Int: 4798 val := v.Int() 4799 4800 ret = func(env *Env) (Stmt, *Env) { 4801 lhs := lhsfun(env) 4802 lhs.SetInt(lhs.Int() ^ int64(val, 4803 ), 4804 ) 4805 4806 env.IP++ 4807 return env.Code[env.IP], env 4808 } 4809 case r.Uint: 4810 val := v.Uint() 4811 4812 ret = func(env *Env) (Stmt, *Env) { 4813 lhs := lhsfun(env) 4814 lhs.SetUint(lhs.Uint() ^ uint64(val, 4815 ), 4816 ) 4817 4818 env.IP++ 4819 return env.Code[env.IP], env 4820 } 4821 default: 4822 c.Errorf(`invalid operator %s= on <%v>`, token.XOR, place.Type) 4823 4824 } 4825 } else { 4826 switch place.Type.Kind() { 4827 case r.Int: 4828 val := int(v.Int()) 4829 4830 ret = func(env *Env) (Stmt, *Env) { 4831 lhs := lhsfun(env) 4832 key := keyfun(env) 4833 var result int 4834 4835 if v := lhs.MapIndex(key); v != Nil { 4836 result = int(v.Int()) 4837 } 4838 result ^= val 4839 4840 lhs.SetMapIndex(key, r.ValueOf(result)) 4841 env.IP++ 4842 return env.Code[env.IP], env 4843 } 4844 case r.Int8: 4845 val := int8(v.Int()) 4846 4847 ret = func(env *Env) (Stmt, *Env) { 4848 lhs := lhsfun(env) 4849 key := keyfun(env) 4850 var result int8 4851 4852 if v := lhs.MapIndex(key); v != Nil { 4853 result = int8(v.Int()) 4854 } 4855 result ^= val 4856 4857 lhs.SetMapIndex(key, r.ValueOf(result)) 4858 env.IP++ 4859 return env.Code[env.IP], env 4860 } 4861 case r.Int16: 4862 val := int16(v.Int()) 4863 4864 ret = func(env *Env) (Stmt, *Env) { 4865 lhs := lhsfun(env) 4866 key := keyfun(env) 4867 var result int16 4868 4869 if v := lhs.MapIndex(key); v != Nil { 4870 result = int16(v.Int()) 4871 } 4872 result ^= val 4873 4874 lhs.SetMapIndex(key, r.ValueOf(result)) 4875 env.IP++ 4876 return env.Code[env.IP], env 4877 } 4878 case r.Int32: 4879 val := int32(v.Int()) 4880 4881 ret = func(env *Env) (Stmt, *Env) { 4882 lhs := lhsfun(env) 4883 key := keyfun(env) 4884 var result int32 4885 4886 if v := lhs.MapIndex(key); v != Nil { 4887 result = int32(v.Int()) 4888 } 4889 result ^= val 4890 4891 lhs.SetMapIndex(key, r.ValueOf(result)) 4892 env.IP++ 4893 return env.Code[env.IP], env 4894 } 4895 case r.Int64: 4896 val := int64(v.Int()) 4897 4898 ret = func(env *Env) (Stmt, *Env) { 4899 lhs := lhsfun(env) 4900 key := keyfun(env) 4901 var result int64 4902 4903 if v := lhs.MapIndex(key); v != Nil { 4904 result = v.Int() 4905 } 4906 result ^= val 4907 4908 lhs.SetMapIndex(key, r.ValueOf(result)) 4909 env.IP++ 4910 return env.Code[env.IP], env 4911 } 4912 case r.Uint: 4913 val := uint(v.Uint()) 4914 4915 ret = func(env *Env) (Stmt, *Env) { 4916 lhs := lhsfun(env) 4917 key := keyfun(env) 4918 var result uint 4919 4920 if v := lhs.MapIndex(key); v != Nil { 4921 result = uint(v.Uint()) 4922 } 4923 result ^= val 4924 4925 lhs.SetMapIndex(key, r.ValueOf(result)) 4926 env.IP++ 4927 return env.Code[env.IP], env 4928 } 4929 case r.Uint8: 4930 val := uint8(v.Uint()) 4931 4932 ret = func(env *Env) (Stmt, *Env) { 4933 lhs := lhsfun(env) 4934 key := keyfun(env) 4935 var result uint8 4936 4937 if v := lhs.MapIndex(key); v != Nil { 4938 result = uint8(v.Uint()) 4939 } 4940 result ^= val 4941 4942 lhs.SetMapIndex(key, r.ValueOf(result)) 4943 env.IP++ 4944 return env.Code[env.IP], env 4945 } 4946 case r.Uint16: 4947 val := uint16(v.Uint()) 4948 4949 ret = func(env *Env) (Stmt, *Env) { 4950 lhs := lhsfun(env) 4951 key := keyfun(env) 4952 var result uint16 4953 4954 if v := lhs.MapIndex(key); v != Nil { 4955 result = uint16(v.Uint()) 4956 } 4957 result ^= val 4958 4959 lhs.SetMapIndex(key, r.ValueOf(result)) 4960 env.IP++ 4961 return env.Code[env.IP], env 4962 } 4963 case r.Uint32: 4964 val := uint32(v.Uint()) 4965 4966 ret = func(env *Env) (Stmt, *Env) { 4967 lhs := lhsfun(env) 4968 key := keyfun(env) 4969 var result uint32 4970 4971 if v := lhs.MapIndex(key); v != Nil { 4972 result = uint32(v.Uint()) 4973 } 4974 result ^= val 4975 4976 lhs.SetMapIndex(key, r.ValueOf(result)) 4977 env.IP++ 4978 return env.Code[env.IP], env 4979 } 4980 case r.Uint64: 4981 val := uint64(v.Uint()) 4982 4983 ret = func(env *Env) (Stmt, *Env) { 4984 lhs := lhsfun(env) 4985 key := keyfun(env) 4986 var result uint64 4987 4988 if v := lhs.MapIndex(key); v != Nil { 4989 result = v.Uint() 4990 } 4991 result ^= val 4992 4993 lhs.SetMapIndex(key, r.ValueOf(result)) 4994 env.IP++ 4995 return env.Code[env.IP], env 4996 } 4997 case r.Uintptr: 4998 val := uintptr(v.Uint()) 4999 5000 ret = func(env *Env) (Stmt, *Env) { 5001 lhs := lhsfun(env) 5002 key := keyfun(env) 5003 var result uintptr 5004 5005 if v := lhs.MapIndex(key); v != Nil { 5006 result = uintptr(v.Uint()) 5007 } 5008 result ^= val 5009 5010 lhs.SetMapIndex(key, r.ValueOf(result)) 5011 env.IP++ 5012 return env.Code[env.IP], env 5013 } 5014 default: 5015 c.Errorf(`invalid operator %s= on <%v>`, token.XOR, place.Type) 5016 5017 } 5018 } 5019 return ret 5020 } 5021} 5022func (c *Comp) placeXorExpr(place *Place, fun I) Stmt { 5023 var ret Stmt 5024 lhsfun := place.Fun 5025 keyfun := place.MapKey 5026 if keyfun == nil { 5027 switch fun := fun.(type) { 5028 case func(*Env) int: 5029 5030 ret = func(env *Env) (Stmt, *Env) { 5031 lhs := lhsfun(env) 5032 lhs.SetInt(lhs.Int() ^ int64(fun(env), 5033 ), 5034 ) 5035 5036 env.IP++ 5037 return env.Code[env.IP], env 5038 } 5039 case func(*Env) int8: 5040 5041 ret = func(env *Env) (Stmt, *Env) { 5042 lhs := lhsfun(env) 5043 lhs.SetInt(lhs.Int() ^ int64(fun(env), 5044 ), 5045 ) 5046 5047 env.IP++ 5048 return env.Code[env.IP], env 5049 } 5050 case func(*Env) int16: 5051 5052 ret = func(env *Env) (Stmt, *Env) { 5053 lhs := lhsfun(env) 5054 lhs.SetInt(lhs.Int() ^ int64(fun(env), 5055 ), 5056 ) 5057 5058 env.IP++ 5059 return env.Code[env.IP], env 5060 } 5061 case func(*Env) int32: 5062 5063 ret = func(env *Env) (Stmt, *Env) { 5064 lhs := lhsfun(env) 5065 lhs.SetInt(lhs.Int() ^ int64(fun(env), 5066 ), 5067 ) 5068 5069 env.IP++ 5070 return env.Code[env.IP], env 5071 } 5072 case func(*Env) int64: 5073 5074 ret = func(env *Env) (Stmt, *Env) { 5075 lhs := lhsfun(env) 5076 lhs.SetInt(lhs.Int() ^ 5077 fun(env), 5078 ) 5079 5080 env.IP++ 5081 return env.Code[env.IP], env 5082 } 5083 case func(*Env) uint: 5084 5085 ret = func(env *Env) (Stmt, *Env) { 5086 lhs := lhsfun(env) 5087 lhs.SetUint(lhs.Uint() ^ uint64(fun(env), 5088 ), 5089 ) 5090 5091 env.IP++ 5092 return env.Code[env.IP], env 5093 } 5094 case func(*Env) uint8: 5095 5096 ret = func(env *Env) (Stmt, *Env) { 5097 lhs := lhsfun(env) 5098 lhs.SetUint(lhs.Uint() ^ uint64(fun(env), 5099 ), 5100 ) 5101 5102 env.IP++ 5103 return env.Code[env.IP], env 5104 } 5105 case func(*Env) uint16: 5106 5107 ret = func(env *Env) (Stmt, *Env) { 5108 lhs := lhsfun(env) 5109 lhs.SetUint(lhs.Uint() ^ uint64(fun(env), 5110 ), 5111 ) 5112 5113 env.IP++ 5114 return env.Code[env.IP], env 5115 } 5116 case func(*Env) uint32: 5117 5118 ret = func(env *Env) (Stmt, *Env) { 5119 lhs := lhsfun(env) 5120 lhs.SetUint(lhs.Uint() ^ uint64(fun(env), 5121 ), 5122 ) 5123 5124 env.IP++ 5125 return env.Code[env.IP], env 5126 } 5127 case func(*Env) uint64: 5128 5129 ret = func(env *Env) (Stmt, *Env) { 5130 lhs := lhsfun(env) 5131 lhs.SetUint(lhs.Uint() ^ 5132 fun(env), 5133 ) 5134 5135 env.IP++ 5136 return env.Code[env.IP], env 5137 } 5138 case func(*Env) uintptr: 5139 5140 ret = func(env *Env) (Stmt, *Env) { 5141 lhs := lhsfun(env) 5142 lhs.SetUint(lhs.Uint() ^ uint64(fun(env), 5143 ), 5144 ) 5145 5146 env.IP++ 5147 return env.Code[env.IP], env 5148 } 5149 default: 5150 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.XOR, place.Type, funTypeOut(fun)) 5151 5152 } 5153 } else { 5154 switch fun := fun.(type) { 5155 case func(*Env) int: 5156 5157 ret = func(env *Env) (Stmt, *Env) { 5158 lhs := lhsfun(env) 5159 key := keyfun(env) 5160 var result int 5161 5162 if v := lhs.MapIndex(key); v != Nil { 5163 result = int(v.Int()) 5164 } 5165 result ^= fun(env) 5166 5167 lhs.SetMapIndex(key, r.ValueOf(result)) 5168 env.IP++ 5169 return env.Code[env.IP], env 5170 } 5171 case func(*Env) int8: 5172 5173 ret = func(env *Env) (Stmt, *Env) { 5174 lhs := lhsfun(env) 5175 key := keyfun(env) 5176 var result int8 5177 5178 if v := lhs.MapIndex(key); v != Nil { 5179 result = int8(v.Int()) 5180 } 5181 result ^= fun(env) 5182 5183 lhs.SetMapIndex(key, r.ValueOf(result)) 5184 env.IP++ 5185 return env.Code[env.IP], env 5186 } 5187 case func(*Env) int16: 5188 5189 ret = func(env *Env) (Stmt, *Env) { 5190 lhs := lhsfun(env) 5191 key := keyfun(env) 5192 var result int16 5193 5194 if v := lhs.MapIndex(key); v != Nil { 5195 result = int16(v.Int()) 5196 } 5197 result ^= fun(env) 5198 5199 lhs.SetMapIndex(key, r.ValueOf(result)) 5200 env.IP++ 5201 return env.Code[env.IP], env 5202 } 5203 case func(*Env) int32: 5204 5205 ret = func(env *Env) (Stmt, *Env) { 5206 lhs := lhsfun(env) 5207 key := keyfun(env) 5208 var result int32 5209 5210 if v := lhs.MapIndex(key); v != Nil { 5211 result = int32(v.Int()) 5212 } 5213 result ^= fun(env) 5214 5215 lhs.SetMapIndex(key, r.ValueOf(result)) 5216 env.IP++ 5217 return env.Code[env.IP], env 5218 } 5219 case func(*Env) int64: 5220 5221 ret = func(env *Env) (Stmt, *Env) { 5222 lhs := lhsfun(env) 5223 key := keyfun(env) 5224 var result int64 5225 5226 if v := lhs.MapIndex(key); v != Nil { 5227 result = v.Int() 5228 } 5229 result ^= fun(env) 5230 5231 lhs.SetMapIndex(key, r.ValueOf(result)) 5232 env.IP++ 5233 return env.Code[env.IP], env 5234 } 5235 case func(*Env) uint: 5236 5237 ret = func(env *Env) (Stmt, *Env) { 5238 lhs := lhsfun(env) 5239 key := keyfun(env) 5240 var result uint 5241 5242 if v := lhs.MapIndex(key); v != Nil { 5243 result = uint(v.Uint()) 5244 } 5245 result ^= fun(env) 5246 5247 lhs.SetMapIndex(key, r.ValueOf(result)) 5248 env.IP++ 5249 return env.Code[env.IP], env 5250 } 5251 case func(*Env) uint8: 5252 5253 ret = func(env *Env) (Stmt, *Env) { 5254 lhs := lhsfun(env) 5255 key := keyfun(env) 5256 var result uint8 5257 5258 if v := lhs.MapIndex(key); v != Nil { 5259 result = uint8(v.Uint()) 5260 } 5261 result ^= fun(env) 5262 5263 lhs.SetMapIndex(key, r.ValueOf(result)) 5264 env.IP++ 5265 return env.Code[env.IP], env 5266 } 5267 case func(*Env) uint16: 5268 5269 ret = func(env *Env) (Stmt, *Env) { 5270 lhs := lhsfun(env) 5271 key := keyfun(env) 5272 var result uint16 5273 5274 if v := lhs.MapIndex(key); v != Nil { 5275 result = uint16(v.Uint()) 5276 } 5277 result ^= fun(env) 5278 5279 lhs.SetMapIndex(key, r.ValueOf(result)) 5280 env.IP++ 5281 return env.Code[env.IP], env 5282 } 5283 case func(*Env) uint32: 5284 5285 ret = func(env *Env) (Stmt, *Env) { 5286 lhs := lhsfun(env) 5287 key := keyfun(env) 5288 var result uint32 5289 5290 if v := lhs.MapIndex(key); v != Nil { 5291 result = uint32(v.Uint()) 5292 } 5293 result ^= fun(env) 5294 5295 lhs.SetMapIndex(key, r.ValueOf(result)) 5296 env.IP++ 5297 return env.Code[env.IP], env 5298 } 5299 case func(*Env) uint64: 5300 5301 ret = func(env *Env) (Stmt, *Env) { 5302 lhs := lhsfun(env) 5303 key := keyfun(env) 5304 var result uint64 5305 5306 if v := lhs.MapIndex(key); v != Nil { 5307 result = v.Uint() 5308 } 5309 result ^= fun(env) 5310 5311 lhs.SetMapIndex(key, r.ValueOf(result)) 5312 env.IP++ 5313 return env.Code[env.IP], env 5314 } 5315 case func(*Env) uintptr: 5316 5317 ret = func(env *Env) (Stmt, *Env) { 5318 lhs := lhsfun(env) 5319 key := keyfun(env) 5320 var result uintptr 5321 5322 if v := lhs.MapIndex(key); v != Nil { 5323 result = uintptr(v.Uint()) 5324 } 5325 result ^= fun(env) 5326 5327 lhs.SetMapIndex(key, r.ValueOf(result)) 5328 env.IP++ 5329 return env.Code[env.IP], env 5330 } 5331 default: 5332 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.XOR, place.Type, funTypeOut(fun)) 5333 5334 } 5335 } 5336 return ret 5337} 5338func (c *Comp) placeAndnotConst(place *Place, val I) Stmt { 5339 if reflect.IsCategory(place.Type.Kind(), r.Int, r.Uint) { 5340 if isLiteralNumber(val, -1) { 5341 return c.placeSetZero(place) 5342 } else if isLiteralNumber(val, 0) { 5343 return c.placeForSideEffects(place) 5344 } 5345 } 5346 5347 { 5348 var ret Stmt 5349 lhsfun := place.Fun 5350 keyfun := place.MapKey 5351 v := r.ValueOf(val) 5352 5353 if keyfun == nil { 5354 switch reflect.Category(place.Type.Kind()) { 5355 case r.Int: 5356 val := v.Int() 5357 5358 ret = func(env *Env) (Stmt, *Env) { 5359 lhs := lhsfun(env) 5360 lhs.SetInt(lhs.Int() &^ int64(val, 5361 ), 5362 ) 5363 5364 env.IP++ 5365 return env.Code[env.IP], env 5366 } 5367 case r.Uint: 5368 val := v.Uint() 5369 5370 ret = func(env *Env) (Stmt, *Env) { 5371 lhs := lhsfun(env) 5372 lhs.SetUint(lhs.Uint() &^ uint64(val, 5373 ), 5374 ) 5375 5376 env.IP++ 5377 return env.Code[env.IP], env 5378 } 5379 default: 5380 c.Errorf(`invalid operator %s= on <%v>`, token.AND_NOT, place.Type) 5381 5382 } 5383 } else { 5384 switch place.Type.Kind() { 5385 case r.Int: 5386 val := int(v.Int()) 5387 5388 ret = func(env *Env) (Stmt, *Env) { 5389 lhs := lhsfun(env) 5390 key := keyfun(env) 5391 var result int 5392 5393 if v := lhs.MapIndex(key); v != Nil { 5394 result = int(v.Int()) 5395 } 5396 result &^= val 5397 5398 lhs.SetMapIndex(key, r.ValueOf(result)) 5399 env.IP++ 5400 return env.Code[env.IP], env 5401 } 5402 case r.Int8: 5403 val := int8(v.Int()) 5404 5405 ret = func(env *Env) (Stmt, *Env) { 5406 lhs := lhsfun(env) 5407 key := keyfun(env) 5408 var result int8 5409 5410 if v := lhs.MapIndex(key); v != Nil { 5411 result = int8(v.Int()) 5412 } 5413 result &^= val 5414 5415 lhs.SetMapIndex(key, r.ValueOf(result)) 5416 env.IP++ 5417 return env.Code[env.IP], env 5418 } 5419 case r.Int16: 5420 val := int16(v.Int()) 5421 5422 ret = func(env *Env) (Stmt, *Env) { 5423 lhs := lhsfun(env) 5424 key := keyfun(env) 5425 var result int16 5426 5427 if v := lhs.MapIndex(key); v != Nil { 5428 result = int16(v.Int()) 5429 } 5430 result &^= val 5431 5432 lhs.SetMapIndex(key, r.ValueOf(result)) 5433 env.IP++ 5434 return env.Code[env.IP], env 5435 } 5436 case r.Int32: 5437 val := int32(v.Int()) 5438 5439 ret = func(env *Env) (Stmt, *Env) { 5440 lhs := lhsfun(env) 5441 key := keyfun(env) 5442 var result int32 5443 5444 if v := lhs.MapIndex(key); v != Nil { 5445 result = int32(v.Int()) 5446 } 5447 result &^= val 5448 5449 lhs.SetMapIndex(key, r.ValueOf(result)) 5450 env.IP++ 5451 return env.Code[env.IP], env 5452 } 5453 case r.Int64: 5454 val := int64(v.Int()) 5455 5456 ret = func(env *Env) (Stmt, *Env) { 5457 lhs := lhsfun(env) 5458 key := keyfun(env) 5459 var result int64 5460 5461 if v := lhs.MapIndex(key); v != Nil { 5462 result = v.Int() 5463 } 5464 result &^= val 5465 5466 lhs.SetMapIndex(key, r.ValueOf(result)) 5467 env.IP++ 5468 return env.Code[env.IP], env 5469 } 5470 case r.Uint: 5471 val := uint(v.Uint()) 5472 5473 ret = func(env *Env) (Stmt, *Env) { 5474 lhs := lhsfun(env) 5475 key := keyfun(env) 5476 var result uint 5477 5478 if v := lhs.MapIndex(key); v != Nil { 5479 result = uint(v.Uint()) 5480 } 5481 result &^= val 5482 5483 lhs.SetMapIndex(key, r.ValueOf(result)) 5484 env.IP++ 5485 return env.Code[env.IP], env 5486 } 5487 case r.Uint8: 5488 val := uint8(v.Uint()) 5489 5490 ret = func(env *Env) (Stmt, *Env) { 5491 lhs := lhsfun(env) 5492 key := keyfun(env) 5493 var result uint8 5494 5495 if v := lhs.MapIndex(key); v != Nil { 5496 result = uint8(v.Uint()) 5497 } 5498 result &^= val 5499 5500 lhs.SetMapIndex(key, r.ValueOf(result)) 5501 env.IP++ 5502 return env.Code[env.IP], env 5503 } 5504 case r.Uint16: 5505 val := uint16(v.Uint()) 5506 5507 ret = func(env *Env) (Stmt, *Env) { 5508 lhs := lhsfun(env) 5509 key := keyfun(env) 5510 var result uint16 5511 5512 if v := lhs.MapIndex(key); v != Nil { 5513 result = uint16(v.Uint()) 5514 } 5515 result &^= val 5516 5517 lhs.SetMapIndex(key, r.ValueOf(result)) 5518 env.IP++ 5519 return env.Code[env.IP], env 5520 } 5521 case r.Uint32: 5522 val := uint32(v.Uint()) 5523 5524 ret = func(env *Env) (Stmt, *Env) { 5525 lhs := lhsfun(env) 5526 key := keyfun(env) 5527 var result uint32 5528 5529 if v := lhs.MapIndex(key); v != Nil { 5530 result = uint32(v.Uint()) 5531 } 5532 result &^= val 5533 5534 lhs.SetMapIndex(key, r.ValueOf(result)) 5535 env.IP++ 5536 return env.Code[env.IP], env 5537 } 5538 case r.Uint64: 5539 val := uint64(v.Uint()) 5540 5541 ret = func(env *Env) (Stmt, *Env) { 5542 lhs := lhsfun(env) 5543 key := keyfun(env) 5544 var result uint64 5545 5546 if v := lhs.MapIndex(key); v != Nil { 5547 result = v.Uint() 5548 } 5549 result &^= val 5550 5551 lhs.SetMapIndex(key, r.ValueOf(result)) 5552 env.IP++ 5553 return env.Code[env.IP], env 5554 } 5555 case r.Uintptr: 5556 val := uintptr(v.Uint()) 5557 5558 ret = func(env *Env) (Stmt, *Env) { 5559 lhs := lhsfun(env) 5560 key := keyfun(env) 5561 var result uintptr 5562 5563 if v := lhs.MapIndex(key); v != Nil { 5564 result = uintptr(v.Uint()) 5565 } 5566 result &^= val 5567 5568 lhs.SetMapIndex(key, r.ValueOf(result)) 5569 env.IP++ 5570 return env.Code[env.IP], env 5571 } 5572 default: 5573 c.Errorf(`invalid operator %s= on <%v>`, token.AND_NOT, place.Type) 5574 5575 } 5576 } 5577 return ret 5578 } 5579} 5580func (c *Comp) placeAndnotExpr(place *Place, fun I) Stmt { 5581 var ret Stmt 5582 lhsfun := place.Fun 5583 keyfun := place.MapKey 5584 if keyfun == nil { 5585 switch fun := fun.(type) { 5586 case func(*Env) int: 5587 5588 ret = func(env *Env) (Stmt, *Env) { 5589 lhs := lhsfun(env) 5590 lhs.SetInt(lhs.Int() &^ int64(fun(env), 5591 ), 5592 ) 5593 5594 env.IP++ 5595 return env.Code[env.IP], env 5596 } 5597 case func(*Env) int8: 5598 5599 ret = func(env *Env) (Stmt, *Env) { 5600 lhs := lhsfun(env) 5601 lhs.SetInt(lhs.Int() &^ int64(fun(env), 5602 ), 5603 ) 5604 5605 env.IP++ 5606 return env.Code[env.IP], env 5607 } 5608 case func(*Env) int16: 5609 5610 ret = func(env *Env) (Stmt, *Env) { 5611 lhs := lhsfun(env) 5612 lhs.SetInt(lhs.Int() &^ int64(fun(env), 5613 ), 5614 ) 5615 5616 env.IP++ 5617 return env.Code[env.IP], env 5618 } 5619 case func(*Env) int32: 5620 5621 ret = func(env *Env) (Stmt, *Env) { 5622 lhs := lhsfun(env) 5623 lhs.SetInt(lhs.Int() &^ int64(fun(env), 5624 ), 5625 ) 5626 5627 env.IP++ 5628 return env.Code[env.IP], env 5629 } 5630 case func(*Env) int64: 5631 5632 ret = func(env *Env) (Stmt, *Env) { 5633 lhs := lhsfun(env) 5634 lhs.SetInt(lhs.Int() &^ 5635 fun(env), 5636 ) 5637 5638 env.IP++ 5639 return env.Code[env.IP], env 5640 } 5641 case func(*Env) uint: 5642 5643 ret = func(env *Env) (Stmt, *Env) { 5644 lhs := lhsfun(env) 5645 lhs.SetUint(lhs.Uint() &^ uint64(fun(env), 5646 ), 5647 ) 5648 5649 env.IP++ 5650 return env.Code[env.IP], env 5651 } 5652 case func(*Env) uint8: 5653 5654 ret = func(env *Env) (Stmt, *Env) { 5655 lhs := lhsfun(env) 5656 lhs.SetUint(lhs.Uint() &^ uint64(fun(env), 5657 ), 5658 ) 5659 5660 env.IP++ 5661 return env.Code[env.IP], env 5662 } 5663 case func(*Env) uint16: 5664 5665 ret = func(env *Env) (Stmt, *Env) { 5666 lhs := lhsfun(env) 5667 lhs.SetUint(lhs.Uint() &^ uint64(fun(env), 5668 ), 5669 ) 5670 5671 env.IP++ 5672 return env.Code[env.IP], env 5673 } 5674 case func(*Env) uint32: 5675 5676 ret = func(env *Env) (Stmt, *Env) { 5677 lhs := lhsfun(env) 5678 lhs.SetUint(lhs.Uint() &^ uint64(fun(env), 5679 ), 5680 ) 5681 5682 env.IP++ 5683 return env.Code[env.IP], env 5684 } 5685 case func(*Env) uint64: 5686 5687 ret = func(env *Env) (Stmt, *Env) { 5688 lhs := lhsfun(env) 5689 lhs.SetUint(lhs.Uint() &^ 5690 fun(env), 5691 ) 5692 5693 env.IP++ 5694 return env.Code[env.IP], env 5695 } 5696 case func(*Env) uintptr: 5697 5698 ret = func(env *Env) (Stmt, *Env) { 5699 lhs := lhsfun(env) 5700 lhs.SetUint(lhs.Uint() &^ uint64(fun(env), 5701 ), 5702 ) 5703 5704 env.IP++ 5705 return env.Code[env.IP], env 5706 } 5707 default: 5708 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.AND_NOT, place.Type, funTypeOut(fun)) 5709 5710 } 5711 } else { 5712 switch fun := fun.(type) { 5713 case func(*Env) int: 5714 5715 ret = func(env *Env) (Stmt, *Env) { 5716 lhs := lhsfun(env) 5717 key := keyfun(env) 5718 var result int 5719 5720 if v := lhs.MapIndex(key); v != Nil { 5721 result = int(v.Int()) 5722 } 5723 result &^= fun(env) 5724 5725 lhs.SetMapIndex(key, r.ValueOf(result)) 5726 env.IP++ 5727 return env.Code[env.IP], env 5728 } 5729 case func(*Env) int8: 5730 5731 ret = func(env *Env) (Stmt, *Env) { 5732 lhs := lhsfun(env) 5733 key := keyfun(env) 5734 var result int8 5735 5736 if v := lhs.MapIndex(key); v != Nil { 5737 result = int8(v.Int()) 5738 } 5739 result &^= fun(env) 5740 5741 lhs.SetMapIndex(key, r.ValueOf(result)) 5742 env.IP++ 5743 return env.Code[env.IP], env 5744 } 5745 case func(*Env) int16: 5746 5747 ret = func(env *Env) (Stmt, *Env) { 5748 lhs := lhsfun(env) 5749 key := keyfun(env) 5750 var result int16 5751 5752 if v := lhs.MapIndex(key); v != Nil { 5753 result = int16(v.Int()) 5754 } 5755 result &^= fun(env) 5756 5757 lhs.SetMapIndex(key, r.ValueOf(result)) 5758 env.IP++ 5759 return env.Code[env.IP], env 5760 } 5761 case func(*Env) int32: 5762 5763 ret = func(env *Env) (Stmt, *Env) { 5764 lhs := lhsfun(env) 5765 key := keyfun(env) 5766 var result int32 5767 5768 if v := lhs.MapIndex(key); v != Nil { 5769 result = int32(v.Int()) 5770 } 5771 result &^= fun(env) 5772 5773 lhs.SetMapIndex(key, r.ValueOf(result)) 5774 env.IP++ 5775 return env.Code[env.IP], env 5776 } 5777 case func(*Env) int64: 5778 5779 ret = func(env *Env) (Stmt, *Env) { 5780 lhs := lhsfun(env) 5781 key := keyfun(env) 5782 var result int64 5783 5784 if v := lhs.MapIndex(key); v != Nil { 5785 result = v.Int() 5786 } 5787 result &^= fun(env) 5788 5789 lhs.SetMapIndex(key, r.ValueOf(result)) 5790 env.IP++ 5791 return env.Code[env.IP], env 5792 } 5793 case func(*Env) uint: 5794 5795 ret = func(env *Env) (Stmt, *Env) { 5796 lhs := lhsfun(env) 5797 key := keyfun(env) 5798 var result uint 5799 5800 if v := lhs.MapIndex(key); v != Nil { 5801 result = uint(v.Uint()) 5802 } 5803 result &^= fun(env) 5804 5805 lhs.SetMapIndex(key, r.ValueOf(result)) 5806 env.IP++ 5807 return env.Code[env.IP], env 5808 } 5809 case func(*Env) uint8: 5810 5811 ret = func(env *Env) (Stmt, *Env) { 5812 lhs := lhsfun(env) 5813 key := keyfun(env) 5814 var result uint8 5815 5816 if v := lhs.MapIndex(key); v != Nil { 5817 result = uint8(v.Uint()) 5818 } 5819 result &^= fun(env) 5820 5821 lhs.SetMapIndex(key, r.ValueOf(result)) 5822 env.IP++ 5823 return env.Code[env.IP], env 5824 } 5825 case func(*Env) uint16: 5826 5827 ret = func(env *Env) (Stmt, *Env) { 5828 lhs := lhsfun(env) 5829 key := keyfun(env) 5830 var result uint16 5831 5832 if v := lhs.MapIndex(key); v != Nil { 5833 result = uint16(v.Uint()) 5834 } 5835 result &^= fun(env) 5836 5837 lhs.SetMapIndex(key, r.ValueOf(result)) 5838 env.IP++ 5839 return env.Code[env.IP], env 5840 } 5841 case func(*Env) uint32: 5842 5843 ret = func(env *Env) (Stmt, *Env) { 5844 lhs := lhsfun(env) 5845 key := keyfun(env) 5846 var result uint32 5847 5848 if v := lhs.MapIndex(key); v != Nil { 5849 result = uint32(v.Uint()) 5850 } 5851 result &^= fun(env) 5852 5853 lhs.SetMapIndex(key, r.ValueOf(result)) 5854 env.IP++ 5855 return env.Code[env.IP], env 5856 } 5857 case func(*Env) uint64: 5858 5859 ret = func(env *Env) (Stmt, *Env) { 5860 lhs := lhsfun(env) 5861 key := keyfun(env) 5862 var result uint64 5863 5864 if v := lhs.MapIndex(key); v != Nil { 5865 result = v.Uint() 5866 } 5867 result &^= fun(env) 5868 5869 lhs.SetMapIndex(key, r.ValueOf(result)) 5870 env.IP++ 5871 return env.Code[env.IP], env 5872 } 5873 case func(*Env) uintptr: 5874 5875 ret = func(env *Env) (Stmt, *Env) { 5876 lhs := lhsfun(env) 5877 key := keyfun(env) 5878 var result uintptr 5879 5880 if v := lhs.MapIndex(key); v != Nil { 5881 result = uintptr(v.Uint()) 5882 } 5883 result &^= fun(env) 5884 5885 lhs.SetMapIndex(key, r.ValueOf(result)) 5886 env.IP++ 5887 return env.Code[env.IP], env 5888 } 5889 default: 5890 c.Errorf(`invalid operator %s= between <%v> and <%v>`, token.AND_NOT, place.Type, funTypeOut(fun)) 5891 5892 } 5893 } 5894 return ret 5895} 5896func (c *Comp) setPlace(place *Place, op token.Token, init *Expr) Stmt { 5897 if place.IsVar() { 5898 return c.setVar(&place.Var, op, init) 5899 } 5900 5901 t := place.Type 5902 if init.Const() { 5903 init.ConstTo(t) 5904 } else if init.Type == nil || !init.Type.AssignableTo(t) { 5905 c.Errorf("incompatible types in assignment: <%v> %s <%v>", t, op, init.Type) 5906 return nil 5907 } 5908 rt := t.ReflectType() 5909 if init.Const() { 5910 val := init.Value 5911 v := r.ValueOf(val) 5912 if v == None || v == Nil { 5913 v = r.Zero(rt) 5914 val = v.Interface() 5915 } else if v.Type() != rt { 5916 v = convert(v, rt) 5917 val = v.Interface() 5918 } 5919 switch op { 5920 case token.ASSIGN: 5921 return c.placeSetConst(place, val) 5922 case token.ADD, token.ADD_ASSIGN: 5923 return c.placeAddConst(place, val) 5924 case token.SUB, token.SUB_ASSIGN: 5925 return c.placeSubConst(place, val) 5926 case token.MUL, token.MUL_ASSIGN: 5927 return c.placeMulConst(place, val) 5928 case token.QUO, token.QUO_ASSIGN: 5929 return c.placeQuoConst(place, val) 5930 case token.REM, token.REM_ASSIGN: 5931 return c.placeRemConst(place, val) 5932 case token.AND, token.AND_ASSIGN: 5933 return c.placeAndConst(place, val) 5934 case token.OR, token.OR_ASSIGN: 5935 return c.placeOrConst(place, val) 5936 case token.XOR, token.XOR_ASSIGN: 5937 return c.placeAndConst(place, val) 5938 case token.AND_NOT, token.AND_NOT_ASSIGN: 5939 return c.placeAndnotConst(place, val) 5940 } 5941 } else { 5942 fun := init.Fun 5943 switch op { 5944 case token.ASSIGN: 5945 return c.placeSetExpr(place, fun) 5946 case token.ADD, token.ADD_ASSIGN: 5947 return c.placeAddExpr(place, fun) 5948 case token.SUB, token.SUB_ASSIGN: 5949 return c.placeSubExpr(place, fun) 5950 case token.MUL, token.MUL_ASSIGN: 5951 return c.placeMulExpr(place, fun) 5952 case token.QUO, token.QUO_ASSIGN: 5953 return c.placeQuoExpr(place, fun) 5954 case token.REM, token.REM_ASSIGN: 5955 return c.placeRemExpr(place, fun) 5956 case token.AND, token.AND_ASSIGN: 5957 return c.placeAndExpr(place, fun) 5958 case token.OR, token.OR_ASSIGN: 5959 return c.placeOrExpr(place, fun) 5960 case token.XOR, token.XOR_ASSIGN: 5961 return c.placeAndExpr(place, fun) 5962 case token.AND_NOT, token.AND_NOT_ASSIGN: 5963 return c.placeAndnotExpr(place, fun) 5964 } 5965 } 5966 c.Errorf("operator %s is not implemented", op) 5967 return nil 5968} 5969