Free Hero Mesh

Check-in [c43bc33f91]
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:Add function calls in pattern matching.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: c43bc33f91b90d04c6998413b1fe079e7da45bdf
User & Date: user on 2021-09-19 01:48:42
Other Links: manifest | tags
Context
2021-09-19
06:08
Implement the INVENTORY virtual table. check-in: 84ff96ae0f user: user tags: trunk
01:48
Add function calls in pattern matching. check-in: c43bc33f91 user: user tags: trunk
2021-09-18
22:37
Add 'am' editor command to make MRU item by SQL results check-in: 16400482c5 user: user tags: trunk
Changes

Modified class.c from [8944449118] to [1bc0783ffd].

1181
1182
1183
1184
1185
1186
1187



1188
1189
1190
1191
1192
1193
1194
          if(!x) ParseError("User flag ^%s not defined\n",tokenstr);
          if(Tokenf(TF_COMMA)) x+=0x100;
          if(Tokenf(TF_EQUAL)) ParseError("Improper token in pattern\n");
          cl->codes[ptr++]=x;
          break;
        default: ParseError("Improper token in pattern\n");
      }



    } else if(tokent==TF_OPEN) {
      nxttok();
      if(Tokenf(TF_MACRO) || !Tokenf(TF_NAME)) ParseError("Improper token in pattern\n");
      switch(tokenv) {
        case OP_HEIGHT: case OP_CLIMB:
          cl->codes[ptr++]=tokenv+0x0800; // OP_HEIGHT_C or OP_CLIMB_C
          nxttok();







>
>
>







1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
          if(!x) ParseError("User flag ^%s not defined\n",tokenstr);
          if(Tokenf(TF_COMMA)) x+=0x100;
          if(Tokenf(TF_EQUAL)) ParseError("Improper token in pattern\n");
          cl->codes[ptr++]=x;
          break;
        default: ParseError("Improper token in pattern\n");
      }
    } else if(Tokenf(TF_FUNCTION)) {
      cl->codes[ptr++]=OP_FUNCTION;
      cl->codes[ptr++]=tokenv&0x3FFF;
    } else if(tokent==TF_OPEN) {
      nxttok();
      if(Tokenf(TF_MACRO) || !Tokenf(TF_NAME)) ParseError("Improper token in pattern\n");
      switch(tokenv) {
        case OP_HEIGHT: case OP_CLIMB:
          cl->codes[ptr++]=tokenv+0x0800; // OP_HEIGHT_C or OP_CLIMB_C
          nxttok();

Modified class.doc from [88620e5545] to [8288aabc43].

2345
2346
2347
2348
2349
2350
2351








2352
2353
2354
2355
2356
2357
2358

<dir>
  Move in the specified direction. (This does not move any objects; it
  only moves the cursor for pattern matching.) The direction can be
  relative to the current direction (initially the Dir variable of the
  origin object) or absolute.









<message>
  Send the message to all objects at the current location. From is the
  position from which pattern matching started. Arg1 is the direction.
  Arg2 is the currently matched object (which may be zero). If the
  return value is zero, it continues normally; if one, the match fails;
  if two, it continues without sending more messages at this location;
  if an object, sets the matched object and current location.







>
>
>
>
>
>
>
>







2345
2346
2347
2348
2349
2350
2351
2352
2353
2354
2355
2356
2357
2358
2359
2360
2361
2362
2363
2364
2365
2366

<dir>
  Move in the specified direction. (This does not move any objects; it
  only moves the cursor for pattern matching.) The direction can be
  relative to the current direction (initially the Dir variable of the
  origin object) or absolute.

<function>
  Call a user-defined function, which should be ( obj dir -- result ),
  and Self is the position from which the current matching started.
  The obj is the currently matched object (which may be zero), and the
  dir is the current direction. If the result is a number, then it sets
  the direction; if a object, sets the current object and the current
  location at that object's location; if a mark, the match fails.

<message>
  Send the message to all objects at the current location. From is the
  position from which pattern matching started. Arg1 is the direction.
  Arg2 is the currently matched object (which may be zero). If the
  return value is zero, it continues normally; if one, the match fails;
  if two, it continues without sending more messages at this location;
  if an object, sets the matched object and current location.

Modified exec.c from [a24f1b5e8f] to [534ed95552].

65
66
67
68
69
70
71

72
73
74
75
76
77
78
#define Push(x) (vstack[vstackptr++]=(x))
#define Pop() (vstack[--vstackptr])

// For arrival/departure masks
#define Xbit(a) ((a)%5-2)
#define Ybit(a) (2-(a)/5)


static Value send_message(Uint32 from,Uint32 to,Uint16 msg,Value arg1,Value arg2,Value arg3);
static Uint32 broadcast(Uint32 from,int c,Uint16 msg,Value arg1,Value arg2,Value arg3,Uint8 s);
static Value destroy(Uint32 from,Uint32 to,Uint32 why);

static const Sint8 x_delta[8]={1,1,0,-1,-1,-1,0,1};
static const Sint8 y_delta[8]={0,-1,-1,-1,0,1,1,1};








>







65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#define Push(x) (vstack[vstackptr++]=(x))
#define Pop() (vstack[--vstackptr])

// For arrival/departure masks
#define Xbit(a) ((a)%5-2)
#define Ybit(a) (2-(a)/5)

static void execute_program(Uint16*code,int ptr,Uint32 obj);
static Value send_message(Uint32 from,Uint32 to,Uint16 msg,Value arg1,Value arg2,Value arg3);
static Uint32 broadcast(Uint32 from,int c,Uint16 msg,Value arg1,Value arg2,Value arg3,Uint8 s);
static Value destroy(Uint32 from,Uint32 to,Uint32 why);

static const Sint8 x_delta[8]={1,1,0,-1,-1,-1,0,1};
static const Sint8 y_delta[8]={0,-1,-1,-1,0,1,1,1};

1854
1855
1856
1857
1858
1859
1860



















1861
1862
1863
1864
1865
1866
1867
      if(n==VOIDLINK) Throw("No object specified in pattern");
      changed=1;
      objects[n]->dir=d;
      break;
    case OP_ELSE:
      ptr--;
      while(code[ptr]==OP_ELSE) ptr=code[ptr+2];



















      break;
    case OP_HEIGHT:
      if(playfield[x+y*64-65]==VOIDLINK || height_at(x,y)<=objects[obj]->climb) goto fail;
      break;
    case OP_HEIGHT_C:
      g=code[ptr++];
      if(playfield[x+y*64-65]==VOIDLINK || height_at(x,y)<=g) goto fail;







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
      if(n==VOIDLINK) Throw("No object specified in pattern");
      changed=1;
      objects[n]->dir=d;
      break;
    case OP_ELSE:
      ptr--;
      while(code[ptr]==OP_ELSE) ptr=code[ptr+2];
      break;
    case OP_FUNCTION:
      StackReq(0,2);
      Push(OVALUE(n));
      Push(NVALUE(d));
      execute_program(classes[0]->codes,functions[code[ptr++]],obj);
      StackReq(1,0);
      v=Pop();
      if(v.t==TY_NUMBER) {
        d=v.u&7;
      } else if(v.t==TY_MARK) {
        goto fail;
      } else if(v.t>TY_MAXTYPE) {
        n=v_object(v);
        x=objects[n]->x;
        y=objects[n]->y;
      } else {
        Throw("Type mismatch");
      }
      break;
    case OP_HEIGHT:
      if(playfield[x+y*64-65]==VOIDLINK || height_at(x,y)<=objects[obj]->climb) goto fail;
      break;
    case OP_HEIGHT_C:
      g=code[ptr++];
      if(playfield[x+y*64-65]==VOIDLINK || height_at(x,y)<=g) goto fail;