| ... | ... |
@@ -36,12 +36,12 @@ typedef struct {
|
| 36 | 36 |
typedef struct {
|
| 37 | 37 |
Uint8 data[LENGTH]; |
| 38 | 38 |
Uint8 lambda_stack[0x100], lambda_ptr, lambda_count; |
| 39 |
+ char scope[0x40], lambda[0x10]; |
|
| 39 | 40 |
unsigned int ptr, length; |
| 40 | 41 |
Uint16 label_len, macro_len, refs_len; |
| 41 | 42 |
Label labels[0x400]; |
| 42 | 43 |
Macro macros[0x100]; |
| 43 | 44 |
Reference refs[0x800]; |
| 44 |
- char scope[0x40]; |
|
| 45 | 45 |
} Program; |
| 46 | 46 |
|
| 47 | 47 |
Program p; |
| ... | ... |
@@ -201,6 +201,15 @@ makereference(char *scope, char *label, char rune, Uint16 addr) |
| 201 | 201 |
return 1; |
| 202 | 202 |
} |
| 203 | 203 |
|
| 204 |
+static char * |
|
| 205 |
+makelambda(int id) |
|
| 206 |
+{
|
|
| 207 |
+ scpy("lambda", p.lambda, 0x07);
|
|
| 208 |
+ p.lambda[6] = '0' + (id >> 0x4); |
|
| 209 |
+ p.lambda[7] = '0' + (id & 0xf); |
|
| 210 |
+ return p.lambda; |
|
| 211 |
+} |
|
| 212 |
+ |
|
| 204 | 213 |
static int |
| 205 | 214 |
writebyte(Uint8 b) |
| 206 | 215 |
{
|
| ... | ... |
@@ -353,16 +362,12 @@ parse(char *w, FILE *f) |
| 353 | 362 |
if(!writebyte(c)) return 0; |
| 354 | 363 |
break; |
| 355 | 364 |
case '{': /* lambda start */
|
| 356 |
- char laba[8] = "lambda0\0"; |
|
| 357 | 365 |
p.lambda_stack[p.lambda_ptr++] = p.lambda_count; |
| 358 |
- laba[6] = '0' + p.lambda_count++; |
|
| 359 |
- makereference(p.scope, laba, ' ', p.ptr + 1); |
|
| 366 |
+ makereference(p.scope, makelambda(p.lambda_count++), ' ', p.ptr + 1); |
|
| 360 | 367 |
return writebyte(0x60) && writeshort(0xffff, 0); |
| 361 | 368 |
case '}': /* lambda end */ |
| 362 |
- char labb[8] = "lambda0\0"; |
|
| 363 |
- labb[6] = '0' + p.lambda_stack[--p.lambda_ptr]; |
|
| 364 |
- if(!makelabel(labb)) |
|
| 365 |
- return error("Invalid label", labb);
|
|
| 369 |
+ if(!makelabel(makelambda(p.lambda_stack[--p.lambda_ptr]))) |
|
| 370 |
+ return error("Invalid label", w);
|
|
| 366 | 371 |
return writebyte(0x6f); |
| 367 | 372 |
case '[': |
| 368 | 373 |
case ']': |