ref: 1062e70c86132e8784a16370892174ed32cc9cd1
parent: 8a26e2094385afe25b97b27b5da368e6f4432669
author: Tor Andersson <tor.andersson@gmail.com>
date: Mon Apr 17 11:01:53 EDT 2017
Track strictness during runtime based on 'use strict' pragma.
--- a/jsi.h
+++ b/jsi.h
@@ -131,6 +131,7 @@
int envtop;
int tracetop;
int top, bot;
+ int strict;
js_Instruction *pc;
};
--- a/jsrun.c
+++ b/jsrun.c
@@ -1167,6 +1167,7 @@
J->trybuf[J->trytop].tracetop = J->tracetop;
J->trybuf[J->trytop].top = J->top;
J->trybuf[J->trytop].bot = J->bot;
+ J->trybuf[J->trytop].strict = J->strict;
J->trybuf[J->trytop].pc = pc;
return J->trybuf[J->trytop++].buf;
}
@@ -1180,6 +1181,7 @@
J->trybuf[J->trytop].tracetop = J->tracetop;
J->trybuf[J->trytop].top = J->top;
J->trybuf[J->trytop].bot = J->bot;
+ J->trybuf[J->trytop].strict = J->strict;
J->trybuf[J->trytop].pc = NULL;
return J->trybuf[J->trytop++].buf;
}
@@ -1201,6 +1203,7 @@
J->tracetop = J->trybuf[J->trytop].tracetop;
J->top = J->trybuf[J->trytop].top;
J->bot = J->trybuf[J->trytop].bot;
+ J->strict = J->trybuf[J->trytop].strict;
js_pushvalue(J, v);
longjmp(J->trybuf[J->trytop].buf, 1);
}
@@ -1271,6 +1274,7 @@
js_Instruction *pc = F->code;
enum js_OpCode opcode;
int offset;
+ int savestrict;
const char *str;
js_Object *obj;
@@ -1279,6 +1283,9 @@
int ix, iy, okay;
int b;
+ savestrict = J->strict;
+ J->strict = F->strict;
+
while (1) {
if (J->gccounter > JS_GCLIMIT) {
J->gccounter = 0;
@@ -1723,6 +1730,7 @@
break;
case OP_RETURN:
+ J->strict = savestrict;
return;
case OP_LINE: