diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-04-21 15:29:53 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2023-04-21 15:29:53 -0300 |
commit | 9f7183c280f310c0d0b49b7b9c3b8eac297fafa7 (patch) | |
tree | 503392ee1a94f6446151a0b90babe8235efdb573 /lpcode.c | |
parent | 7b42a7b13f9c6655dfa7c5951de46dcf0642b0a6 (diff) | |
download | lpeg-9f7183c280f310c0d0b49b7b9c3b8eac297fafa7.tar.gz lpeg-9f7183c280f310c0d0b49b7b9c3b8eac297fafa7.tar.bz2 lpeg-9f7183c280f310c0d0b49b7b9c3b8eac297fafa7.zip |
Field Instruction.key put inside a union
So that we can get its space for other uses, if needed.
Diffstat (limited to 'lpcode.c')
-rw-r--r-- | lpcode.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -499,7 +499,7 @@ static int nextinstruction (CompileState *compst) { | |||
499 | static int addinstruction (CompileState *compst, Opcode op, int aux) { | 499 | static int addinstruction (CompileState *compst, Opcode op, int aux) { |
500 | int i = nextinstruction(compst); | 500 | int i = nextinstruction(compst); |
501 | getinstr(compst, i).i.code = op; | 501 | getinstr(compst, i).i.code = op; |
502 | getinstr(compst, i).i.aux = aux; | 502 | getinstr(compst, i).i.aux1 = aux; |
503 | return i; | 503 | return i; |
504 | } | 504 | } |
505 | 505 | ||
@@ -528,8 +528,8 @@ static void codeutfr (CompileState *compst, TTree *tree) { | |||
528 | int to = sib1(tree)->u.n; | 528 | int to = sib1(tree)->u.n; |
529 | assert(sib1(tree)->tag == TXInfo); | 529 | assert(sib1(tree)->tag == TXInfo); |
530 | getinstr(compst, i + 1).offset = tree->u.n; | 530 | getinstr(compst, i + 1).offset = tree->u.n; |
531 | getinstr(compst, i).i.aux = to & 0xff; | 531 | getinstr(compst, i).i.aux1 = to & 0xff; |
532 | getinstr(compst, i).i.key = to >> 8; | 532 | getinstr(compst, i).i.aux2.key = to >> 8; |
533 | } | 533 | } |
534 | 534 | ||
535 | 535 | ||
@@ -542,7 +542,7 @@ static void codeutfr (CompileState *compst, TTree *tree) { | |||
542 | static int addinstcap (CompileState *compst, Opcode op, int cap, int key, | 542 | static int addinstcap (CompileState *compst, Opcode op, int cap, int key, |
543 | int aux) { | 543 | int aux) { |
544 | int i = addinstruction(compst, op, joinkindoff(cap, aux)); | 544 | int i = addinstruction(compst, op, joinkindoff(cap, aux)); |
545 | getinstr(compst, i).i.key = key; | 545 | getinstr(compst, i).i.aux2.key = key; |
546 | return i; | 546 | return i; |
547 | } | 547 | } |
548 | 548 | ||
@@ -575,7 +575,7 @@ static void jumptohere (CompileState *compst, int instruction) { | |||
575 | */ | 575 | */ |
576 | static void codechar (CompileState *compst, int c, int tt) { | 576 | static void codechar (CompileState *compst, int c, int tt) { |
577 | if (tt >= 0 && getinstr(compst, tt).i.code == ITestChar && | 577 | if (tt >= 0 && getinstr(compst, tt).i.code == ITestChar && |
578 | getinstr(compst, tt).i.aux == c) | 578 | getinstr(compst, tt).i.aux1 == c) |
579 | addinstruction(compst, IAny, 0); | 579 | addinstruction(compst, IAny, 0); |
580 | else | 580 | else |
581 | addinstruction(compst, IChar, c); | 581 | addinstruction(compst, IChar, c); |
@@ -636,7 +636,7 @@ static int codetestset (CompileState *compst, Charset *cs, int e) { | |||
636 | case IAny: return addoffsetinst(compst, ITestAny); | 636 | case IAny: return addoffsetinst(compst, ITestAny); |
637 | case IChar: { | 637 | case IChar: { |
638 | int i = addoffsetinst(compst, ITestChar); | 638 | int i = addoffsetinst(compst, ITestChar); |
639 | getinstr(compst, i).i.aux = c; | 639 | getinstr(compst, i).i.aux1 = c; |
640 | return i; | 640 | return i; |
641 | } | 641 | } |
642 | case ISet: { | 642 | case ISet: { |
@@ -862,7 +862,7 @@ static void correctcalls (CompileState *compst, int *positions, | |||
862 | Instruction *code = compst->p->code; | 862 | Instruction *code = compst->p->code; |
863 | for (i = from; i < to; i += sizei(&code[i])) { | 863 | for (i = from; i < to; i += sizei(&code[i])) { |
864 | if (code[i].i.code == IOpenCall) { | 864 | if (code[i].i.code == IOpenCall) { |
865 | int n = code[i].i.key; /* rule number */ | 865 | int n = code[i].i.aux2.key; /* rule number */ |
866 | int rule = positions[n]; /* rule position */ | 866 | int rule = positions[n]; /* rule position */ |
867 | assert(rule == from || code[rule - 1].i.code == IRet); | 867 | assert(rule == from || code[rule - 1].i.code == IRet); |
868 | if (code[finaltarget(code, i + 2)].i.code == IRet) /* call; ret ? */ | 868 | if (code[finaltarget(code, i + 2)].i.code == IRet) /* call; ret ? */ |
@@ -904,7 +904,7 @@ static void codegrammar (CompileState *compst, TTree *grammar) { | |||
904 | static void codecall (CompileState *compst, TTree *call) { | 904 | static void codecall (CompileState *compst, TTree *call) { |
905 | int c = addoffsetinst(compst, IOpenCall); /* to be corrected later */ | 905 | int c = addoffsetinst(compst, IOpenCall); /* to be corrected later */ |
906 | assert(sib1(sib2(call))->tag == TXInfo); | 906 | assert(sib1(sib2(call))->tag == TXInfo); |
907 | getinstr(compst, c).i.key = sib1(sib2(call))->u.n; /* rule number */ | 907 | getinstr(compst, c).i.aux2.key = sib1(sib2(call))->u.n; /* rule number */ |
908 | } | 908 | } |
909 | 909 | ||
910 | 910 | ||