Free Hero Mesh

Check-in [9930393c98]
Login
This is a mirror of the main repository for Free Hero Mesh. New tickets and changes will not be accepted at this mirror.
Overview
Comment:Implement the / and ,/ commands in pattern blocks.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9930393c98ff63d1728e6bc3363ec6b6c8c89404
User & Date: user on 2023-08-04 18:15:29
Other Links: manifest | tags
Context
2023-08-04
23:03
Implement ,if ,while ,until instructions (conditions with keeping the value in the stack if it is nonzero) check-in: 41eca04785 user: user tags: trunk
18:15
Implement the / and ,/ commands in pattern blocks. check-in: 9930393c98 user: user tags: trunk
2023-08-01
19:50
The portalled Matrix chat is no longer available, so change the documentation to mention that it is not available. check-in: a7a889509e user: user tags: trunk
Changes

Modified class.c from [3051994863] to [133b55b71e].

1348
1349
1350
1351
1352
1353
1354
1355

1356
1357
1358
1359
1360
1361
1362
1348
1349
1350
1351
1352
1353
1354

1355
1356
1357
1358
1359
1360
1361
1362







-
+







      switch(tokenv) {
        case OP_ADD: case OP_CLIMB: case OP_HEIGHT:
        case OP_LOC: case OP_MARK: case OP_SUB:
        case OP_QUEEN: case OP_ROOK: case OP_BISHOP:
        case OP_DIR: case OP_DIR_C: case OP_DIR_E: case OP_DIR_EC:
        case OP_OBJTOPAT: case OP_OBJBOTTOMAT: case OP_CUT: case OP_MUL:
        case OP_OBJABOVE: case OP_OBJBELOW: case OP_TRACE: case OP_NEXT:
        case OP_IMAGE: case OP_IMAGE_C:
        case OP_IMAGE: case OP_IMAGE_C: case OP_DIV: case OP_DIV_C:
        case 0x0200 ... 0x02FF: // message
        case 0x4000 ... 0x7FFF: // class
        case 0xC000 ... 0xFFFF: // message
          cl->codes[ptr++]=tokenv;
          break;
        case OP_BEGIN: case OP_IF:
          if(depth==31) ParseError("Too much pattern nesting\n");

Modified class.doc from [c053f49e1f] to [c2dbc07def].

2856
2857
2858
2859
2860
2861
2862











2863
2864
2865
2866
2867
2868
2869
2856
2857
2858
2859
2860
2861
2862
2863
2864
2865
2866
2867
2868
2869
2870
2871
2872
2873
2874
2875
2876
2877
2878
2879
2880







+
+
+
+
+
+
+
+
+
+
+








-
  Push zero to the stack.

*
  Update the current choice point with the location and direction.

/
  Succeeds only if the pattern prior to this command succeeds but the
  pattern after this command (which still has the same state as the
  prior pattern) fails. This should not be used inside of loops and
  should not be used in a (P*) or (,P*) or (=P*) block. If this command
  occurs more than once, then the most recent / that is successfully
  matched determines the return value if the final match fails.

,/
  Undoes the effect of the / command.

_
  Push a mark to the stack.

again
  End a block with begin or if, allowing it to occur more than once; it
  is repeated until it no longer matches. If the first word is begin,
  then it must match at least once; if it is if, then it can match zero

Modified exec.c from [40900c6cd3] to [fa70af0dc1].

2473
2474
2475
2476
2477
2478
2479

2480
2481
2482
2483
2484
2485
2486
2473
2474
2475
2476
2477
2478
2479
2480
2481
2482
2483
2484
2485
2486
2487







+







} ChoicePoint;

#define MAXCHOICE 80
static Uint32 v_pattern(Uint16*code,int ptr,Uint32 obj,char all) {
  Uint8 x=objects[obj]->x;
  Uint8 y=objects[obj]->y;
  Uint8 d=objects[obj]->dir;
  Uint32 un=VOIDLINK;
  Uint32 n=VOIDLINK;
  Uint32 m;
  Uint16 g;
  Value v;
  ChoicePoint cp[MAXCHOICE];
  Uint8 cpi=0;
  Uint16 ccl=objects[obj]->class;
2597
2598
2599
2600
2601
2602
2603







2604
2605
2606
2607
2608
2609
2610
2598
2599
2600
2601
2602
2603
2604
2605
2606
2607
2608
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618







+
+
+
+
+
+
+







      objects[obj]->dir=d;
      break;
    case OP_DIR_EC:
      if(n==VOIDLINK) Throw("No object specified in pattern");
      changed=1;
      objects[n]->dir=d;
      break;
    case OP_DIV:
      un=(n==VOIDLINK?obj_bottom_at(x,y):n);
      if(un==VOIDLINK) un=obj;
      break;
    case OP_DIV_C:
      un=VOIDLINK;
      break;
    case OP_ELSE:
      ptr--;
      while(code[ptr]==OP_ELSE) ptr=code[ptr+2];
      break;
    case OP_FUNCTION:
      StackReq(0,2);
      Push(OVALUE(n));
2708
2709
2710
2711
2712
2713
2714
2715

2716


2717
2718
2719
2720
2721
2722
2723
2716
2717
2718
2719
2720
2721
2722

2723
2724
2725
2726
2727
2728
2729
2730
2731
2732
2733







-
+

+
+







      break;
    case OP_RET:
      if(all) {
        if(vstackptr>=VSTACKSIZE-1) Throw("Stack overflow");
        if(n==VOIDLINK) n=obj_bottom_at(x,y);
        Push(OVALUE(n));
        goto fail;
      } else {
      } else if(un==VOIDLINK) {
        return n==VOIDLINK?obj_bottom_at(x,y):n;
      } else {
        return VOIDLINK;
      }
      break;
    case OP_ROOK:
      if(cpi>=MAXCHOICE-4) Throw("Choice overflow");
      d=0;
      cpi+=3;
      cp[cpi].x=x;
2748
2749
2750
2751
2752
2753
2754
2755

2756
2757
2758
2759
2760
2761
2762
2758
2759
2760
2761
2762
2763
2764

2765
2766
2767
2768
2769
2770
2771
2772







-
+







  }
  goto again;
  fail:
  if(!all) {
    if(vstackptr<cp->depth) Throw("Stack underflow in pattern matching");
    vstackptr=cp[cpi].depth;
  }
  if(!cpi) return VOIDLINK;
  if(!cpi) return un;
  x=cp[cpi].x;
  y=cp[cpi].y;
  d=cp[cpi].dir;
  ptr=cp[cpi].ptr;
  n=VOIDLINK;
  cpi--;
  goto again;