aboutsummaryrefslogtreecommitdiff
path: root/lpcode.c
diff options
context:
space:
mode:
authorSérgio Queiroz <sqmedeiros@gmail.com>2017-12-12 11:42:14 -0300
committerSérgio Queiroz <sqmedeiros@gmail.com>2017-12-12 11:42:14 -0300
commit26c1b9aa78e10b2ed2d36d151033fe94254fa8c5 (patch)
tree743f8cca325a2788cd0aa9e98de79ab275884d01 /lpcode.c
parent5ffef3da93ad53069d2510a75b11ecbb1b6e8aa7 (diff)
downloadlpeglabel-26c1b9aa78e10b2ed2d36d151033fe94254fa8c5.tar.gz
lpeglabel-26c1b9aa78e10b2ed2d36d151033fe94254fa8c5.tar.bz2
lpeglabel-26c1b9aa78e10b2ed2d36d151033fe94254fa8c5.zip
Using field 'key' to allow strings as labels (partial)
Diffstat (limited to 'lpcode.c')
-rw-r--r--lpcode.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/lpcode.c b/lpcode.c
index f335dcb..d67d42f 100644
--- a/lpcode.c
+++ b/lpcode.c
@@ -519,6 +519,15 @@ static int addinstruction (CompileState *compst, Opcode op, int aux) {
519 return i; 519 return i;
520} 520}
521 521
522/* labeled failure */
523static int addthrowinstruction (CompileState *compst, int aux, int key) {
524 int i = addinstruction(compst, IThrow, aux);
525 getinstr(compst, i).i.key = key;
526 return i;
527}
528
529/* labeled failure */
530
522 531
523/* 532/*
524** Add an instruction followed by space for an offset (to be set later) 533** Add an instruction followed by space for an offset (to be set later)
@@ -996,7 +1005,10 @@ static void codegen (CompileState *compst, TTree *tree, int opt, int tt,
996 tree = sib2(tree); goto tailcall; 1005 tree = sib2(tree); goto tailcall;
997 } 1006 }
998 case TThrow: { /* labeled failure */ 1007 case TThrow: { /* labeled failure */
999 addinstruction(compst, IThrow, (byte) tree->u.label); 1008 /*printf("TThrow %s top %d\n", lua_typename(compst->L, -1), lua_gettop(compst->L));*/
1009 /*lua_rawgeti(compst->L, -1, tree->key);*/
1010 /*printf("Throw2 lab = %s\n", lua_tostring(compst->L, -1));*/
1011 addthrowinstruction(compst, (byte) tree->u.label, tree->key);
1000 break; 1012 break;
1001 } 1013 }
1002 case TRecov: { /* labeled failure */ 1014 case TRecov: { /* labeled failure */