about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--002test.cc2
-rw-r--r--041name.cc24
-rw-r--r--043space.cc3
-rw-r--r--070display.cc2
-rw-r--r--edit.mu26
5 files changed, 33 insertions, 24 deletions
diff --git a/002test.cc b/002test.cc
index a35f95bf..d59309a2 100644
--- a/002test.cc
+++ b/002test.cc
@@ -54,7 +54,7 @@ if (Run_tests) {
   time_t t; time(&t);
   cerr << "C tests: " << ctime(&t);
   for (size_t i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) {
-//?     cerr << i << '\n'; //? 1
+//?     cerr << i << '\n'; //? 2
     run_test(i);
   }
   // End Tests
diff --git a/041name.cc b/041name.cc
index 20668ab5..e2c1d940 100644
--- a/041name.cc
+++ b/041name.cc
@@ -69,6 +69,8 @@ void transform_names(const recipe_number r) {
 void check_metadata(map<string, vector<type_number> >& metadata, const reagent& x, const recipe_number r) {
   if (is_literal(x)) return;
   if (is_raw(x)) return;
+  // if you use raw locations you're probably doing something unsafe
+  if (is_integer(x.name)) return;
   if (metadata.find(x.name) == metadata.end())
     metadata[x.name] = x.types;
   if (metadata[x.name] != x.types)
@@ -224,11 +226,12 @@ if (inst.operation == Recipe_number["get"]
   assert(SIZE(inst.ingredients) >= 2);
 //?   cout << inst.ingredients.at(1).to_string() << '\n'; //? 1
   assert(is_literal(inst.ingredients.at(1)));
-  if (inst.ingredients.at(1).name.find_first_not_of("0123456789") == string::npos) continue;
-  // since first non-address in base type must be a container, we don't have to canonize
-  type_number base_type = skip_addresses(inst.ingredients.at(0).types);
-  inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name));
-  trace("name") << "element " << inst.ingredients.at(1).name << " of type " << Type[base_type].name << " is at offset " << inst.ingredients.at(1).value;
+  if (inst.ingredients.at(1).name.find_first_not_of("0123456789") != string::npos) {
+    // since first non-address in base type must be a container, we don't have to canonize
+    type_number base_type = skip_addresses(inst.ingredients.at(0).types);
+    inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name));
+    trace("name") << "element " << inst.ingredients.at(1).name << " of type " << Type[base_type].name << " is at offset " << inst.ingredients.at(1).value;
+  }
 }
 
 //: this test is actually illegal so can't call run
@@ -260,9 +263,10 @@ if (inst.operation == Recipe_number["maybe-convert"]) {
   // at least 2 args, and second arg is offset
   assert(SIZE(inst.ingredients) >= 2);
   assert(is_literal(inst.ingredients.at(1)));
-  if (inst.ingredients.at(1).name.find_first_not_of("0123456789") == string::npos) continue;
-  // since first non-address in base type must be an exclusive container, we don't have to canonize
-  type_number base_type = skip_addresses(inst.ingredients.at(0).types);
-  inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name));
-  trace("name") << "variant " << inst.ingredients.at(1).name << " of type " << Type[base_type].name << " has tag " << inst.ingredients.at(1).value;
+  if (inst.ingredients.at(1).name.find_first_not_of("0123456789") != string::npos) {
+    // since first non-address in base type must be an exclusive container, we don't have to canonize
+    type_number base_type = skip_addresses(inst.ingredients.at(0).types);
+    inst.ingredients.at(1).set_value(find_element_name(base_type, inst.ingredients.at(1).name));
+    trace("name") << "variant " << inst.ingredients.at(1).name << " of type " << Type[base_type].name << " has tag " << inst.ingredients.at(1).value;
+  }
 }
