comparison lwasm/pseudo.c @ 142:697bc543368c

Implement distinction between . and * for OS9 modules
author lost@l-w.ca
date Fri, 19 Aug 2011 23:55:40 -0600
parents fe117454a1e7
children d6e9cc4484f6
comparison
equal deleted inserted replaced
141:11ebce0183a5 142:697bc543368c
492 l -> len = 0; 492 l -> len = 0;
493 l -> lint = 1; 493 l -> lint = 1;
494 l -> symset = 1; 494 l -> symset = 1;
495 } 495 }
496 } 496 }
497 497 else
498 {
499 if (l -> inmod)
500 {
501 l -> dlen = -1;
502 l -> len = 0;
503 }
504 }
498 lwasm_save_expr(l, 0, expr); 505 lwasm_save_expr(l, 0, expr);
499 } 506 }
500 507
501 RESOLVEFUNC(pseudo_resolve_rmb) 508 RESOLVEFUNC(pseudo_resolve_rmb)
502 { 509 {
503 lw_expr_t expr; 510 lw_expr_t expr;
504 511
505 if (l -> lint) 512 if (l -> lint)
506 return; 513 return;
507 514
508 if (l -> len >= 0) 515 if (l -> inmod)
509 return; 516 {
510 517 if (l -> dlen >= 0)
518 return;
519 }
520 else
521 {
522 if (l -> len >= 0)
523 return;
524 }
525
511 expr = lwasm_fetch_expr(l, 0); 526 expr = lwasm_fetch_expr(l, 0);
512 527
513 if (lw_expr_istype(expr, lw_expr_type_int)) 528 if (lw_expr_istype(expr, lw_expr_type_int))
514 { 529 {
515 l -> len = lw_expr_intval(expr); 530 if (l -> inmod)
531 l -> dlen = lw_expr_intval(expr);
532 else
533 l -> len = lw_expr_intval(expr);
516 } 534 }
517 } 535 }
518 536
519 EMITFUNC(pseudo_emit_rmb) 537 EMITFUNC(pseudo_emit_rmb)
520 { 538 {
521 if (l -> lint) 539 if (l -> lint)
522 return; 540 return;
523 541
524 if (l -> len < 0) 542 if (l -> len < 0 || l -> dlen < 0)
525 lwasm_register_error(as, l, "Expression not constant"); 543 lwasm_register_error(as, l, "Expression not constant");
526 } 544 }
527 545
528 PARSEFUNC(pseudo_parse_rmd) 546 PARSEFUNC(pseudo_parse_rmd)
529 { 547 {
551 l -> len = 0; 569 l -> len = 0;
552 l -> symset = 1; 570 l -> symset = 1;
553 l -> lint = 1; 571 l -> lint = 1;
554 } 572 }
555 } 573 }
574 else
575 {
576 if (l -> inmod)
577 {
578 l -> dlen = -1;
579 l -> len = 0;
580 }
581 }
556 lwasm_save_expr(l, 0, expr); 582 lwasm_save_expr(l, 0, expr);
557 } 583 }
558 584
559 RESOLVEFUNC(pseudo_resolve_rmd) 585 RESOLVEFUNC(pseudo_resolve_rmd)
560 { 586 {
561 lw_expr_t expr; 587 lw_expr_t expr;
562 588
563 if (l -> lint) 589 if (l -> lint)
564 return; 590 return;
565 591
566 if (l -> len >= 0) 592 if (l -> inmod)
567 return; 593 {
594 if (l -> dlen >= 0)
595 return;
596 }
597 else
598 {
599 if (l -> len >= 0)
600 return;
601 }
568 602
569 expr = lwasm_fetch_expr(l, 0); 603 expr = lwasm_fetch_expr(l, 0);
570 604
571 if (lw_expr_istype(expr, lw_expr_type_int)) 605 if (lw_expr_istype(expr, lw_expr_type_int))
572 { 606 {
573 l -> len = lw_expr_intval(expr) * 2; 607 if (l -> inmod)
608 l -> dlen = lw_expr_intval(expr) * 2;
609 else
610 l -> len = lw_expr_intval(expr) * 2;
574 } 611 }
575 } 612 }
576 613
577 EMITFUNC(pseudo_emit_rmd) 614 EMITFUNC(pseudo_emit_rmd)
578 { 615 {
579 if (l -> lint) 616 if (l -> lint)
580 return; 617 return;
581 618
582 if (l -> len < 0) 619 if (l -> len < 0 || l -> dlen < 0)
583 lwasm_register_error(as, l, "Expression not constant"); 620 lwasm_register_error(as, l, "Expression not constant");
584 } 621 }
585 622
586 623
587 PARSEFUNC(pseudo_parse_rmq) 624 PARSEFUNC(pseudo_parse_rmq)
609 l -> len = 0; 646 l -> len = 0;
610 l -> symset = 1; 647 l -> symset = 1;
611 l -> lint = 1; 648 l -> lint = 1;
612 } 649 }
613 } 650 }
614 651 else
652 {
653 if (as -> inmod)
654 {
655 l -> dlen = -1;
656 l -> len = 0;
657 }
658 }
615 lwasm_save_expr(l, 0, expr); 659 lwasm_save_expr(l, 0, expr);
616 } 660 }
617 661
618 RESOLVEFUNC(pseudo_resolve_rmq) 662 RESOLVEFUNC(pseudo_resolve_rmq)
619 { 663 {
620 lw_expr_t expr; 664 lw_expr_t expr;
621 665
622 if (l -> lint) 666 if (l -> lint)
623 return; 667 return;
624 668
625 if (l -> len >= 0) 669 if (l -> inmod)
626 return; 670 {
671 if (l -> dlen >= 0)
672 return;
673 }
674 else
675 {
676 if (l -> len >= 0)
677 return;
678 }
627 679
628 expr = lwasm_fetch_expr(l, 0); 680 expr = lwasm_fetch_expr(l, 0);
629 681
630 if (lw_expr_istype(expr, lw_expr_type_int)) 682 if (lw_expr_istype(expr, lw_expr_type_int))
631 { 683 {
632 l -> len = lw_expr_intval(expr) * 4; 684 if (l -> inmod)
685 l -> dlen = lw_expr_intval(expr) * 4;
686 else
687 l -> len = lw_expr_intval(expr) * 4;
633 } 688 }
634 } 689 }
635 690
636 EMITFUNC(pseudo_emit_rmq) 691 EMITFUNC(pseudo_emit_rmq)
637 { 692 {
638 if (l -> lint) 693 if (l -> lint)
639 return; 694 return;
640 695
641 if (l -> len < 0) 696 if (l -> len < 0 || l -> dlen < 0)
642 lwasm_register_error(as, l, "Expression not constant"); 697 lwasm_register_error(as, l, "Expression not constant");
643 } 698 }
644 699
645 700
646 PARSEFUNC(pseudo_parse_zmq) 701 PARSEFUNC(pseudo_parse_zmq)
781 { 836 {
782 lwasm_register_error(as, l, "Bad operand"); 837 lwasm_register_error(as, l, "Bad operand");
783 return; 838 return;
784 } 839 }
785 840
786 lw_expr_destroy(l -> addr); 841 lw_expr_destroy(l -> daddr);
787 l -> addr = e; 842 l -> daddr = e;
843
844 if (l -> inmod == 0)
845 {
846 lw_expr_destroy(l -> addr);
847 l -> addr = e;
848 }
788 l -> len = 0; 849 l -> len = 0;
789 } 850 }
790 851
791 PARSEFUNC(pseudo_parse_equ) 852 PARSEFUNC(pseudo_parse_equ)
792 { 853 {