aboutsummaryrefslogtreecommitdiff
path: root/lpcode.c
diff options
context:
space:
mode:
Diffstat (limited to 'lpcode.c')
-rw-r--r--lpcode.c24
1 files changed, 3 insertions, 21 deletions
diff --git a/lpcode.c b/lpcode.c
index 9fa8867..50e6764 100644
--- a/lpcode.c
+++ b/lpcode.c
@@ -11,7 +11,7 @@
11 11
12#include "lptypes.h" 12#include "lptypes.h"
13#include "lpcode.h" 13#include "lpcode.h"
14#include "lpprint.h" /* labeled failure */ 14
15 15
16/* signals a "no-instruction */ 16/* signals a "no-instruction */
17#define NOINST -1 17#define NOINST -1
@@ -492,25 +492,10 @@ static int addinstruction (CompileState *compst, Opcode op, int aux) {
492static int addoffsetinst (CompileState *compst, Opcode op) { 492static int addoffsetinst (CompileState *compst, Opcode op) {
493 int i = addinstruction(compst, op, 0); /* instruction */ 493 int i = addinstruction(compst, op, 0); /* instruction */
494 addinstruction(compst, (Opcode)0, 0); /* open space for offset */ 494 addinstruction(compst, (Opcode)0, 0); /* open space for offset */
495 assert(op == ITestSet || sizei(&getinstr(compst, i)) == 2 || op == ILabChoice); /* labeled failure */ 495 assert(op == ITestSet || sizei(&getinstr(compst, i)) == 2);
496 return i; 496 return i;
497} 497}
498 498
499/* labeled failure begin */
500static int addthrowinstruction (CompileState *compst, byte lab) {
501 return addinstruction(compst, IThrow, lab);
502}
503
504/*static int addoffsetlabinst (CompileState *compst, const byte *cs) {
505 int j;
506 int i = addinstruction(compst, ILabChoice, 0);
507 addinstruction(compst, (Opcode)0, 0);
508 j = nextinstruction(compst);
509 getinstr(compst, j).labels = cs;
510
511 return i;
512}*/
513/* labeled failure end */
514 499
515/* 500/*
516** Set the offset of an instruction 501** Set the offset of an instruction
@@ -720,17 +705,14 @@ static void codelabchoice (CompileState *compst, TTree *p1, TTree *p2, int opt,
720 int emptyp2 = (p2->tag == TTrue); 705 int emptyp2 = (p2->tag == TTrue);
721 int pcommit; 706 int pcommit;
722 int test = NOINST; 707 int test = NOINST;
723 /* int pchoice = addoffsetlabinst(compst, cs);*/
724 int pchoice = addoffsetinst(compst, ILabChoice); 708 int pchoice = addoffsetinst(compst, ILabChoice);
725 addcharset(compst, cs); 709 addcharset(compst, cs);
726 codegen(compst, p1, emptyp2, test, fullset); 710 codegen(compst, p1, emptyp2, test, fullset);
727 pcommit = addoffsetinst(compst, ICommit); 711 pcommit = addoffsetinst(compst, ICommit);
728 jumptohere(compst, pchoice); 712 jumptohere(compst, pchoice);
729 jumptohere(compst, test); 713 jumptohere(compst, test);
730 /*printf("vou codificar codelabchoice %d\n", p2->tag);*/
731 codegen(compst, p2, opt, NOINST, fl); 714 codegen(compst, p2, opt, NOINST, fl);
732 jumptohere(compst, pcommit); 715 jumptohere(compst, pcommit);
733 /*printf("fim codelabchoice\n");*/
734} 716}
735/* labeled failure end */ 717/* labeled failure end */
736 718
@@ -962,7 +944,7 @@ static void codegen (CompileState *compst, TTree *tree, int opt, int tt,
962 tree = sib2(tree); goto tailcall; 944 tree = sib2(tree); goto tailcall;
963 } 945 }
964 case TThrow: { /* labeled failure */ 946 case TThrow: { /* labeled failure */
965 addthrowinstruction(compst, (byte) tree->u.label); 947 addinstruction(compst, IThrow, (byte) tree->u.label);
966 break; 948 break;
967 } 949 }
968 case TLabChoice: { /* labeled failure */ 950 case TLabChoice: { /* labeled failure */