diff --git a/043space.cc b/043space.cc
index ddff7a4a..52c92f87 100644
--- a/043space.cc
+++ b/043space.cc
@@ -55,7 +55,8 @@ reagent absolutize(reagent x) {
 //?   cout << is_raw(x) << '\n'; //? 1
   if (is_raw(x) || is_dummy(x)) return x;
 //?   cout << "not raw: " << x.to_string() << '\n'; //? 1
-  assert(x.initialized);
+  if (!x.initialized)
+    raise << current_instruction().to_string() << ": reagent not initialized: " << x.to_string() << die();
   reagent r = x;
   r.set_value(address(r.value, space_base(r)));
 //?   cout << "after absolutize: " << r.value << '\n'; //? 1
diff --git a/070display.cc b/070display.cc
index 07656c7d..9cec82ca 100644
--- a/070display.cc
+++ b/070display.cc
@@ -271,6 +271,8 @@ case CHECK_FOR_INTERACTION: {
     break;
   }
   if (event_type == TB_EVENT_MOUSE) {
+//?     tb_shutdown(); //? 1
+//?     cerr << "AAA\n"; //? 1
     products.at(0).push_back(/*touch event*/2);
     products.at(0).push_back(event.key);  // which button, etc.
     products.at(0).push_back(event.y);  // row
diff --git a/edit.mu b/edit.mu
index 214925ea..b04b9645 100644
--- a/edit.mu
+++ b/edit.mu
@@ -33,12 +33,12 @@ scenario editor-initially-prints-string-to-screen [
 ## text to the screen.
 
 container editor-data [
-  # doubly linked list of characters
+  # doubly linked list of characters (head contains a special marker)
   data:address:duplex-list
   # location of top-left of screen inside data (scrolling)
   top-of-screen:address:duplex-list
-  # location of cursor inside data
-  cursor:address:duplex-list
+  # location before cursor inside data
+  before-cursor:address:duplex-list
 
   screen:address:screen
   # raw bounds of display area on screen
@@ -65,6 +65,8 @@ recipe new-editor [
   right:number <- next-ingredient
   right:number <- subtract right:number, 1:literal
   result:address:editor-data <- new editor-data:type
+  d:address:address:duplex-list <- get-address result:address:editor-data/deref, data:offset
+  d:address:address:duplex-list/deref <- push-duplex 167:literal/§, 0:literal/tail
   # initialize screen-related fields
   sc:address:address:screen <- get-address result:address:editor-data/deref, screen:offset
   sc:address:address:screen/deref <- copy screen:address
@@ -90,10 +92,7 @@ recipe new-editor [
   # s is guaranteed to have at least one character, so initialize result's
   # duplex-list
   init:address:address:duplex-list <- get-address result:address:editor-data/deref, top-of-screen:offset
-  init:address:address:duplex-list/deref <- copy 0:literal
-  c:character <- index s:address:array:character/deref, idx:number
-  idx:number <- add idx:number, 1:literal
-  init:address:address:duplex-list/deref <- push c:character, init:address:address:duplex-list/deref
+  init:address:address:duplex-list/deref <- copy d:address:address:duplex-list/deref
   curr:address:duplex-list <- copy init:address:address:duplex-list/deref
   # now we can start appending the rest, character by character
   {
@@ -111,7 +110,7 @@ recipe new-editor [
     loop
   }
   # initialize cursor to top of screen
-  y:address:address:duplex-list <- get-address result:address:editor-data/deref, cursor:offset
+  y:address:address:duplex-list <- get-address result:address:editor-data/deref, before-cursor:offset
   y:address:address:duplex-list/deref <- copy init:address:address:duplex-list/deref
   # perform initial rendering to screen
   bottom:address:number <- get-address result:address:editor-data/deref, bottom:offset
@@ -126,9 +125,9 @@ scenario editor-initializes-without-data [
     2:editor-data <- copy 1:address:editor-data/deref
   ]
   memory-should-contain [
-    2 <- 0  # data
+    # 2 <- just the § marker
     3 <- 0  # pointer into data to top of screen
-    4 <- 0  # pointer into data to cursor
+    # 4 (before cursor) <- the § marker
     # 5 <- screen
     6 <- 1  # top
     7 <- 2  # left
@@ -154,6 +153,7 @@ recipe render [
   right:number <- next-ingredient
   # traversing editor
   curr:address:duplex-list <- get editor:address:editor-data/deref, top-of-screen:offset
+  curr:address:duplex-list <- next-duplex curr:address:duplex-list
   # traversing screen
   row:number <- copy top:number
   column:number <- copy left:number
@@ -277,12 +277,14 @@ recipe event-loop [
     break-if quit?:boolean  # only in tests
     trace [app], [next-event]
     {
-      t:address:touch-event <- maybe-convert e:event, touch:variant
+      t:address:touch-event <- maybe-convert e:event, 2:variant
       break-unless t:address:touch-event
       editor:address:editor-data <- move-cursor-in-editor editor:address:editor-data, t:address:touch-event/deref
       loop +next-event:label
     }
+    $print e:event
     c:address:character <- maybe-convert e:event, text:variant
+    close-console
     assert c:address:character, [event was of unknown type; neither keyboard nor mouse]
     loop
   }
@@ -297,7 +299,7 @@ recipe move-cursor-in-editor [
   column:address:number <- get-address editor:address:editor-data/deref, cursor-column:offset
   column:address:number/deref <- get t:touch-event, column:offset
   # clear cursor pointer; will be set correctly during render
-  cursor:address:address:duplex-list <- get-address editor:address:editor-data/deref, cursor:offset
+  cursor:address:address:duplex-list <- get-address editor:address:editor-data/deref, before-cursor:offset
   cursor:address:address:duplex-list/deref <- copy 0:literal
 ]
 
1' href='#n551'>551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936